This commit is contained in:
2025-03-23 03:46:13 +03:30
parent a84b0befe2
commit c49abe21db
10 changed files with 4204 additions and 2932 deletions
+241 -385
View File
@@ -31,7 +31,6 @@
enum ENUM_X121SMC_XWZ_PROVIDERS
{
X121SMC_XWZ_PROVIDER_NONE,
X121SMC_XWZ_PROVIDER_XHKMA,
X121SMC_XWZ_PROVIDER_XBREAKED_BOX,
X121SMC_XWZ_PROVIDER_XREJECTED_BOX,
X121SMC_XWZ_PROVIDER_XACTIVATED_BOX,
@@ -488,6 +487,7 @@ struct X121SMCStrategyXWZWorkingZone
int idx = -1;
int count = 0;
bool has = false;
datetime cTime = TimeCurrent();
//
if (barIndex < 0)
@@ -559,235 +559,19 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Select Order Blocks ...
if (obStateEvents.hasNewOrderBlock)
{
//
idx = GetYoungest(obState.orderBlocks);
has = IsValidIndex(idx);
if (has)
{
//
XCFVG *iFVG = NULL;
XCOrderBlock *iOB = obState.orderBlocks[idx];
bool isBullish = iOB.IsBullish();
//
// Detecting Inside FVG ...
has = fvgState.HasFairValueGaps();
if (has)
{
//
XCFVG *tmpFVGs[];
count = fvgState.CountFairValueGaps();
for (int i = 0; i < count; i++)
{
//
XCFVG *jFVG = fvgState.fairValueGaps[i];
//
bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection();
bool isFromPassed = jFVG.From() >= iOB.From();
bool isPlacePassed = IsInsideOrDiff(
jFVG,
iOB,
false //
);
//
has = isDirPassed &&
isFromPassed &&
isPlacePassed;
if (has)
{
//
Add(
jFVG,
tmpFVGs //
);
}
//
ZeroMemory(jFVG);
}
//
// Selecting iFVG Based on Direction of OB ...
has = HasChild(tmpFVGs);
if (has)
{
//
idx =
isBullish
? GetLowest(tmpFVGs)
: GetHighest(tmpFVGs);
has = IsValidIndex(idx);
if (has)
{
iFVG = tmpFVGs[idx];
}
}
//
Clean(tmpFVGs);
}
//
XBoxZone iOBBox;
XBoxZone iFVGBox;
if (iFVG != NULL)
{
//
has = ToBox(
iFVGBox,
iFVG //
);
}
//
has = ToBox(
iOBBox,
iOB //
);
//
has = iOBBox.IsValid() &&
iFVGBox.IsValid();
if (has)
{
//
XSignalBox iSignalBox;
//
iSignalBox.ob = iOBBox;
iSignalBox.fvg = iFVGBox;
//
// Here We Check Waiting Box Contains Other Zones ...
// Like Support/Resistances ...
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();
}
//
iOBBox.Clean();
iFVGBox.Clean();
ZeroMemory(iOB);
ZeroMemory(iFVG);
}
}
//
// Checking Other Senario for Waiting Boxes ...
// Detect a Sharp Zone Which Contains
// an Order Block and Also an FVG ...
if (obStateEvents.hasNewSharp)
{
//
XBoxZone ob;
XBoxZone fvg;
XBoxZone currSharp;
XBoxZone prevSharp;
XBoxZone sharpConsolidation;
//
// Retrieve Current Sharp ...
XCPOIDrawer *drawer = provider.visionCycleHelper.mPOIDrawer;
XBoxZone tmpBoxes[];
Copy(
obState.sharps,
@@ -906,37 +690,225 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Detect Order Block / FVG ...
has = sharpConsolidation.IsValid();
if (has)
{
//
// Check Direction ...
bool isBullish = sharpConsolidation.IsBullish();
//
// Find Inside Order Block ...
Clean(tmpBoxes);
if (isBullish)
{
//
ToBox(
obState.bullishOrderBlocks,
tmpBoxes //
);
}
else
{
//
ToBox(
obState.bearishOrderBlocks,
tmpBoxes //
);
}
//
// Select Order Block ...
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 Selected Box ...
bool isDirPassed = iBox.dir == sharpConsolidation.dir;
bool isFromPassed = iBox.from > sharpConsolidation.from;
bool isInsidePassed = IsBoxInside(
iBox,
sharpConsolidation //
);
bool isValidationPassed = IsBoxValid(
iBox,
barIndex //
);
//
has = isDirPassed &&
isFromPassed &&
isInsidePassed &&
isValidationPassed;
if (has)
{
ob = iBox;
}
//
iBox.Clean();
//
if (ob.IsValid())
{
break;
}
}
}
Clean(tmpBoxes);
//
// Find Inside FVG ...
has = ob.IsValid();
if (has)
{
//
Clean(tmpBoxes);
if (isBullish)
{
//
ToBox(
fvgState.bullishFairValueGaps,
tmpBoxes //
);
}
else
{
//
ToBox(
fvgState.bearishFairValueGaps,
tmpBoxes //
);
}
//
// Select FVG ...
has = HasChild(tmpBoxes);
if (has)
{
//
while (HasChild(tmpBoxes))
{
//
idx = isBullish
? GetLowest(tmpBoxes)
: GetHighest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Validate Selected Box ...
bool isDirPassed = iBox.dir == ob.dir;
bool isFromPassed = iBox.from > ob.from;
bool isInsidePassed = IsBoxInside(
iBox,
ob //
);
//
has = isDirPassed &&
isFromPassed &&
isInsidePassed;
if (has)
{
fvg = iBox;
}
//
iBox.Clean();
//
if (fvg.IsValid())
{
break;
}
}
}
Clean(tmpBoxes);
}
}
//
// Checking Validation of Boxes ...
has = ob.IsValid() &&
fvg.IsValid() &&
sharpConsolidation.IsValid();
if (has)
{
//
// Update Time ...
ob.to = cTime;
fvg.to = cTime;
sharpConsolidation.to = cTime;
//
XSignalBox iSBox;
//
iSBox.ob = ob;
iSBox.fvg = fvg;
iSBox.sharp = sharpConsolidation;
//
has = iSBox.IsValid();
if (has)
{
//
AddRef(
iSBox,
waitingBoxes //
);
}
//
iSBox.Clean();
}
//
ob.Clean();
fvg.Clean();
toBar.Clean();
currSharp.Clean();
prevSharp.Clean();
sharpConsolidation.Clean();
}
//
if (has)
{
//
XCBoxObject *iCurrObj;
XCBoxObject *iPrevObj;
XCBoxObject *iSharpConsolidationObj;
has = drawer.DrawBox(
currSharp,
iCurrObj //
);
has =
has &&
drawer.DrawBox(
prevSharp,
iPrevObj //
);
has =
has &&
drawer.DrawBox(
sharpConsolidation,
iSharpConsolidationObj //
);
if (has)
{
Print("Sharp Detection ...");
}
}
Clean(tmpBoxes);
currSharp.Clean();
prevSharp.Clean();
sharpConsolidation.Clean();
}
//
@@ -1017,15 +989,6 @@ struct X121SMCStrategyXWZWorkingZone
//
has = isInite &&
(
//
IsBoxBreaked(
iBox.fvg,
iBar.Index() - 1,
barIndex,
period //
)
//
||
//
IsBoxBreaked(
iBox.ob,
@@ -1335,14 +1298,7 @@ struct X121SMCStrategyXWZWorkingZone
count = CountWaitingBoxes();
for (int i = 0; i < count; i++)
{
//
waitingBoxes[i].ob.to = value;
//
if (waitingBoxes[i].fvg.IsValid())
{
waitingBoxes[i].fvg.to = value;
}
waitingBoxes[i].UpdateTo(value);
}
}
@@ -1443,7 +1399,6 @@ struct X121SMCStrategyXWZWorkingZone
* Detect Signal Box Conditions ...
*
* @param box: XBoxZone instance reference, Signalled Box ...
* @param holderBox: XBoxZone instance reference, Signalled Holder Box ...
* @param dir: ENUM_X_DIRECTION member, Specified Signal Direction ...
* @param signalProvider: ENUM_X121SMC_XWZ_PROVIDERS member, Specified Signal Type ...
* @param provider: X121SMCStrategySignalProviderData instance reference ...
@@ -1452,8 +1407,7 @@ struct X121SMCStrategyXWZWorkingZone
* @return ( bool )
*/
bool DetectSignalConditions(
XBoxZone &box,
XBoxZone &holderBox,
XSignalBox &box,
ENUM_X_DIRECTION &dir,
ENUM_X121SMC_XWZ_PROVIDERS &signalProvider,
X121SMCStrategySignalProviderData &provider,
@@ -1468,7 +1422,6 @@ struct X121SMCStrategyXWZWorkingZone
//
box.Clean();
holderBox.Clean();
dir = X_DIRECTION_NONE;
signalProvider = X121SMC_XWZ_PROVIDER_NONE;
@@ -1507,14 +1460,14 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------
// Rejected Box ...
// ---------------------------------------------
bool useSenario1 = true;
bool useSenario1 = false;
bool isSenario1Happend = false;
bool isSenario1Bullish = false;
bool isSenario1Bearish = false;
if (useSenario1)
{
//
isSenario1Happend = cParser.HasSenario1Conditions(
isSenario1Happend = cParser.HasRejectedBoxConditions(
X_CYCLE_DECISION,
box,
holderBox,
@@ -1553,32 +1506,6 @@ struct X121SMCStrategyXWZWorkingZone
if (!isSenario1Happend &&
useSenario2)
{
//
isSenario2Happend = cParser.HasSenario2Conditions(
X_CYCLE_DECISION,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario2Bullish =
isSenario2Happend &&
IsBullish(dir);
//
isSenario2Bearish =
isSenario2Happend &&
IsBearish(dir);
//
if (isSenario2Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XACTIVATED_BOX;
}
}
//
@@ -1594,32 +1521,6 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario2Happend &&
useSenario3)
{
//
isSenario3Happend = cParser.HasSenario3Conditions(
X_CYCLE_DECISION,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario3Bullish =
isSenario3Happend &&
IsBullish(dir);
//
isSenario3Bearish =
isSenario3Happend &&
IsBearish(dir);
//
if (isSenario3Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XBREAKED_BOX;
}
}
//
@@ -1636,40 +1537,14 @@ struct X121SMCStrategyXWZWorkingZone
!isSenario3Happend &&
useSenario4)
{
//
isSenario4Happend = cParser.HasSenario4Conditions(
X_CYCLE_DECISION,
trend,
box,
holderBox,
dir,
waitingBoxes,
provider,
barIndex //
);
//
isSenario4Bullish =
isSenario4Happend &&
IsBullish(dir);
//
isSenario4Bearish =
isSenario4Happend &&
IsBearish(dir);
//
if (isSenario4Happend)
{
signalProvider = X121SMC_XWZ_PROVIDER_XHKMA;
}
}
//
// Senario 5:
// ---------------------------------------------
// XSHCNZ Signal Box Detection Conditions ...
// ---------------------------------------------
bool useSenario5 = false;
bool useSenario5 = true;
bool isSenario5Happend = false;
bool isSenario5Bullish = false;
bool isSenario5Bearish = false;
@@ -1708,7 +1583,8 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bullish ||
isSenario3Bullish ||
isSenario4Bullish ||
isSenario5Bullish
isSenario5Bullish ||
isSenario6Bullish
//
;
@@ -1719,7 +1595,8 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bearish ||
isSenario3Bearish ||
isSenario4Bearish ||
isSenario5Bearish
isSenario5Bearish ||
isSenario6Bearish
//
;
@@ -1876,13 +1753,13 @@ struct X121SMCStrategyXWZWorkingZone
*
* @param drawSupplyZone: boolean ...
* @param drawDemandZone: boolean ...
* @param drawWaitingZones: boolean ...
* @param drawWaitingBoxes: boolean ...
*/
void Draw(
XCPOIDrawer *drawer,
bool drawSupplyZone = false,
bool drawDemandZone = false,
bool drawWaitingZones = false,
bool drawWaitingBoxes = false,
bool drawTrend = false //
)
{
@@ -2108,7 +1985,7 @@ struct X121SMCStrategyXWZWorkingZone
//
// Waiting Zones ...
if (drawWaitingZones)
if (drawWaitingBoxes)
{
//
has = HasWaitingBoxes();
@@ -2119,42 +1996,21 @@ struct X121SMCStrategyXWZWorkingZone
for (int i = 0; i < count; i++)
{
//
// OB ...
XCBoxObject *iOBBoxObj;
has = drawer.DrawBox(
waitingBoxes[i].ob,
iOBBoxObj //
XCBaseObject *objects[];
has = drawer.DrawSignalBox(
waitingBoxes[i],
objects //
);
if (has)
{
mDrawnObjects.Add(iOBBoxObj);
}
//
// FVG ...
if (waitingBoxes[i].fvg.IsValid())
{
//
XCBoxObject *iFVGBoxObj;
has = drawer.DrawBox(
waitingBoxes[i].fvg,
iFVGBoxObj //
);
if (has)
count = ArraySize(objects);
for (int i = 0; i < count; i++)
{
//
iFVGBoxObj.BoxStyle(STYLE_SOLID);
//
mDrawnObjects.Add(iFVGBoxObj);
mWorkingZoneObjects.Add(objects[i]);
}
//
ZeroMemory(iFVGBoxObj);
}
//
ZeroMemory(iOBBoxObj);
Clean(objects);
}
}
}