add support for Cycle Provider ...

This commit is contained in:
2025-03-06 23:35:44 +03:30
parent 7e976bc157
commit 6157bbe125
6 changed files with 1488 additions and 1785 deletions
+61 -265
View File
@@ -139,10 +139,7 @@ struct X121SMCStrategyXWZWorkingZone
string _symbol,
ENUM_TIMEFRAMES _period,
int barIndex,
XPOIState &htfState,
XPOIState &mtfState,
XPOIState &stfState, //
XPOIState &ttfState //
X121SMCStrategySignalProviderData &provider //
)
{
//
@@ -160,15 +157,7 @@ struct X121SMCStrategyXWZWorkingZone
IsValid(_symbol) &&
IsValid(_period) &&
//
htfState.IsValid() &&
mtfState.IsValid() &&
stfState.IsValid() &&
ttfState.IsValid() &&
//
htfState.HasChild() &&
mtfState.HasChild() &&
stfState.HasChild() &&
ttfState.HasChild()
provider.IsValid()
//
;
if (!result)
@@ -208,12 +197,17 @@ struct X121SMCStrategyXWZWorkingZone
if (!has)
{
//
idx = GetHighest(mtfState.supplyZones);
idx = GetHighest(provider
.consolidationState
.supplyZones //
);
has = IsValidIndex(idx);
if (has)
{
//
supplyZone = mtfState.supplyZones[idx];
supplyZone = provider
.consolidationState
.supplyZones[idx];
has = hh5 < supplyZone.Lower();
if (!has)
{
@@ -228,12 +222,17 @@ struct X121SMCStrategyXWZWorkingZone
if (!has)
{
//
idx = GetLowest(mtfState.demandZones);
idx = GetLowest(provider
.consolidationState
.demandZones //
);
has = IsValidIndex(idx);
if (has)
{
//
demandZone = mtfState.demandZones[idx];
demandZone = provider
.consolidationState
.demandZones[idx];
has = ll5 > demandZone.Upper();
if (!has)
{
@@ -275,12 +274,7 @@ struct X121SMCStrategyXWZWorkingZone
//
bool DetectZone(
XCPOIDrawer *drawer,
ENUM_XPOI_EVENTS &obPOIEvents[],
ENUM_XPOI_EVENTS &fvgPOIEvents[],
ENUM_XPOI_EVENTS &supDemPOIEvents[],
XPOIState &obState,
XPOIState &fvgState,
XPOIState &supDemState //
X121SMCStrategySignalProviderData &provider //
)
{
//
@@ -288,13 +282,7 @@ struct X121SMCStrategyXWZWorkingZone
//
result = IsValid() &&
obState.IsValid() &&
fvgState.IsValid() &&
supDemState.IsValid() &&
obState.HasOrderBlocks() &&
fvgState.HasFairValueGaps() &&
supDemState.HasSupplyZones() &&
supDemState.HasDemandZones();
provider.IsValid();
if (!result)
{
return result;
@@ -323,17 +311,22 @@ struct X121SMCStrategyXWZWorkingZone
bool hasNewSupply =
Contains(
X_SUPPLY_ZONE_DETECTED,
supDemPOIEvents //
provider.consolidationPoiEvents //
);
if (hasNewSupply)
{
//
idx = GetYoungest(supDemState.supplyZones);
idx = GetYoungest(provider
.consolidationState
.supplyZones //
);
has = IsValidIndex(idx);
if (has)
{
//
supply = supDemState.supplyZones[idx];
supply = provider
.consolidationState
.supplyZones[idx];
has = ToBox(
supplyBox,
supply //
@@ -353,17 +346,23 @@ struct X121SMCStrategyXWZWorkingZone
bool hasNewDemand =
Contains(
X_DEMAND_ZONE_DETECTED,
supDemPOIEvents //
provider
.consolidationPoiEvents //
);
if (hasNewDemand)
{
//
idx = GetYoungest(supDemState.demandZones);
idx = GetYoungest(provider
.consolidationState
.demandZones //
);
has = IsValidIndex(idx);
if (has)
{
//
demand = supDemState.demandZones[idx];
demand = provider
.consolidationState
.demandZones[idx];
has = ToBox(
demandBox,
demand //
@@ -383,21 +382,28 @@ struct X121SMCStrategyXWZWorkingZone
bool hasNewFairValueGap =
Contains(
X_BULLISH_FVG_DETECTED,
fvgPOIEvents //
provider
.analysePoiEvents //
) ||
Contains(
X_BEARISH_FVG_DETECTED,
fvgPOIEvents //
provider
.analysePoiEvents //
);
if (hasNewFairValueGap)
{
//
idx = GetYoungest(fvgState.fairValueGaps);
idx = GetYoungest(provider
.analyseState
.fairValueGaps //
);
has = IsValidIndex(idx);
if (has)
{
//
fvg = fvgState.fairValueGaps[idx];
fvg = provider
.analyseState
.fairValueGaps[idx];
has = ToBox(
fvgBox,
fvg //
@@ -417,21 +423,28 @@ struct X121SMCStrategyXWZWorkingZone
bool hasNewOrderBlock =
Contains(
X_BULLISH_ORDERBLOCK_DETECTED,
obPOIEvents //
provider
.consolidationPoiEvents //
) ||
Contains(
X_BEARISH_ORDERBLOCK_DETECTED,
obPOIEvents //
provider
.consolidationPoiEvents //
);
if (hasNewOrderBlock)
{
//
idx = GetYoungest(obState.orderBlocks);
idx = GetYoungest(provider
.consolidationState
.orderBlocks //
);
has = IsValidIndex(idx);
if (has)
{
//
ob = obState.orderBlocks[idx];
ob = provider
.consolidationState
.orderBlocks[idx];
has = ToBox(
obBox,
ob //
@@ -683,226 +696,9 @@ struct X121SMCStrategyXWZWorkingZone
}
//
bool IsZoneRejected(
bool IsZoneActivated(
XOBFVG &zone,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Cleanup Result ...
zone.Clean();
//
// Normalize Bar Index ...
if (barIndex < 0)
{
barIndex = 0;
}
//
// Validate ...
result = IsValid() &&
HasWaitingZones();
if (!result)
{
return result;
}
//
// Detecting Rejected Waiting Zone ...
int count = CountWaitingZones();
for (int i = 0; i < count; i++)
{
//
// Detecting XBoxZone Area of Waiting Zone ...
XBoxZone iBox;
bool hasBox = waitingZones[i]
.ToZone(iBox);
if (hasBox)
{
//
// Check Zone Rejection ...
int fromIDX = iBarShift(
iBox.symbol,
period,
iBox.from //
);
bool has = IsValidIndex(fromIDX);
if (has)
{
//
// Looking for Rejection ...
bool isBullish = iBox.IsBullish();
for (int j = barIndex; j < fromIDX; j++)
{
//
XOHCL iBar;
has = iBar.Init(
iBox.symbol,
period,
j //
);
if (has)
{
//
// Checking Box Rejected ...
//
bool isLowerReject =
//
isBullish &&
(iBar.low < iBox.upper &&
iBar.GetDown() > iBox.upper)
//
;
//
bool isUpperReject =
//
!isBullish &&
(iBar.high > iBox.lower &&
iBar.GetUp() < iBox.lower)
//
;
//
bool isRejected =
isLowerReject ||
isUpperReject;
result = isRejected;
if (result)
{
//
iBar.Clean();
break;
}
}
//
iBar.Clean();
}
}
}
//
// Validate Result ...
if (result)
{
//
iBox.Clean();
zone = waitingZones[i];
break;
}
//
iBox.Clean();
}
//
return result;
}
//
// TODO: Remove this ...
bool IsZoneOBRejected(
XOBFVG &zone,
X121Conditions &conditions,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Cleanup Result ...
zone.Clean();
//
// Normalize Bar Index ...
if (barIndex < 0)
{
barIndex = 0;
}
//
if (barIndex == 0)
{
barIndex = 1;
}
//
XOHCL bar;
bool isInited = bar.Init(
symbol,
period,
barIndex //
);
//
// Validate ...
result = isInited &&
IsValid() &&
HasWaitingZones();
if (!result)
{
return result;
}
//
double points = GetPoints(bar.symbol);
//
// Detecting Rejected Waiting Zone ...
int count = CountWaitingZones();
for (int i = 0; i < count; i++)
{
//
// Detecting XBoxZone Area of Waiting Zone ...
XBoxZone iBox;
bool hasBox = waitingZones[i]
.ToZone(iBox);
if (hasBox)
{
//
double peak = conditions.peaksBuffer[1];
double lower = waitingZones[i].ob.Lower();
//
double delta = MathAbs(lower - peak);
//
result = delta == 0 ||
delta < points * 2;
}
//
// Validate Result ...
if (result)
{
//
iBox.Clean();
zone = waitingZones[i];
break;
}
//
iBox.Clean();
}
//
bar.Clean();
//
return result;
}
//
bool IsZoneValidForSignal(
XOBFVG &zone,
X121Conditions &conditions,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
@@ -953,8 +749,8 @@ struct X121SMCStrategyXWZWorkingZone
}
//
double peak = conditions.peaksBuffer[1];
double vale = conditions.valesBuffer[1];
double peak = provider.decisionXConditions.peaksBuffer[1];
double vale = provider.decisionXConditions.valesBuffer[1];
//
int count = CountWaitingZones();