This commit is contained in:
2025-03-21 06:51:15 +03:30
parent 419d697eb8
commit 0459bf2ac4
6 changed files with 2250 additions and 1393 deletions
+354 -157
View File
@@ -73,6 +73,11 @@ struct X121SMCStrategyXWZWorkingZone
XCSupplyZone *supplyZone;
XCDemandZone *demandZone;
//
XBoxZone support;
XBoxZone resistance;
ENUM_X_DIRECTION trend;
//
XSignalBox waitingBoxes[];
XSignalBox breakedBoxes[];
@@ -470,7 +475,8 @@ struct X121SMCStrategyXWZWorkingZone
* @return ( bool )
*/
bool DetectWaitingBoxes(
ENUM_X_CYCLES cycle,
ENUM_X_CYCLES obCycle,
ENUM_X_CYCLES fvgCycle,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
@@ -490,28 +496,63 @@ struct X121SMCStrategyXWZWorkingZone
}
//
// Select Cycle ...
XPOIState cState;
XPOIStateEvents cStateEvents;
X121Conditions cXConditions;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
// Select OB Cycle ...
XPOIState obState;
XPOIStateEvents obStateEvents;
X121Conditions obXConditions;
XC121SMCCycleHelper *obHelper;
X121SMCCycleConditions obConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
obCycle,
obState,
obStateEvents,
obXConditions,
obHelper,
obConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
obState.Clean();
ZeroMemory(obHelper);
obConditions.Clean();
obStateEvents.Clean();
obXConditions.Clean();
//
return result;
}
//
// Select FVG Cycle ...
XPOIState fvgState;
XPOIStateEvents fvgStateEvents;
X121Conditions fvgXConditions;
XC121SMCCycleHelper *fvgHelper;
X121SMCCycleConditions fvgConditions;
result = provider.SelectCycle(
fvgCycle,
fvgState,
fvgStateEvents,
fvgXConditions,
fvgHelper,
fvgConditions //
);
if (!result)
{
//
obState.Clean();
ZeroMemory(obHelper);
obConditions.Clean();
obStateEvents.Clean();
obXConditions.Clean();
//
fvgState.Clean();
ZeroMemory(fvgHelper);
fvgConditions.Clean();
fvgStateEvents.Clean();
fvgXConditions.Clean();
//
return result;
@@ -519,30 +560,30 @@ struct X121SMCStrategyXWZWorkingZone
//
// Select Order Blocks ...
if (cStateEvents.hasNewOrderBlock)
if (obStateEvents.hasNewOrderBlock)
{
//
idx = GetYoungest(cState.orderBlocks);
idx = GetYoungest(obState.orderBlocks);
has = IsValidIndex(idx);
if (has)
{
//
XCFVG *iFVG = NULL;
XCOrderBlock *iOB = cState.orderBlocks[idx];
XCOrderBlock *iOB = obState.orderBlocks[idx];
bool isBullish = iOB.IsBullish();
//
// Detecting Inside FVG ...
has = cState.HasFairValueGaps();
has = fvgState.HasFairValueGaps();
if (has)
{
//
XCFVG *tmpFVGs[];
count = cState.CountFairValueGaps();
count = fvgState.CountFairValueGaps();
for (int i = 0; i < count; i++)
{
//
XCFVG *jFVG = cState.fairValueGaps[i];
XCFVG *jFVG = fvgState.fairValueGaps[i];
//
bool isDirPassed = jFVG.GetDirection() == iOB.GetDirection();
@@ -610,7 +651,8 @@ struct X121SMCStrategyXWZWorkingZone
);
//
has = iOBBox.IsValid();
has = iOBBox.IsValid() &&
iFVGBox.IsValid();
if (has)
{
//
@@ -646,11 +688,18 @@ struct X121SMCStrategyXWZWorkingZone
// Cleanup Resources ...
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cXConditions.Clean();
cStateEvents.Clean();
obState.Clean();
ZeroMemory(obHelper);
obConditions.Clean();
obStateEvents.Clean();
obXConditions.Clean();
//
fvgState.Clean();
ZeroMemory(fvgHelper);
fvgConditions.Clean();
fvgStateEvents.Clean();
fvgXConditions.Clean();
//
return result;
@@ -766,118 +815,6 @@ struct X121SMCStrategyXWZWorkingZone
return result;
}
/**
* Detect Overal Trend of Working Zone ...
*
* @param dir: ENUM_X_DIRECTION member ...
*
* @return ( bool )
*/
bool DetectOveralDirection(
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
dir = X_DIRECTION_NONE;
//
result = IsValid() &&
HasSupplyZone() &&
HasDemandZone();
if (!result)
{
return result;
}
//
XBoxZone demBox;
XBoxZone supBox;
result = ToBox(
demBox,
demandZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
result = ToBox(
supBox,
supplyZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
//
XOHCL supPriceOutBar;
bool hasSupPriceOutBar = false;
result = DetectBoxNearestPriceOut(
supBox,
supPriceOutBar,
supBox.period //
);
//
XOHCL demPriceOutBar;
bool hasDemPriceOutBar = false;
result = DetectBoxNearestPriceOut(
demBox,
demPriceOutBar,
demBox.period //
);
//
hasSupPriceOutBar = supPriceOutBar.IsValid();
hasDemPriceOutBar = demPriceOutBar.IsValid();
//
// Specified Direction ...
dir =
(hasSupPriceOutBar &&
hasDemPriceOutBar)
? supPriceOutBar.time > demPriceOutBar.time
? X_DIRECTION_BEARISH
: demPriceOutBar.time > supPriceOutBar.time
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE
: (hasSupPriceOutBar &&
!hasDemPriceOutBar)
? X_DIRECTION_BEARISH
: (!hasSupPriceOutBar &&
hasDemPriceOutBar)
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE;
//
result = HasDirection(dir);
//
// Clean Up Resources ...
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
/**
* Detect Trend Based On Boxes ...
*
@@ -886,24 +823,218 @@ struct X121SMCStrategyXWZWorkingZone
* @return ( bool )
*/
bool DetectTreand(
ENUM_X_DIRECTION &dir //
ENUM_X_CYCLES cycle,
ENUM_X_DIRECTION &dir,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
support.Clean();
resistance.Clean();
dir = X_DIRECTION_NONE;
trend = X_DIRECTION_NONE;
//
// Overal ...
ENUM_X_DIRECTION overal;
bool hasOveral = DetectOveralDirection(overal);
if (barIndex < 0)
{
barIndex = 0;
}
//
// Waiting Boxes ...
result = IsValid(cycle);
if (!result)
{
return result;
}
//
// Select Cycle ...
XPOIState cState;
XPOIStateEvents cStateEvents;
X121Conditions cXConditions;
XC121SMCCycleHelper *cHelper;
X121SMCCycleConditions cConditions;
result = provider.SelectCycle(
cycle,
cState,
cStateEvents,
cXConditions,
cHelper,
cConditions //
);
if (!result)
{
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
//
// Detect Trend ...
//
int idx = -1;
bool has = false;
//
XBoxZone tmp[];
XBoxZone tmpBoxes[];
//
// Select Supports ...
ToBox(
cState.supportZones,
tmp //
);
Copy(
tmp,
tmpBoxes,
false //
);
Clean(tmp);
//
// Select Resistances ...
ToBox(
cState.resistanceZones,
tmp //
);
Copy(
tmp,
tmpBoxes,
false //
);
Clean(tmp);
//
result = HasChild(tmpBoxes);
if (!result)
{
//
Clean(tmpBoxes);
//
cState.Clean();
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
}
//
// Select Youngest Valid Zone ...
while (HasChild(tmpBoxes) ||
!(support.IsValid() &&
resistance.IsValid()))
{
//
// Check Yongest Zone ...
idx = GetYoungest(tmpBoxes);
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
// Remove Extracted Box ...
XBoxZone iBox = tmpBoxes[idx];
ArrayRemove(
tmpBoxes,
idx,
1 //
);
//
// Check Validation of Box ...
has = IsBoxValid(
iBox,
barIndex,
period //
);
if (!has)
{
//
iBox.Clean();
continue;
}
//
// Assign Support or Resistance ...
bool isBullish = iBox.IsBullish();
if (isBullish &&
!support.IsValid())
{
support = iBox;
}
else if (!isBullish &&
!resistance.IsValid())
{
resistance = iBox;
}
//
// Validate Support and Resistance ...
has =
support.IsValid() &&
resistance.IsValid();
if (!has)
{
//
iBox.Clean();
continue;
}
//
iBox.Clean();
}
//
// Checking Result ...
bool isBullish =
support.from > resistance.from;
bool isBearish =
support.from < resistance.from;
result = isBullish ||
isBearish;
if (result)
{
//
dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
trend = dir;
//
support.to = TimeCurrent();
resistance.to = TimeCurrent();
}
//
// Cleanup Resources ...
//
Clean(tmp);
cState.Clean();
Clean(tmpBoxes);
ZeroMemory(cHelper);
cConditions.Clean();
cStateEvents.Clean();
cXConditions.Clean();
//
return result;
@@ -1117,7 +1248,7 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------
// Rejected Box ...
// ---------------------------------------------
bool useSenario1 = true;
bool useSenario1 = false;
bool isSenario1Happend = false;
bool isSenario1Bullish = false;
bool isSenario1Bearish = false;
@@ -1156,7 +1287,7 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------------
// Activated Box ...
// ---------------------------------------------------
bool useSenario2 = true;
bool useSenario2 = false;
bool isSenario2Happend = false;
bool isSenario2Bullish = false;
bool isSenario2Bearish = false;
@@ -1196,7 +1327,7 @@ struct X121SMCStrategyXWZWorkingZone
// ---------------------------------------------------
// Breaked Box ...
// ---------------------------------------------------
bool useSenario3 = true;
bool useSenario3 = false;
bool isSenario3Happend = false;
bool isSenario3Bullish = false;
bool isSenario3Bearish = false;
@@ -1234,10 +1365,10 @@ struct X121SMCStrategyXWZWorkingZone
//
// Senario 4:
// ---------------------------------------------
// Detect Signal Box Based On Conditions ...
// ---------------------------------------------
bool useSenario4 = false;
// -----------------------------------------------
// Detect Signal Box Based On XHKMA Conditions ...
// -----------------------------------------------
bool useSenario4 = true;
bool isSenario4Happend = false;
bool isSenario4Bullish = false;
bool isSenario4Bearish = false;
@@ -1246,6 +1377,33 @@ 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;
}
}
//
@@ -1274,7 +1432,7 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bullish ||
isSenario3Bullish ||
isSenario4Bullish ||
isSenario5Bullish
isSenario5Bullish
//
;
@@ -1285,7 +1443,7 @@ struct X121SMCStrategyXWZWorkingZone
isSenario2Bearish ||
isSenario3Bearish ||
isSenario4Bearish ||
isSenario5Bearish
isSenario5Bearish
//
;
@@ -1448,7 +1606,8 @@ struct X121SMCStrategyXWZWorkingZone
XCPOIDrawer *drawer,
bool drawSupplyZone = false,
bool drawDemandZone = false,
bool drawWaitingZones = false //
bool drawWaitingZones = false,
bool drawTrend = false //
)
{
//
@@ -1724,6 +1883,44 @@ struct X121SMCStrategyXWZWorkingZone
}
}
//
// Draw Trend if Exists ...
if (drawTrend)
{
//
// Check Trend Exists ...
has =
support.IsValid() &&
HasDirection(trend) &&
resistance.IsValid();
if (has)
{
//
// Draw Support ...
XCBoxObject *supportObject;
has = drawer.DrawBox(
support,
supportObject //
);
if (has)
{
mWorkingZoneObjects.Add(supportObject);
}
//
// Draw Resistance ...
XCBoxObject *resistanceObject;
has = drawer.DrawBox(
resistance,
resistanceObject //
);
if (has)
{
mWorkingZoneObjects.Add(resistanceObject);
}
}
}
//
}