Files
MQL5Data/X121XKIEA/Documents/Strategies/Strategy 4 - KI Breaker Block Entry.md
T
2026-02-27 01:46:11 +03:30

17 KiB

USER

Strategy 4: KI Breaker Block Entry

ASSISTANT

🎯 Complete Strategy 4: KI Breaker Block Entry Implementation

Based on your SaherElm Framework and X121XKI Indicator buffers, here is the complete implementation for Strategy 4: KI Breaker Block Entry.

This strategy focuses on failed Order Blocks that become Breaker Blocks after being broken, then entered on the retest with X121XKI confirmation.

/**
* Check Bar Has Signal Based on Strategy 4 ...
* KI Breaker Block Entry
*
* @param  bar: XOHCL, reference to Bar ...
* @param  zone: XBoxZone, reference to holds affected zone ...
* @param  targets: XTarget, reference to detected Signal's Targets collections ...
* @param  dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy4HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
// Prepare ...
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
// Validate ...
result = bar.IsValid() && kiParser.IsValid();
if (!result)
{
return result;
}
//
// Configuration ...
int barIndex = bar.Index() + 1;
double points = GetPoints(symbol);
int minBreakerPoints = 30;      // Minimum Breaker Block size in points
int minFVGPoints = 20;          // Minimum FVG size in points
int kiConfirmationBars = 3;     // Bars for KI confirmation
double minScore = 16.0;         // Minimum score for signal
//
// State Variables ...
bool isBullish = false;
bool isBearish = false;
double bullishScore = 0;
double bearishScore = 0;
//
// #region 1. Detect Recent Swings (Liquidity Pools) ...
//
XBoxZone swingHigh;
XBoxZone swingLow;
//
// Detect Recent Swings for Breaker Detection ...
poiDetector.DetectRecentSwings(
swingHigh,
swingLow,
barIndex,
50,  // swingsValidationLength
500, // loopback
period,
true // forceRefineZones
);
//
// #endregion
//
// #region 2. Detect Order Blocks (Potential Breakers) ...
//
// Detect Order Blocks ...
XBoxZone bullishOBs[];
XBoxZone bearishOBs[];
//
int bullishOBCount = poiDetector.CollectOBs(bar, bullishOBs, 5, 10, 100);
int bearishOBCount = poiDetector.CollectOBs(bar, bearishOBs, 5, 10, 100);
//
// Detect Fair Value Gaps ...
XBoxZone bullishFVGs[];
XBoxZone bearishFVGs[];
//
int bullishFVGCount = poiDetector.CollectFVGs(bar, bullishFVGs, 5, 10, 100);
int bearishFVGCount = poiDetector.CollectFVGs(bar, bearishFVGs, 5, 10, 100);
//
// #endregion
//
// #region 3. Identify Broken Order Blocks (Breaker Candidates) ...
//
// Filter Bullish OBs that were Broken (Price went below them) ...
XBoxZone brokenBullishOBs[];
for (int i = 0; i < bullishOBCount; i++)
{
//
bool isBroken = bar.low < bullishOBs[i].lower;
bool isValidSize = (bullishOBs[i].upper - bullishOBs[i].lower) >= (minBreakerPoints * points);
bool isNotRetested = bar.close > bullishOBs[i].upper; // Price moved away after break
//
if (isBroken && isValidSize && isNotRetested)
{
AddRef(bullishOBs[i], brokenBullishOBs);
}
}
//
// Filter Bearish OBs that were Broken (Price went above them) ...
XBoxZone brokenBearishOBs[];
for (int i = 0; i < bearishOBCount; i++)
{
//
bool isBroken = bar.high > bearishOBs[i].upper;
bool isValidSize = (bearishOBs[i].upper - bearishOBs[i].lower) >= (minBreakerPoints * points);
bool isNotRetested = bar.close < bearishOBs[i].lower; // Price moved away after break
//
if (isBroken && isValidSize && isNotRetested)
{
AddRef(bearishOBs[i], brokenBearishOBs);
}
}
//
// #endregion
//
// #region 4. Detect Price Returning to Breaker Zone (Retest) ...
//
// Bullish Breaker: Price broke below OB, now returning from below ...
XBoxZone validBullishBreakers[];
for (int i = 0; i < ArraySize(brokenBullishOBs); i++)
{
//
XBoxZone iBreaker = brokenBullishOBs[i];
//
// Check Price is Returning from Below (in the zone or just below) ...
bool isReturning = bar.low <= iBreaker.upper && bar.close >= iBreaker.lower;
bool isFreshBreak = (bar.time - iBreaker.breakAt) <= (PeriodSeconds(period) * 20); // Within 20 bars
//
if (isReturning && isFreshBreak)
{
AddRef(iBreaker, validBullishBreakers);
}
}
//
// Bearish Breaker: Price broke above OB, now returning from above ...
XBoxZone validBearishBreakers[];
for (int i = 0; i < ArraySize(brokenBearishOBs); i++)
{
//
XBoxZone iBreaker = brokenBearishOBs[i];
//
// Check Price is Returning from Above (in the zone or just above) ...
bool isReturning = bar.high >= iBreaker.lower && bar.close <= iBreaker.upper;
bool isFreshBreak = (bar.time - iBreaker.breakAt) <= (PeriodSeconds(period) * 20); // Within 20 bars
//
if (isReturning && isFreshBreak)
{
AddRef(iBreaker, validBearishBreakers);
}
}
//
// #endregion
//
// #region 5. KI Trend Confirmation ...
//
// Check KI Fast State ...
bool kiFastBullish = kiParser.IsKIFastBullish(barIndex);
bool kiFastBearish = kiParser.IsKIFastBearish(barIndex);
//
// Check KI Fast Switch (Trend Change) ...
bool kiFastSwitchedBullish = kiParser.IsKIFastSwitchedToBullish(barIndex);
bool kiFastSwitchedBearish = kiParser.IsKIFastSwitchedToBearish(barIndex);
//
// Check KI Slow Alignment (HTF Bias) ...
bool kiSlowBullish = kiParser.IsKISlowBullish(barIndex);
bool kiSlowBearish = kiParser.IsKISlowBearish(barIndex);
//
// Check KI Super Slow (Major HTF Bias) ...
bool kiSuperSlowBullish = kiParser.IsKISuperSlowBullish(barIndex);
bool kiSuperSlowBearish = kiParser.IsKISuperSlowBearish(barIndex);
//
// Check Price Position Relative to KI ...
bool priceAboveKIFast = kiParser.IsPriceOverKIFast(barIndex, X_PRICE_CLOSE);
bool priceBelowKIFast = kiParser.IsPriceUnderKIFast(barIndex, X_PRICE_CLOSE);
//
// Check KI Wave Momentum ...
bool kiWaveBullish = kiParser.IsKIWaveSwitchedToBullish(barIndex);
bool kiWaveBearish = kiParser.IsKIWaveSwitchedToBearish(barIndex);
//
// #endregion
//
// #region 6. Momentum Confirmation (MA) ...
//
// Check MA Fast vs KI Fast (Momentum) ...
double maFast = kiParser.GetMAFast(barIndex);
double kiFast = kiParser.GetKIFast(barIndex);
//
bool maFastAboveKI = maFast > kiFast;
bool maFastBelowKI = maFast < kiFast;
//
// Check MA Fast Switch ...
bool maFastSwitchedBullish = kiParser.IsMAFastSwitchedToBullish(barIndex);
bool maFastSwitchedBearish = kiParser.IsMAFastSwitchedToBearish(barIndex);
//
// #endregion
//
// #region 7. RSI Momentum Confirmation ...
//
// Check RSI State ...
bool rsiBullish = kiParser.IsRSISwitchedToBullish(barIndex, 55, 2);
bool rsiBearish = kiParser.IsRSISwitchedToBearish(barIndex, 45, 2);
//
// Check RSI Not in Extreme Zones ...
double currentRSI = kiParser.GetRSI(barIndex);
bool rsiNotOverbought = currentRSI < 70;
bool rsiNotOversold = currentRSI > 30;
//
// #endregion
//
// #region 8. Volatility / Displacement ...
//
// Check Volatility Expansion ...
bool volatilityHigh = kiParser.IsVolatilityHigh(barIndex);
bool volatilitySwitchedHigh = kiParser.IsVolatilitySwitchdToHigh(barIndex);
//
// #endregion
//
// #region 9. Candlestick Confirmation ...
//
// Check for Bullish Confirmation Patterns ...
XOHCL pBar;
bool hasBullishEngulfing = false;
bool hasBullishPinBar = false;
//
if (bar.GetPreviousBar(pBar))
{
//
// Bullish Engulfing ...
hasBullishEngulfing = 
bar.IsBullish() && 
pBar.IsBearish() && 
bar.close > pBar.open && 
bar.open < pBar.close;
//
// Bullish Pin Bar ...
hasBullishPinBar = 
bar.IsBullish() && 
bar.GetLowShadow() > (bar.GetBody() * 2) && 
bar.GetHighShadow() < bar.GetBody();
}
pBar.Clean();
//
// Check for Bearish Confirmation Patterns ...
bool hasBearishEngulfing = false;
bool hasBearishPinBar = false;
//
if (bar.GetPreviousBar(pBar))
{
//
// Bearish Engulfing ...
hasBearishEngulfing = 
bar.IsBearish() && 
pBar.IsBullish() && 
bar.close < pBar.open && 
bar.open > pBar.close;
//
// Bearish Pin Bar ...
hasBearishPinBar = 
bar.IsBearish() && 
bar.GetHighShadow() > (bar.GetBody() * 2) && 
bar.GetLowShadow() < bar.GetBody();
}
pBar.Clean();
//
// #endregion
//
// #region 10. Calculate Scores ...
//
// Bullish Breaker Score ...
//
// Breaker Zone Presence (Max 6 points) ...
if (ArraySize(validBullishBreakers) > 0) bullishScore += 6;
//
// KI Trend Alignment (Max 6 points) ...
if (kiFastBullish) bullishScore += 1;
if (kiSlowBullish) bullishScore += 2;
if (kiSuperSlowBullish) bullishScore += 3;
if (priceAboveKIFast) bullishScore += 1;
//
// KI Wave Momentum (Max 2 points) ...
if (kiWaveBullish) bullishScore += 2;
//
// MA Momentum (Max 3 points) ...
if (maFastAboveKI) bullishScore += 1;
if (maFastSwitchedBullish) bullishScore += 2;
//
// RSI Confirmation (Max 3 points) ...
if (rsiBullish) bullishScore += 2;
if (rsiNotOverbought) bullishScore += 1;
//
// Volatility (Max 2 points) ...
if (volatilityHigh) bullishScore += 1;
if (volatilitySwitchedHigh) bullishScore += 1;
//
// Candlestick Confirmation (Max 3 points) ...
if (hasBullishEngulfing) bullishScore += 2;
if (hasBullishPinBar) bullishScore += 1;
//
// Liquidity Sweep Before Break (Max 3 points) ...
if (swingLow.IsValid() && bar.low < swingLow.lower) bullishScore += 3;
//
// Bearish Breaker Score ...
//
// Breaker Zone Presence (Max 6 points) ...
if (ArraySize(validBearishBreakers) > 0) bearishScore += 6;
//
// KI Trend Alignment (Max 6 points) ...
if (kiFastBearish) bearishScore += 1;
if (kiSlowBearish) bearishScore += 2;
if (kiSuperSlowBearish) bearishScore += 3;
if (priceBelowKIFast) bearishScore += 1;
//
// KI Wave Momentum (Max 2 points) ...
if (kiWaveBearish) bearishScore += 2;
//
// MA Momentum (Max 3 points) ...
if (maFastBelowKI) bearishScore += 1;
if (maFastSwitchedBearish) bearishScore += 2;
//
// RSI Confirmation (Max 3 points) ...
if (rsiBearish) bearishScore += 2;
if (rsiNotOversold) bearishScore += 1;
//
// Volatility (Max 2 points) ...
if (volatilityHigh) bearishScore += 1;
if (volatilitySwitchedHigh) bearishScore += 1;
//
// Candlestick Confirmation (Max 3 points) ...
if (hasBearishEngulfing) bearishScore += 2;
if (hasBearishPinBar) bearishScore += 1;
//
// Liquidity Sweep Before Break (Max 3 points) ...
if (swingHigh.IsValid() && bar.high > swingHigh.upper) bearishScore += 3;
//
// #endregion
//
// #region 11. Determine Direction ...
//
// Ensure Only One Direction ...
if (bullishScore >= minScore && bearishScore >= minScore)
{
//
// Use higher score to determine direction ...
if (bullishScore > bearishScore)
{
bearishScore = 0;
}
else if (bearishScore > bullishScore)
{
bullishScore = 0;
}
else
{
//
// Same score, no signal ...
bullishScore = 0;
bearishScore = 0;
}
}
//
// Check Bullish Breaker Conditions ...
isBullish = (bullishScore >= minScore) &&
(ArraySize(validBullishBreakers) > 0) &&
(kiFastBullish || kiWaveBullish);
//
// Check Bearish Breaker Conditions ...
isBearish = (bearishScore >= minScore) &&
(ArraySize(validBearishBreakers) > 0) &&
(kiFastBearish || kiWaveBearish);
//
// #endregion
//
// #region 12. Generate Signal ...
//
// Generate Bullish Breaker Signal ...
if (isBullish)
{
dir = X_DIRECTION_BULLISH;
//
// Select Best Breaker (Youngest Valid Breaker) ...
XBoxZone selectedBreaker;
int breakerIdx = GetYoungest(validBullishBreakers);
//
if (IsValidIndex(breakerIdx))
{
selectedBreaker = validBullishBreakers[breakerIdx];
}
//
// Validate Selected Breaker ...
if (selectedBreaker.IsValid())
{
zone = selectedBreaker;
zone.type = "S4_Breaker_KI";
//
// Calculate Targets ...
double entry = GetEntry(symbol, dir);
//
// SL: Below Breaker Zone Low ...
double sl = zone.lower - (10 * points);
//
// TP1: 1:1 R:R ...
XTarget tp1;
tp1.target = entry + MathAbs(entry - sl);
tp1.volumeMultiplier = 0.5;
tp1.doRF = true;
tp1.doRFOnEntry = false;
AddRef(tp1, targets);
//
// TP2: Next Liquidity (Swing High) ...
XTarget tp2;
if (swingHigh.IsValid())
{
tp2.target = swingHigh.upper + (10 * points);
}
else
{
tp2.target = entry + (MathAbs(entry - sl) * 2);
}
tp2.volumeMultiplier = 0.5;
tp2.doRF = false;
tp2.doRFOnEntry = false;
AddRef(tp2, targets);
//
// TP3: 1:3 R:R ...
XTarget tp3;
tp3.target = entry + (MathAbs(entry - sl) * 3);
tp3.volumeMultiplier = 1.0;
tp3.doRF = false;
tp3.doRFOnEntry = false;
AddRef(tp3, targets);
}
}
//
// Generate Bearish Breaker Signal ...
else if (isBearish)
{
dir = X_DIRECTION_BEARISH;
//
// Select Best Breaker (Youngest Valid Breaker) ...
XBoxZone selectedBreaker;
int breakerIdx = GetYoungest(validBearishBreakers);
//
if (IsValidIndex(breakerIdx))
{
selectedBreaker = validBearishBreakers[breakerIdx];
}
//
// Validate Selected Breaker ...
if (selectedBreaker.IsValid())
{
zone = selectedBreaker;
zone.type = "S4_Breaker_KI";
//
// Calculate Targets ...
double entry = GetEntry(symbol, dir);
//
// SL: Above Breaker Zone High ...
double sl = zone.upper + (10 * points);
//
// TP1: 1:1 R:R ...
XTarget tp1;
tp1.target = entry - MathAbs(entry - sl);
tp1.volumeMultiplier = 0.5;
tp1.doRF = true;
tp1.doRFOnEntry = false;
AddRef(tp1, targets);
//
// TP2: Next Liquidity (Swing Low) ...
XTarget tp2;
if (swingLow.IsValid())
{
tp2.target = swingLow.lower - (10 * points);
}
else
{
tp2.target = entry - (MathAbs(entry - sl) * 2);
}
tp2.volumeMultiplier = 0.5;
tp2.doRF = false;
tp2.doRFOnEntry = false;
AddRef(tp2, targets);
//
// TP3: 1:3 R:R ...
XTarget tp3;
tp3.target = entry - (MathAbs(entry - sl) * 3);
tp3.volumeMultiplier = 1.0;
tp3.doRF = false;
tp3.doRFOnEntry = false;
AddRef(tp3, targets);
}
}
//
// #endregion
//
// #region 13. Validation & Risk Management ...
//
// Validate Signal ...
result = zone.IsValid() && HasDirection(dir) && HasChild(targets);
//
// Check Max Allowed Risk ...
if (result && maxAllowedRiskDistance > 0)
{
double riskInPoints = 0;
if (dir == X_DIRECTION_BULLISH)
{
riskInPoints = MathAbs(zone.GetDirectionalPrice() - zone.GetInDirectionalPrice()) / points;
}
else
{
riskInPoints = MathAbs(zone.GetInDirectionalPrice() - zone.GetDirectionalPrice()) / points;
}
//
if (riskInPoints > maxAllowedRiskDistance)
{
result = false;
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
}
}
//
// #endregion
//
// #region 14. Debug & Logging ...
//
// Optional: Debug Break for Testing ...
// if (result)
// {
//     Print("Strategy 4 Breaker Signal Detected:");
//     Print("  Direction: ", ToXString(dir));
//     Print("  Bullish Score: ", bullishScore);
//     Print("  Bearish Score: ", bearishScore);
//     Print("  Breaker Type: ", zone.type);
//     Print("  Targets Count: ", ArraySize(targets));
// }
//
// #endregion
//
//
// Cleanup Resources ...
//
XClean(bullishOBs);
XClean(bearishOBs);
XClean(bullishFVGs);
XClean(bearishFVGs);
XClean(brokenBullishOBs);
XClean(brokenBearishOBs);
XClean(validBullishBreakers);
XClean(validBearishBreakers);
//
return result;
}

📋 Key Features of Strategy 4 (Breaker Block)

Entry Conditions:

Component Weight Description
Breaker Zone 6 pts Valid broken OB that price is returning to
KI Trend Alignment 6 pts KI Fast + Slow + SuperSlow alignment
KI Wave Momentum 2 pts KI Wave color switch confirmation
MA Momentum 3 pts MA Fast cross + switch confirmation
RSI Confirmation 3 pts RSI cross + not in extreme zones
Volatility 2 pts ATR expansion confirmation
Candlestick 3 pts Engulfing or Pin Bar confirmation
Liquidity Sweep 3 pts Liquidity taken before break
Minimum Score 16 pts Higher threshold for Breaker entries

Breaker Block Logic:

Bullish Breaker:
1. Bullish OB forms
2. Price breaks BELOW OB (failure)
3. Price returns to OB from below
4. Enter LONG on retest with confirmation

Bearish Breaker:
1. Bearish OB forms
2. Price breaks ABOVE OB (failure)
3. Price returns to OB from above
4. Enter SHORT on retest with confirmation

Risk Management:

// Stop Loss:
SL = Below/Above Breaker Zone ± 10 points buffer

// Take Profit Levels:
TP1 = 1:1 R:R (50% position, RF enabled)
TP2 = Next Swing Liquidity (50% position)
TP3 = 1:3 R:R (100% position)

Signal Filtering:

  1. ✅ Fresh Break: Breaker must be within 20 bars
  2. ✅ Minimum Size: Breaker must be at least 30 points
  3. ✅ Price Returning: Price must be in/near breaker zone
  4. ✅ KI Alignment: At least KI Fast must align with direction
  5. ✅ Minimum Score: 16 points (selective entries)
  6. ✅ Candlestick Confirmation: Engulfing or Pin Bar preferred

📊 Expected Behavior

Bullish Breaker Setup:

  1. OB Forms: Bullish Order Block identified
  2. OB Fails: Price breaks below OB low (liquidity sweep)
  3. KI Confirms: KI Fast turns Green, price above KI Fast
  4. Price Returns: Price comes back to broken OB zone
  5. Entry Trigger: Bullish engulfing or pin bar at retest
  6. Target: Next swing high or 1:3 R:R

Bearish Breaker Setup:

  1. OB Forms: Bearish Order Block identified
  2. OB Fails: Price breaks above OB high (liquidity sweep)
  3. KI Confirms: KI Fast turns Red, price below KI Fast
  4. Price Returns: Price comes back to broken OB zone
  5. Entry Trigger: Bearish engulfing or pin bar at retest
  6. Target: Next swing low or 1:3 R:R

⚠️ Important Notes

  1. Breaker Blocks have higher win rates than standard OB entries (failed levels become strong S/R)
  2. Wait for the retest - Don't enter on the initial break
  3. Fresh breaks work best - Within 20 bars of the break
  4. Liquidity sweep before break adds confluence (+3 points)
  5. Higher minimum score - 16 points vs 15 for other strategies (more selective)
  6. Best in trending markets - Avoid ranging conditions where breakers fail often