This commit is contained in:
2025-03-21 10:23:40 +03:30
parent 57bb590094
commit 7970785883
3 changed files with 364 additions and 244 deletions
@@ -2640,6 +2640,12 @@ struct X121SMCStrategyConditionParser
// //
bool result = false; bool result = false;
//
// Configure ...
bool forceRetestBox = false;
bool forceHolderBox = false;
bool forceConsolidationZone = false;
// //
// Fil Selected Data ... // Fil Selected Data ...
XPOIState cState; XPOIState cState;
@@ -2755,6 +2761,7 @@ struct X121SMCStrategyConditionParser
IsBearish(iBarPosDir); IsBearish(iBarPosDir);
// //
XBoxZone selectedBox;
XSignalBox iSignalBox; XSignalBox iSignalBox;
count = ArraySize(waitingBoxes); count = ArraySize(waitingBoxes);
has = IsValidSize(count); has = IsValidSize(count);
@@ -2807,18 +2814,41 @@ struct X121SMCStrategyConditionParser
// //
has = has =
isBullish isBullish
? isBarValidForBullish && ? (hasFVG
(hasFVG ? isFVGBullishRejected
? isFVGBullishRejected : isOBBullishRejected)
: isOBBullishRejected) : (hasFVG
: isBarValidForBearish && ? isFVGBearishRejected
(hasFVG : isOBBearishRejected);
? isFVGBearishRejected
: isOBBearishRejected); //
// Force Using OB ...
if (!has && hasFVG)
{
//
has = isBullish
? isOBBullishRejected
: isOBBearishRejected;
//
selectedBox = iBox.ob;
}
if (has) if (has)
{ {
// //
iSignalBox = iBox; iSignalBox = iBox;
if (!selectedBox.IsValid())
{
//
if (hasFVG)
{
selectedBox = iBox.fvg;
}
else
{
selectedBox = iBox.ob;
}
}
iBox.Clean(); iBox.Clean();
break; break;
} }
@@ -2827,30 +2857,20 @@ struct X121SMCStrategyConditionParser
iBox.Clean(); iBox.Clean();
} }
} }
has = iSignalBox.IsValid(); has =
iSignalBox.IsValid() &&
selectedBox.IsValid();
// //
// Retest Signal ... // Retest Signal ...
int retests = 0; int retests = 0;
if (has) if (has)
{ {
//
bool hasFVG = iSignalBox.fvg.IsValid();
XBoxZone iBox;
if (hasFVG)
{
iBox = iSignalBox.fvg;
}
else
{
iBox = iSignalBox.ob;
}
// //
int iFromIDX = GetBarIndex( int iFromIDX = GetBarIndex(
cBar.symbol, cBar.symbol,
cBar.period, cBar.period,
iBox.from // selectedBox.from //
); );
has = IsValidIndex(iFromIDX); has = IsValidIndex(iFromIDX);
if (has) if (has)
@@ -2870,21 +2890,21 @@ struct X121SMCStrategyConditionParser
// //
bool isBullishRetested = bool isBullishRetested =
// //
iBar.low < iBox.upper && iBar.low < selectedBox.upper &&
iBar.GetDown() > iBox.upper iBar.GetDown() > selectedBox.upper
// //
; ;
// //
bool isBearishRetested = bool isBearishRetested =
// //
iBar.high > iBox.lower && iBar.high > selectedBox.lower &&
iBar.GetUp() < iBox.lower iBar.GetUp() < selectedBox.lower
// //
; ;
// //
has = iBox.IsBullish() has = selectedBox.IsBullish()
? isBullishRetested ? isBullishRetested
: isBearishRetested; : isBearishRetested;
if (has) if (has)
@@ -2896,110 +2916,119 @@ struct X121SMCStrategyConditionParser
iBar.Clean(); iBar.Clean();
} }
} }
//
iBox.Clean();
} }
// //
bool isSignalBoxRetested = retests > 1; bool isSignalBoxRetested =
!forceRetestBox
? retests >= 1
: retests >= 2;
bool hasSignalBox = iSignalBox.IsValid(); bool hasSignalBox = iSignalBox.IsValid();
bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir); bool isSignalBoxBullish = IsBullish(iSignalBox.ob.dir);
// //
// Check Consolidation Zone ... // Check Consolidation Zone ...
XBoxZone cZone; bool hasBullishCZone = true;
XBoxZone tmpBoxes[]; bool hasBearishCZone = true;
if (isSignalBoxBullish) if (forceConsolidationZone)
{ {
// //
ToBox( XBoxZone cZone;
cState.bullishConsolidationZones, XBoxZone tmpBoxes[];
tmpBoxes // if (isSignalBoxBullish)
);
}
else
{
//
ToBox(
cState.bearishConsolidationZones,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
XBoxZone selectedBox;
if (iSignalBox.fvg.IsValid())
{ {
selectedBox = iSignalBox.fvg; //
ToBox(
cState.bullishConsolidationZones,
tmpBoxes //
);
} }
else else
{ {
selectedBox = iSignalBox.ob; //
ToBox(
cState.bearishConsolidationZones,
tmpBoxes //
);
} }
has = HasChild(tmpBoxes);
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (has) if (has)
{ {
// //
cZone = tmpBoxes[idx]; XBoxZone selectedBox;
if (iSignalBox.fvg.IsValid())
{
selectedBox = iSignalBox.fvg;
}
else
{
selectedBox = iSignalBox.ob;
}
// //
// Check Consolidation Zone Place ... idx = GetYoungest(tmpBoxes);
has = has = IsValidIndex(idx);
// if (has)
(
//
IsBoxInsideOr(
cZone,
selectedBox //
)
//
&&
//
cZone.from >= selectedBox.from
//
)
//
||
//
(
//
IsBoxInsideOr(
selectedBox,
cZone //
)
//
&&
//
selectedBox.from >= cZone.from
//
)
//
;
if (!has)
{ {
cZone.Clean(); //
cZone = tmpBoxes[idx];
//
// Check Consolidation Zone Place ...
has =
//
(
//
IsBoxInsideOr(
cZone,
selectedBox //
)
//
&&
//
cZone.from >= selectedBox.from
//
)
//
||
//
(
//
IsBoxInsideOr(
selectedBox,
cZone //
)
//
&&
//
selectedBox.from >= cZone.from
//
)
//
;
if (!has)
{
cZone.Clean();
}
} }
//
selectedBox.Clean();
} }
Clean(tmpBoxes);
// //
selectedBox.Clean(); hasBullishCZone = cZone.IsValid() &&
} cZone.IsBullish();
Clean(tmpBoxes);
// //
bool hasBullishCZone = cZone.IsValid() && hasBearishCZone = cZone.IsValid() &&
cZone.IsBullish();
//
bool hasBearishZone = cZone.IsValid() &&
cZone.IsBearish(); cZone.IsBearish();
//
cZone.Clean();
}
// //
// Bullish Conditions ... // Bullish Conditions ...
isBullish = isBullish =
@@ -3025,7 +3054,7 @@ struct X121SMCStrategyConditionParser
( (
// //
hasSignalBox && hasSignalBox &&
hasBearishZone && hasBearishCZone &&
!isSignalBoxBullish && !isSignalBoxBullish &&
isSignalBoxRetested && isSignalBoxRetested &&
isBarValidForBearish isBarValidForBearish
@@ -3048,162 +3077,157 @@ struct X121SMCStrategyConditionParser
: X_DIRECTION_BEARISH; : X_DIRECTION_BEARISH;
// //
if (iSignalBox.fvg.IsValid()) box = selectedBox;
{
box = iSignalBox.fvg;
}
else
{
box = iSignalBox.ob;
}
//
box.to = TimeCurrent(); box.to = TimeCurrent();
// //
// Detect Holder Box ... // Detect Holder Box ...
XBoxZone tmpBoxes[]; if (forceHolderBox)
if (isBullish)
{ {
// //
// Order Blocks ... XBoxZone tmpBoxes[];
XBoxZone tmp[]; if (isBullish)
ToBox(
cState.bullishOrderBlocks,
tmp //
);
Copy(
tmp,
tmpBoxes //
);
Clean(tmp);
//
// Fair Value Gaps ...
ToBox(
cState.bullishFairValueGaps,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
//
// Support Zones ...
ToBox(
cState.supportZones,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
}
else
{
//
// Order Blocks ...
XBoxZone tmp[];
ToBox(
cState.bearishOrderBlocks,
tmp //
);
Copy(
tmp,
tmpBoxes //
);
Clean(tmp);
//
// Fair Value Gaps ...
ToBox(
cState.bearishFairValueGaps,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
//
// Resistance Zones ...
ToBox(
cState.resistanceZones,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
}
//
count = ArraySize(tmpBoxes);
has = IsValidSize(count);
if (has)
{
//
while (HasChild(tmpBoxes))
{ {
// //
idx = GetOldest(tmpBoxes); // Order Blocks ...
has = IsValidIndex(idx); XBoxZone tmp[];
if (!has) ToBox(
{ cState.bullishOrderBlocks,
break; tmp //
} );
Copy(
tmp,
tmpBoxes //
);
Clean(tmp);
// //
XBoxZone iBox = tmpBoxes[idx]; // Fair Value Gaps ...
ArrayRemove( ToBox(
cState.bullishFairValueGaps,
tmp //
);
Copy(
tmp,
tmpBoxes, tmpBoxes,
idx, false // Ignore Clean ...
1 //
); );
Clean(tmp);
// //
has = IsBoxInside( // Support Zones ...
iBox, ToBox(
box // cState.supportZones,
tmp //
); );
if (has) Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
}
else
{
//
// Order Blocks ...
XBoxZone tmp[];
ToBox(
cState.bearishOrderBlocks,
tmp //
);
Copy(
tmp,
tmpBoxes //
);
Clean(tmp);
//
// Fair Value Gaps ...
ToBox(
cState.bearishFairValueGaps,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
//
// Resistance Zones ...
ToBox(
cState.resistanceZones,
tmp //
);
Copy(
tmp,
tmpBoxes,
false // Ignore Clean ...
);
Clean(tmp);
}
//
count = ArraySize(tmpBoxes);
has = IsValidSize(count);
if (has)
{
//
while (HasChild(tmpBoxes))
{ {
// //
holderBox = iBox; idx = GetOldest(tmpBoxes);
holderBox.to = TimeCurrent(); has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
has = IsBoxInside(
iBox,
box //
);
if (has)
{
//
holderBox = iBox;
holderBox.to = TimeCurrent();
iBox.Clean();
break;
}
//
iBox.Clean(); iBox.Clean();
break;
} }
//
iBox.Clean();
} }
}
//
Clean(tmpBoxes);
//
result =
result &&
holderBox.IsValid() &&
holderBox.dir == dir;
if (!result)
{
// //
box.Clean(); Clean(tmpBoxes);
isBullish = false;
isBearish = false; //
holderBox.Clean(); result =
result &&
holderBox.IsValid() &&
holderBox.dir == dir;
if (!result)
{
//
box.Clean();
isBullish = false;
isBearish = false;
holderBox.Clean();
}
} }
} }
@@ -3220,9 +3244,9 @@ struct X121SMCStrategyConditionParser
zBar.Clean(); zBar.Clean();
cBar.Clean(); cBar.Clean();
pBar.Clean(); pBar.Clean();
cZone.Clean();
cState.Clean(); cState.Clean();
iSignalBox.Clean(); iSignalBox.Clean();
selectedBox.Clean();
ZeroMemory(cHelper); ZeroMemory(cHelper);
cConditions.Clean(); cConditions.Clean();
cStateEvents.Clean(); cStateEvents.Clean();
@@ -228,8 +228,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
// Detectiong Signal Boxes ... // Detectiong Signal Boxes ...
hasWaitingBoxes = workingZone hasWaitingBoxes = workingZone
.DetectWaitingBoxes( .DetectWaitingBoxes(
X_CYCLE_CONSOLIDATION,
X_CYCLE_ANALYSE, X_CYCLE_ANALYSE,
X_CYCLE_DECISION,
provider, provider,
zIndex // zIndex //
); );
+100 -4
View File
@@ -663,10 +663,106 @@ struct X121SMCStrategyXWZWorkingZone
iSignalBox.fvg = iFVGBox; iSignalBox.fvg = iFVGBox;
// //
AddRef( // Here We Check Waiting Box Contains Other Zones ...
iSignalBox, // Like Support/Resistances ...
waitingBoxes // bool forceVerification = false;
); if (forceVerification)
{
//
XBoxZone iVerificationBox;
XBoxZone tmpBoxes[];
if (isBullish)
{
//
ToBox(
provider.decisionState.supportZones,
tmpBoxes //
);
}
else
{
//
ToBox(
provider.decisionState.resistanceZones,
tmpBoxes //
);
}
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
// Select Box ...
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Box ...
bool isValidPassed = !IsBoxValid(
iBox,
barIndex //
);
bool isDirPassed = iBox.dir == iOBBox.dir;
bool isPlacePassed =
IsBoxInside(
iBox,
iOBBox //
)
//
&&
//
(!iFVGBox.IsValid()
? true
: IsBoxInsideOr(
iBox,
iFVGBox //
));
//
has =
isDirPassed &&
isValidPassed &&
isPlacePassed;
if (has)
{
//
iVerificationBox = iBox;
iBox.Clean();
break;
}
//
iBox.Clean();
}
}
has = iVerificationBox.IsValid();
Clean(tmpBoxes);
iVerificationBox.Clean();
}
//
if (has)
{
//
AddRef(
iSignalBox,
waitingBoxes //
);
}
// //
iSignalBox.Clean(); iSignalBox.Clean();