This commit is contained in:
2025-03-24 16:54:05 +03:30
parent 1b8bcfaece
commit 9c034fce4f
3 changed files with 1101 additions and 13 deletions
+524 -6
View File
@@ -31,6 +31,7 @@
enum ENUM_X121SMC_XWZ_PROVIDERS
{
X121SMC_XWZ_PROVIDER_NONE,
X121SMC_XWZ_PROVIDER_XFVGMA,
X121SMC_XWZ_PROVIDER_XBREAKED_BOX,
X121SMC_XWZ_PROVIDER_XREJECTED_BOX,
X121SMC_XWZ_PROVIDER_XACTIVATED_BOX,
@@ -911,6 +912,474 @@ struct X121SMCStrategyXWZWorkingZone
sharpConsolidation.Clean();
}
//
// Preparing Waiting Box based on FVG State ...
if (fvgStateEvents.hasNewSharp)
{
//
// Select Newest Sharp Change ...
XBoxZone sharp;
idx = GetYoungest(fvgState.sharps);
has = IsValidIndex(idx);
if (has)
{
//
XOHCL endBar;
XOHCL startBar;
int totalBars = 0;
int orderBlocksIDX[];
int bullBarsCount = 0;
int bearBarsCount = 0;
int validPercent = 75;
//
sharp = fvgState.sharps[idx];
sharp.type = "XSHPOBX";
bool isSharpBullish = sharp.IsBullish();
//
// Validate End Bar ...
if (sharp.IsValid())
{
//
// Validate End Bar Direction ...
int endBarIDX = GetBarIndex(
sharp.symbol,
sharp.period,
sharp.to //
);
//
has = endBar.Init(
sharp.symbol,
sharp.period,
endBarIDX + 1 //
);
//
if (has)
{
//
has = sharp.dir == endBar.GetDirection();
if (!has)
{
sharp.Clean();
}
}
}
//
// Validate Start Bar ...
if (sharp.IsValid())
{
//
// Validate Start Bar Direction ...
int startBarIDX = GetBarIndex(
sharp.symbol,
sharp.period,
sharp.from //
);
//
has = startBar.Init(
sharp.symbol,
sharp.period,
startBarIDX + 1 //
);
//
if (has)
{
//
has = sharp.dir == Opposit(startBar.GetDirection());
if (!has)
{
sharp.Clean();
}
}
}
//
// Validate OrderBlocks ...
if (sharp.IsValid())
{
//
int end = endBar.Index();
int start = startBar.Index();
for (int i = start; i >= end; i--)
{
//
XOHCL iBar;
has = iBar.Init(
sharp.symbol,
sharp.period,
i //
);
if (!has)
{
//
iBar.Clean();
continue;
}
//
totalBars++;
//
bool isBullish = iBar.IsBullish();
if (isBullish)
{
//
bullBarsCount++;
//
if (!isSharpBullish)
{
//
Add(
i,
orderBlocksIDX //
);
}
}
else
{
//
bearBarsCount++;
//
if (isSharpBullish)
{
//
Add(
i,
orderBlocksIDX //
);
}
}
//
iBar.Clean();
}
//
// Follow Order Blocks ...
has = HasChild(orderBlocksIDX);
if (has)
{
//
int bullBarsPercent = (bullBarsCount * 100) / totalBars;
int bearBarsPercent = (bearBarsCount * 100) / totalBars;
//
has = isSharpBullish
? bullBarsPercent >= validPercent
: bearBarsPercent >= validPercent;
if (has)
{
//
// Prepare Waiting Boxes ...
count = ArraySize(orderBlocksIDX);
for (int i = 0; i < count; i++)
{
//
XOHCL iBar;
has = iBar.Init(
sharp.symbol,
sharp.period,
orderBlocksIDX[i] //
);
if (!has)
{
//
iBar.Clean();
continue;
}
//
XBoxZone iOB;
XBoxZone iFVG;
//
iOB.to = sharp.to;
iOB.type = "XOBX";
iOB.dir = sharp.dir;
iOB.from = iBar.time;
iOB.lower = iBar.low;
iOB.upper = iBar.high;
iOB.period = iBar.period;
iOB.symbol = iBar.symbol;
//
// Select FVG ...
has = iOB.IsValid();
if (has)
{
//
// Select FVG ...
has = HasChild(fvgState.fairValueGaps);
if (has)
{
//
XBoxZone tmpBoxes[];
if (isSharpBullish)
{
//
ToBox(
fvgState.bullishFairValueGaps,
tmpBoxes //
);
}
else
{
//
ToBox(
fvgState.bearishFairValueGaps,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate FVG ...
bool isDirPassed = iBox.dir == sharp.dir;
bool isFromPassed = iBox.from >= iOB.from;
bool isPricePassed = IsBoxInsideOr(iBox, iOB);
//
has = isDirPassed &&
isFromPassed &&
isPricePassed;
if (has)
{
//
iFVG = iBox;
iBox.Clean();
break;
}
//
iBox.Clean();
}
}
Clean(tmpBoxes);
}
}
//
has =
sharp.IsValid() &&
iOB.IsValid() &&
iFVG.IsValid();
if (has)
{
//
XSignalBox iSBox;
//
iSBox.ob = iOB;
iSBox.fvg = iFVG;
iSBox.sharp = sharp;
//
AddRef(
iSBox,
waitingBoxes //
);
//
iSBox.Clean();
}
//
iOB.Clean();
iFVG.Clean();
iBar.Clean();
}
}
}
else
{
//
// Follow Non Order Block ...
// First Found FVGs ...
XBoxZone iOB;
XBoxZone iFVG;
XBoxZone tmpBoxes[];
if (isSharpBullish)
{
//
ToBox(
fvgState.bullishFairValueGaps,
tmpBoxes //
);
}
else
{
//
ToBox(
fvgState.bearishFairValueGaps,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate FVG ...
bool isDirPassed = iBox.dir == sharp.dir;
bool isFromPassed = iBox.from >= sharp.from;
bool isPricePassed = IsBoxInside(iBox, sharp);
//
has = isDirPassed &&
isFromPassed &&
isPricePassed;
if (has)
{
//
iFVG = iBox;
//
// Now we Have to Create an Order Block ...
//
XOHCL iToBar;
XOHCL iFromBar;
//
int fromIDX = GetBarIndex(
iBox.symbol,
iBox.period,
iBox.from //
);
int toIDX = GetBarIndex(
iBox.symbol,
iBox.period,
iBox.to //
);
has = iToBar.Init(
iBox.symbol,
iBox.period,
toIDX //
);
has =
has &&
iFromBar.Init(
iBox.symbol,
iBox.period,
fromIDX //
);
if (!has)
{
//
iBox.Clean();
iToBar.Clean();
iFromBar.Clean();
//
break;
}
//
iOB.to = iBox.to;
iOB.type = "XOBX";
iOB.dir = iBox.dir;
iOB.from = iBox.from;
iOB.symbol = iBox.symbol;
iOB.period = iBox.period;
iOB.lower = MathMin(iToBar.low, iFromBar.low);
iOB.upper = MathMax(iToBar.high, iFromBar.high);
//
iBox.Clean();
iToBar.Clean();
iFromBar.Clean();
break;
}
//
iBox.Clean();
}
}
Clean(tmpBoxes);
//
has = iOB.IsValid() &&
iFVG.IsValid() &&
sharp.IsValid();
if (has)
{
//
XSignalBox iSBox;
//
iSBox.ob = iOB;
iSBox.fvg = iFVG;
iSBox.sharp = sharp;
//
AddRef(
iSBox,
waitingBoxes //
);
//
iSBox.Clean();
}
//
iOB.Clean();
iFVG.Clean();
}
}
//
endBar.Clean();
startBar.Clean();
Clean(orderBlocksIDX);
}
}
//
count = CountWaitingBoxes();
result = IsValidSize(count);
@@ -1498,7 +1967,7 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------------
// Activated Box ...
// ---------------------------------------------------
bool useSenario2 = false;
bool useSenario2 = true;
bool isSenario2Happend = false;
bool isSenario2Bullish = false;
bool isSenario2Bearish = false;
@@ -1537,7 +2006,7 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------------
// Breaked Box ...
// ---------------------------------------------------
bool useSenario3 = false;
bool useSenario3 = true;
bool isSenario3Happend = false;
bool isSenario3Bullish = false;
bool isSenario3Bearish = false;
@@ -1545,14 +2014,39 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario2Happend &&
useSenario3)
{
//
isSenario3Happend = cParser.HasBreakedBoxConditions(
X_CYCLE_DECISION,
box,
dir,
breakedBoxes,
provider,
barIndex //
);
//
isSenario3Bullish =
isSenario3Happend &&
IsBullish(dir);
//
isSenario3Bearish =
isSenario3Happend &&
IsBearish(dir);
//
if (isSenario3Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XACTIVATED_BOX;
}
}
//
// Senario 4:
// -----------------------------------------------
// Detect Signal Box Based On XHKMA Conditions ...
// Detect Signal Box Based On FVG Conditions ...
// -----------------------------------------------
bool useSenario4 = false;
bool useSenario4 = true;
bool isSenario4Happend = false;
bool isSenario4Bullish = false;
bool isSenario4Bearish = false;
@@ -1561,14 +2055,38 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario3Happend &&
useSenario4)
{
//
isSenario4Happend = cParser.HasXFVGMAConditions(
X_CYCLE_DECISION,
box,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario4Bullish =
isSenario4Happend &&
IsBullish(dir);
//
isSenario4Bearish =
isSenario4Happend &&
IsBearish(dir);
//
if (isSenario4Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XFVGMA;
}
}
//
// Senario 5:
// ---------------------------------------------
// XSHCNZ Signal Box Detection Conditions ...
// ---------------------------------------------
bool useSenario5 = true;
bool useSenario5 = false;
bool isSenario5Happend = false;
bool isSenario5Bullish = false;
bool isSenario5Bearish = false;