This commit is contained in:
2025-02-16 14:49:39 +03:30
parent 11fca38b6a
commit 62aead0094
8 changed files with 2390 additions and 1608 deletions
+411 -173
View File
@@ -678,6 +678,7 @@ struct X121SMCXWZZone
isBullish
? supResBoxes[j].lower
: supResBoxes[j].upper;
//
// Check Swing Low ...
bool isSwingLow =
@@ -1167,6 +1168,13 @@ struct X121SMCXWZWorkingZone
datetime to;
datetime from;
//
XOHCL swingBar;
XOHCL breakerBar;
XOHCL momentumBar;
XOHCL rejectionBar;
XBoxZone appliedBox;
//
X121SMCXWZWorkingZone()
{
@@ -1190,10 +1198,24 @@ struct X121SMCXWZWorkingZone
symbol = NULL;
period = NULL;
//
CleanConditionBars();
//
ZeroMemory(this);
}
//
void CleanConditionBars()
{
//
swingBar.Clean();
breakerBar.Clean();
appliedBox.Clean();
momentumBar.Clean();
rejectionBar.Clean();
}
//
bool IsValid()
{
@@ -2004,7 +2026,7 @@ struct X121SMCStrategyXWZSignalConditions
//
hasTrend =
//
IsValid(supplyTouch) &&
IsValid(supplyTouch) ||
IsValid(demandTouch)
//
;
@@ -2037,6 +2059,10 @@ struct X121SMCStrategyXWZSignalConditions
//
// Find Order Block and FVG for Trend Approve ...
//
bool isBullishTrendApproved = false;
bool isBearishTrendApproved = false;
//
// Now We Have to Detect at least One OrderBlock with FVG ...
// for Trend Approvement ...
@@ -2054,192 +2080,205 @@ struct X121SMCStrategyXWZSignalConditions
XCOrderBlock *ob = NULL;
//
if (hasBullishTrend)
has = mtfState.HasBullishOrderBlocks();
count = mtfState.CountBullishOrderBlocks();
//
if (has)
{
//
has = mtfState.HasBullishOrderBlocks();
count = mtfState.CountBullishOrderBlocks();
//
if (has)
// Check Order Block ...
for (int i = 0; i < count; i++)
{
//
// Check Order Block ...
for (int i = 0; i < count; i++)
XCOrderBlock *iOB = mtfState.bullishOrderBlocks[i];
//
iOB.To(cTime);
//
// Check From Passes ...
bool isFromPassed = iOB.From() > demandZone.From();
if (!isFromPassed)
{
continue;
}
//
// Must inside DemandZone ...
bool isInsideDemand = IsInsideDiff(
iOB,
demandZone //
);
if (!isInsideDemand)
{
continue;
}
//
// Check Started ...
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
bool isStarted = iOB.IsStarted(
X_DIRECTION_BULLISH,
startedBar,
startedDir //
);
if (!isStarted)
{
//
XCOrderBlock *iOB = mtfState.bullishOrderBlocks[i];
//
iOB.To(cTime);
//
// Check From Passes ...
bool isFromPassed = iOB.From() > demandZone.From();
if (!isFromPassed)
{
continue;
}
//
// Must inside DemandZone ...
bool isInsideDemand = IsInsideDiff(
iOB,
demandZone //
);
if (!isInsideDemand)
{
continue;
}
//
// Check Started ...
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
bool isStarted = iOB.IsStarted(
X_DIRECTION_BULLISH,
startedBar,
startedDir //
);
if (!isStarted)
{
//
startedBar.Clean();
continue;
}
//
// Converts to Box ...
XBoxZone obBox;
bool hasOBBox = ToBox(
obBox,
iOB //
);
if (!hasOBBox)
{
//
obBox.Clean();
startedBar.Clean();
continue;
}
//
// Check Zone Must not Used before ...
bool isUsed = IsBoxUsed(
obBox,
startedBar.Index() - 1,
zIndex //
);
if (isUsed)
{
//
obBox.Clean();
startedBar.Clean();
continue;
}
//
ob = iOB;
startedBar.Clean();
continue;
}
//
// Converts to Box ...
XBoxZone obBox;
bool hasOBBox = ToBox(
obBox,
iOB //
);
if (!hasOBBox)
{
//
obBox.Clean();
startedBar.Clean();
//
break;
continue;
}
//
// Detect Fair Value Gap ...
if (ob != NULL &&
ob.IsValid())
// Check Zone Must not Used before ...
bool isUsed = IsBoxUsed(
obBox,
startedBar.Index() - 1,
zIndex //
);
if (isUsed)
{
//
has = stfState.HasBullishFairValueGaps();
count = stfState.CountBullishFairValueGaps();
if (has)
obBox.Clean();
startedBar.Clean();
continue;
}
//
ob = iOB;
//
obBox.Clean();
startedBar.Clean();
//
break;
}
//
// Detect Fair Value Gap ...
if (ob != NULL &&
ob.IsValid())
{
//
has = stfState.HasBullishFairValueGaps();
count = stfState.CountBullishFairValueGaps();
if (has)
{
//
// Check Fir Value Gap ...
for (int i = 0; i < count; i++)
{
//
// Check Fir Value Gap ...
for (int i = 0; i < count; i++)
XCFVG *iFVG = stfState.bullishFairValueGaps[i];
//
iFVG.To(cTime);
//
// Check From Passes ...
bool isFromPassed = iFVG.From() > ob.From();
if (!isFromPassed)
{
continue;
}
//
// Check Started ...
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
bool isStarted = iFVG.IsStarted(
X_DIRECTION_BULLISH,
startedBar,
startedDir //
);
if (!isStarted)
{
//
XCFVG *iFVG = stfState.bullishFairValueGaps[i];
//
iFVG.To(cTime);
//
// Check From Passes ...
bool isFromPassed = iFVG.From() > ob.From();
if (!isFromPassed)
{
continue;
}
//
// Check Started ...
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
bool isStarted = iFVG.IsStarted(
X_DIRECTION_BULLISH,
startedBar,
startedDir //
);
if (!isStarted)
{
//
startedBar.Clean();
continue;
}
//
// Converts to Box ...
XBoxZone fvgBox;
bool hasFVGBox = ToBox(
fvgBox,
iFVG //
);
if (!hasFVGBox)
{
//
fvgBox.Clean();
startedBar.Clean();
continue;
}
//
// Check Inside Order Block ...
bool isInside = IsInsideDiff(
iFVG,
ob,
true // Force Side Out ...
);
if (!isInside)
{
continue;
}
//
fvg = iFVG;
startedBar.Clean();
continue;
}
//
// Converts to Box ...
XBoxZone fvgBox;
bool hasFVGBox = ToBox(
fvgBox,
iFVG //
);
if (!hasFVGBox)
{
//
fvgBox.Clean();
startedBar.Clean();
//
break;
continue;
}
}
else
{
//
ob = NULL;
// Check Inside Order Block ...
bool isInside = IsInsideDiff(
iFVG,
ob,
true // Force Side Out ...
);
if (!isInside)
{
continue;
}
//
fvg = iFVG;
//
fvgBox.Clean();
startedBar.Clean();
//
break;
}
}
else
{
//
ob = NULL;
}
}
//
if (ob != NULL &&
fvg != NULL)
{
//
orderBlock = ob;
fairValueGap = fvg;
}
//
hasOrderBlock = HasOrderBlock();
hasFairValueGap = HasFairValueGap();
isBullishTrendApproved = hasOrderBlock &&
hasFairValueGap;
}
else if (hasBearishTrend)
//
if (!isBullishTrendApproved)
{
//
has = mtfState.HasBearishOrderBlocks();
@@ -2422,28 +2461,32 @@ struct X121SMCStrategyXWZSignalConditions
ob = NULL;
}
}
//
if (ob != NULL &&
fvg != NULL)
{
//
orderBlock = ob;
fairValueGap = fvg;
}
//
hasOrderBlock = HasOrderBlock();
hasFairValueGap = HasFairValueGap();
isBearishTrendApproved = hasOrderBlock &&
hasFairValueGap;
}
}
//
if (ob != NULL &&
fvg != NULL)
{
//
orderBlock = ob;
fairValueGap = fvg;
}
//
hasOrderBlock = HasOrderBlock();
hasFairValueGap = HasFairValueGap();
}
//
// Check Trend Approved ...
bool isTrendApproved =
hasOrderBlock &&
hasFairValueGap;
hasFairValueGap &&
(isBullishTrendApproved ||
isBearishTrendApproved);
result = isTrendApproved;
if (!result)
{
@@ -2634,7 +2677,7 @@ struct X121SMCStrategyXWZSignalConditions
//
result =
//
IsValid(supplyTouch) &&
IsValid(supplyTouch) ||
IsValid(demandTouch)
//
;
@@ -2819,10 +2862,54 @@ struct X121SMCStrategyXWZSignalConditions
//
bool hasOBFVG = startZone.HasOB() &&
startZone.HasFVG();
bool isOBStarted = false;
bool isFVGStarted = false;
bool isOBActivated = false;
bool isFVGActivated = false;
bool isOBInsideFVG = false;
bool isFVGInsideOB = false;
if (hasOBFVG)
{
//
//
ENUM_X_DIRECTION forDir = startZone.ob.GetDirection();
//
XOHCL startedBar;
ENUM_X_DIRECTION startedDir;
//
isOBStarted = startZone.ob.IsStarted(
forDir,
startedBar,
startedDir //
);
//
isOBActivated = startZone.ob.IsActivated(
forDir,
startedBar,
startedDir //
);
//
forDir = startZone.fvg.GetDirection();
//
isFVGStarted = startZone.fvg.IsStarted(
forDir,
startedBar,
startedDir //
);
//
isFVGActivated = startZone.fvg.IsActivated(
forDir,
startedBar,
startedDir //
);
//
isOBInsideFVG =
IsInsideDiff(
@@ -2857,10 +2944,17 @@ struct X121SMCStrategyXWZSignalConditions
startZone.ob,
true // IgnoreInside
));
//
startedBar.Clean();
}
//
result =
isOBStarted &&
isFVGStarted &&
isOBActivated &&
isFVGActivated &&
startZone.IsValid() &&
(isOBInsideFVG ||
isFVGInsideOB) &&
@@ -3008,6 +3102,150 @@ struct X121SMCStrategyXWZSignalConditions
cBar.Clean();
}
//
bool HasWorkingZoneConditions(
ENUM_X_DIRECTION &conditionsDir,
XPOIState &state,
int barIndex = 0,
ENUM_TIMEFRAMES forPeriod = NULL //
)
{
//
bool result = false;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
conditionsDir = X_DIRECTION_NONE;
//
result = HasWorkingZone();
if (!result)
{
return result;
}
//
XBoxZone appliedBox;
//
// Clean Condition Bars ...
workingZone.CleanConditionBars();
//
// Validate ...
result = state.IsValid() &&
state.HasChild();
if (!result)
{
//
workingZone.CleanConditionBars();
return result;
}
//
if (!IsValid(forPeriod))
{
forPeriod = period;
}
//
datetime cTime = iTime(
symbol,
forPeriod,
barIndex //
);
//
// Check Supply Zone ...
//
XBoxZone supplyBox;
bool hasSupplyBox =
supplyZone != NULL &&
supplyZone.IsValid() &&
ToBox(
supplyBox,
supplyZone //
);
if (hasSupplyBox)
{
//
result = CheckBoxForTradeConditions(
supplyBox,
appliedBox,
workingZone.swingBar,
workingZone.breakerBar,
workingZone.rejectionBar,
workingZone.momentumBar,
state,
barIndex,
forPeriod //
);
//
if (result)
{
conditionsDir = X_DIRECTION_BEARISH;
}
}
//
// Check Demand Zone ...
XBoxZone demandBox;
bool hasDemandBox = false;
if (!result)
{
//
hasDemandBox =
demandZone != NULL &&
demandZone.IsValid() &&
ToBox(
demandBox,
demandZone //
);
if (hasDemandBox)
{
//
result = CheckBoxForTradeConditions(
demandBox,
appliedBox,
workingZone.swingBar,
workingZone.breakerBar,
workingZone.rejectionBar,
workingZone.momentumBar,
state,
barIndex,
forPeriod //
);
//
if (result)
{
conditionsDir = X_DIRECTION_BULLISH;
}
}
}
//
if (!result)
{
workingZone.CleanConditionBars();
}
//
supplyBox.Clean();
demandBox.Clean();
appliedBox.Clean();
//
return result;
}
//
double GetEntry()
{