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
File diff suppressed because it is too large Load Diff
@@ -1431,17 +1431,18 @@ class XCX121SMCXSupDemOBSSignalDetector : public XCBase
bool isIBullish = IsBullish(iForDir); bool isIBullish = IsBullish(iForDir);
// //
isPriceRejected = IsReject( isPriceRejected = false;
iForDir, // IsReject(
decisionZBar, // iForDir,
obs[i], // decisionZBar,
decisionState, // obs[i],
swingBar, // decisionState,
rejectBar, // swingBar,
breakerBar, // rejectBar,
momentumBar, // breakerBar,
false // // momentumBar,
); // false //
// );
if (isPriceRejected) if (isPriceRejected)
{ {
// //
@@ -1494,17 +1495,18 @@ class XCX121SMCXSupDemOBSSignalDetector : public XCBase
bool isIBullish = IsBullish(iForDir); bool isIBullish = IsBullish(iForDir);
// //
isPriceRejected = IsReject( isPriceRejected = false;
iForDir, // IsReject(
decisionZBar, // iForDir,
fvgs[i], // decisionZBar,
decisionState, // fvgs[i],
swingBar, // decisionState,
rejectBar, // swingBar,
breakerBar, // rejectBar,
momentumBar, // breakerBar,
false // // momentumBar,
); // false //
// );
if (isPriceRejected) if (isPriceRejected)
{ {
// //
File diff suppressed because it is too large Load Diff
-11
View File
@@ -36,7 +36,6 @@ const string X121SMCStrategyToken = "X121SMC";
// //
const string X121SMCXWZToken = "X121XWZ"; const string X121SMCXWZToken = "X121XWZ";
const string X121SMCXSupDemOBSToken = "X121XSupDemOBS";
// //
// X121 SMC Providers ... // X121 SMC Providers ...
@@ -45,7 +44,6 @@ enum ENUM_X_121_SMC_PROVIDERS
// //
X_121_SMC_PROVIDER_NONE, X_121_SMC_PROVIDER_NONE,
X_121_SMC_PROVIDER_XWZ, X_121_SMC_PROVIDER_XWZ,
X_121_SMC_PROVIDER_XSUPDEMOBS,
}; };
// //
@@ -698,11 +696,6 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
case X_121_SMC_PROVIDER_XWZ: case X_121_SMC_PROVIDER_XWZ:
result = X121SMCXWZToken; result = X121SMCXWZToken;
break; break;
//
case X_121_SMC_PROVIDER_XSUPDEMOBS:
result = X121SMCXSupDemOBSToken;
break;
} }
// //
@@ -732,10 +725,6 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
{ {
result = X_121_SMC_PROVIDER_XWZ; result = X_121_SMC_PROVIDER_XWZ;
} }
else if (Contains(X121SMCXSupDemOBSToken, value))
{
result = X_121_SMC_PROVIDER_XSUPDEMOBS;
}
// //
return result; return result;
+135 -70
View File
@@ -538,64 +538,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
); );
} }
//
result = hasStartZone;
if (!result)
{
//
Clean(visionPoiEvents);
Clean(analysePoiEvents);
Clean(decisionPoiEvents);
Clean(visionCycleEvents);
Clean(analyseCycleEvents);
Clean(decisionCycleEvents);
Clean(consolidationPoiEvents);
Clean(consolidationCycleEvents);
//
visionState.Clean();
analyseState.Clean();
decisionZBar.Clean();
decisionCBar.Clean();
decisionPBar.Clean();
decisionState.Clean();
visionConditions.Clean();
analyseConditions.Clean();
visionXConditions.Clean();
consolidationState.Clean();
decisionConditions.Clean();
analyseXConditions.Clean();
decisionXConditions.Clean();
consolidationConditions.Clean();
consolidationXConditions.Clean();
//
RemoveDraws();
RemoveWorkingZoneDraws();
//
mConditions.Clean();
//
return result;
}
// //
mConditions.UpdateTo(cTime); mConditions.UpdateTo(cTime);
//
// Detect Start Zone Conditions ...
bool hasCondition = mConditions
.startZone
.HasCondition(
decisionState,
zIndex,
period //
);
ENUM_X_DIRECTION conditionsDir = mConditions
.startZone
.GetDirection();
// //
// Detect Condition Priority ... // Detect Condition Priority ...
ENUM_X121SMC_XWZ_PRIORITY bullishPriority; ENUM_X121SMC_XWZ_PRIORITY bullishPriority;
@@ -617,8 +562,77 @@ class XCX121SMCXWZSignalDetector : public XCBase
? canLookupShort ? canLookupShort
: false; : false;
//
bool hasCondition = false;
ENUM_X_DIRECTION conditionsDir = X_DIRECTION_NONE;
//
// Detect Start Zone Based Conditions ...
if (hasStartZone)
{
//
// Detect Start Zone Conditions ...
hasCondition = mConditions
.startZone
.HasCondition(
decisionState,
zIndex,
NULL // period //
);
conditionsDir = mConditions
.startZone
.GetDirection();
}
//
RemoveWorkingZoneDraws();
DrawWorkingZone(mConditions, visionCycleHelper.mPOIDrawer);
//
// Detect Supply and Deman Zone Based Conditions ...
if (!hasCondition)
{
//
bool isPriceInsideSupplyZone =
bearishPriority == X121SMC_XWZ_PRIORITY_STRONG_HIGH;
//
bool isPriceInsideDemandZone =
bullishPriority == X121SMC_XWZ_PRIORITY_STRONG_HIGH;
//
bool isPriceInsideSupDem = isPriceInsideSupplyZone ||
isPriceInsideDemandZone;
if (isPriceInsideSupDem)
{
//
hasCondition = mConditions.HasWorkingZoneConditions(
conditionsDir,
decisionState //
);
}
}
//
isBullish = IsBullish(conditionsDir);
isBearish = IsBearish(conditionsDir);
//
double reward;
double amountPercent;
ENUM_X121SMC_XWZ_PRIORITY priority =
isBullish
? bullishPriority
: bearishPriority;
bool hasRewardAmount = CalculateRiskReward(
priority,
reward,
amountPercent //
);
// //
result = hasCondition && result = hasCondition &&
hasRewardAmount &&
isPriorityPassed && isPriorityPassed &&
trend == conditionsDir; trend == conditionsDir;
if (!result) if (!result)
@@ -658,14 +672,60 @@ class XCX121SMCXWZSignalDetector : public XCBase
} }
// //
// Apply Traget ...
switch (priority)
{
//
case X121SMC_XWZ_PRIORITY_STRONG_HIGH:
//
target =
isBullish
? mConditions.workingZone.quarter3
: mConditions.workingZone.quarter1;
break;
//
case X121SMC_XWZ_PRIORITY_HIGH:
//
target =
isBullish
? mConditions.workingZone.quarter3
: mConditions.workingZone.quarter1;
break;
//
case X121SMC_XWZ_PRIORITY_REGULAR:
//
target =
isBullish
? mConditions.workingZone.quarter2
: mConditions.workingZone.quarter2;
break;
//
case X121SMC_XWZ_PRIORITY_LOW:
//
target =
isBullish
? mConditions.workingZone.quarter1
: mConditions.workingZone.quarter3;
break;
//
default:
target = 0;
break;
}
//
mConditions.reward = reward;
mConditions.target = target;
mConditions.setupTime = cTime; mConditions.setupTime = cTime;
mConditions.priority = priority;
mConditions.dir = conditionsDir; mConditions.dir = conditionsDir;
mConditions.amountPercent = amountPercent;
mConditions.pivot = mConditions.GetExit(); mConditions.pivot = mConditions.GetExit();
mConditions.point = mConditions.GetPoint(); mConditions.point = mConditions.GetPoint();
isBullish = mConditions.startZone.IsBullish();
isBearish = mConditions.startZone.IsBearish();
result = isBullish ||
isBearish;
// //
mConditions.UpdateTo(cTime); mConditions.UpdateTo(cTime);
@@ -869,18 +929,16 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
isBullish = isBullish =
// //
isBullish isBullish &&
// && isPointBreaked
// isPointBreaked
// //
; ;
// //
isBearish = isBearish =
// //
isBearish isBearish &&
// && isPointBreaked
// isPointBreaked
// //
; ;
@@ -939,7 +997,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
double iAtr = decisionXConditions.atrBuffer[1]; double iAtr = decisionXConditions.atrBuffer[1];
iAtr *= 1.5; iAtr *= 2;
// //
double slsMin = GetMin(sls); double slsMin = GetMin(sls);
@@ -2701,30 +2759,37 @@ class XCX121SMCXWZSignalDetector : public XCBase
switch (priority) switch (priority)
{ {
// //
case X121SMC_XWZ_PRIORITY_HIGH: case X121SMC_XWZ_PRIORITY_STRONG_HIGH:
// //
reward = 6; reward = 6;
amountPercent = 2; amountPercent = 2;
break; break;
//
case X121SMC_XWZ_PRIORITY_HIGH:
//
reward = 4;
amountPercent = 2;
break;
// //
case X121SMC_XWZ_PRIORITY_REGULAR: case X121SMC_XWZ_PRIORITY_REGULAR:
// //
reward = 6; reward = 3;
amountPercent = 1.5; amountPercent = 1.5;
break; break;
// //
case X121SMC_XWZ_PRIORITY_LOW: case X121SMC_XWZ_PRIORITY_LOW:
// //
reward = 4; reward = 2;
amountPercent = 1; amountPercent = 1;
break; break;
// //
case X121SMC_XWZ_PRIORITY_WEAK: case X121SMC_XWZ_PRIORITY_WEAK:
// //
reward = 2; reward = 1;
amountPercent = 0.5; amountPercent = 0.5;
break; break;
} }
+411 -173
View File
@@ -678,6 +678,7 @@ struct X121SMCXWZZone
isBullish isBullish
? supResBoxes[j].lower ? supResBoxes[j].lower
: supResBoxes[j].upper; : supResBoxes[j].upper;
// //
// Check Swing Low ... // Check Swing Low ...
bool isSwingLow = bool isSwingLow =
@@ -1167,6 +1168,13 @@ struct X121SMCXWZWorkingZone
datetime to; datetime to;
datetime from; datetime from;
//
XOHCL swingBar;
XOHCL breakerBar;
XOHCL momentumBar;
XOHCL rejectionBar;
XBoxZone appliedBox;
// //
X121SMCXWZWorkingZone() X121SMCXWZWorkingZone()
{ {
@@ -1190,10 +1198,24 @@ struct X121SMCXWZWorkingZone
symbol = NULL; symbol = NULL;
period = NULL; period = NULL;
//
CleanConditionBars();
// //
ZeroMemory(this); ZeroMemory(this);
} }
//
void CleanConditionBars()
{
//
swingBar.Clean();
breakerBar.Clean();
appliedBox.Clean();
momentumBar.Clean();
rejectionBar.Clean();
}
// //
bool IsValid() bool IsValid()
{ {
@@ -2004,7 +2026,7 @@ struct X121SMCStrategyXWZSignalConditions
// //
hasTrend = hasTrend =
// //
IsValid(supplyTouch) && IsValid(supplyTouch) ||
IsValid(demandTouch) IsValid(demandTouch)
// //
; ;
@@ -2037,6 +2059,10 @@ struct X121SMCStrategyXWZSignalConditions
// //
// Find Order Block and FVG for Trend Approve ... // 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 ... // Now We Have to Detect at least One OrderBlock with FVG ...
// for Trend Approvement ... // for Trend Approvement ...
@@ -2054,192 +2080,205 @@ struct X121SMCStrategyXWZSignalConditions
XCOrderBlock *ob = NULL; XCOrderBlock *ob = NULL;
// //
if (hasBullishTrend) has = mtfState.HasBullishOrderBlocks();
count = mtfState.CountBullishOrderBlocks();
//
if (has)
{ {
// //
has = mtfState.HasBullishOrderBlocks(); // Check Order Block ...
count = mtfState.CountBullishOrderBlocks(); for (int i = 0; i < count; i++)
//
if (has)
{ {
// //
// Check Order Block ... XCOrderBlock *iOB = mtfState.bullishOrderBlocks[i];
for (int i = 0; i < count; 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]; startedBar.Clean();
continue;
// }
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;
//
// Converts to Box ...
XBoxZone obBox;
bool hasOBBox = ToBox(
obBox,
iOB //
);
if (!hasOBBox)
{
// //
obBox.Clean(); obBox.Clean();
startedBar.Clean(); startedBar.Clean();
continue;
//
break;
} }
// //
// Detect Fair Value Gap ... // Check Zone Must not Used before ...
if (ob != NULL && bool isUsed = IsBoxUsed(
ob.IsValid()) obBox,
startedBar.Index() - 1,
zIndex //
);
if (isUsed)
{ {
// //
has = stfState.HasBullishFairValueGaps(); obBox.Clean();
count = stfState.CountBullishFairValueGaps(); startedBar.Clean();
if (has) 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 ... XCFVG *iFVG = stfState.bullishFairValueGaps[i];
for (int i = 0; i < count; 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]; startedBar.Clean();
continue;
// }
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;
//
// Converts to Box ...
XBoxZone fvgBox;
bool hasFVGBox = ToBox(
fvgBox,
iFVG //
);
if (!hasFVGBox)
{
// //
fvgBox.Clean(); fvgBox.Clean();
startedBar.Clean(); startedBar.Clean();
continue;
//
break;
} }
}
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(); has = mtfState.HasBearishOrderBlocks();
@@ -2422,28 +2461,32 @@ struct X121SMCStrategyXWZSignalConditions
ob = NULL; 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 ... // Check Trend Approved ...
bool isTrendApproved = bool isTrendApproved =
hasOrderBlock && hasOrderBlock &&
hasFairValueGap; hasFairValueGap &&
(isBullishTrendApproved ||
isBearishTrendApproved);
result = isTrendApproved; result = isTrendApproved;
if (!result) if (!result)
{ {
@@ -2634,7 +2677,7 @@ struct X121SMCStrategyXWZSignalConditions
// //
result = result =
// //
IsValid(supplyTouch) && IsValid(supplyTouch) ||
IsValid(demandTouch) IsValid(demandTouch)
// //
; ;
@@ -2819,10 +2862,54 @@ struct X121SMCStrategyXWZSignalConditions
// //
bool hasOBFVG = startZone.HasOB() && bool hasOBFVG = startZone.HasOB() &&
startZone.HasFVG(); startZone.HasFVG();
bool isOBStarted = false;
bool isFVGStarted = false;
bool isOBActivated = false;
bool isFVGActivated = false;
bool isOBInsideFVG = false; bool isOBInsideFVG = false;
bool isFVGInsideOB = false; bool isFVGInsideOB = false;
if (hasOBFVG) 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 = isOBInsideFVG =
IsInsideDiff( IsInsideDiff(
@@ -2857,10 +2944,17 @@ struct X121SMCStrategyXWZSignalConditions
startZone.ob, startZone.ob,
true // IgnoreInside true // IgnoreInside
)); ));
//
startedBar.Clean();
} }
// //
result = result =
isOBStarted &&
isFVGStarted &&
isOBActivated &&
isFVGActivated &&
startZone.IsValid() && startZone.IsValid() &&
(isOBInsideFVG || (isOBInsideFVG ||
isFVGInsideOB) && isFVGInsideOB) &&
@@ -3008,6 +3102,150 @@ struct X121SMCStrategyXWZSignalConditions
cBar.Clean(); 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() double GetEntry()
{ {
+11 -339
View File
@@ -27,7 +27,6 @@
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5" #include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
// //
#include "../Signals/x-121.smc.xsupdemobs.signal.class.mq5"
#include "../Signals/x-121.smc.xwz.signal.class.mq5" #include "../Signals/x-121.smc.xwz.signal.class.mq5"
// //
@@ -43,9 +42,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// Props ... // Props ...
bool useXWZSignal; bool useXWZSignal;
bool useXSupDemOBSSignal;
XCX121SMCXWZSignalDetector *mXWZSignalDetector; XCX121SMCXWZSignalDetector *mXWZSignalDetector;
XCX121SMCXSupDemOBSSignalDetector *mXSupDemOBSSignalDetector;
// //
// Constructor(s) ... // Constructor(s) ...
@@ -62,7 +59,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
mXWZSignalDetector = new XCX121SMCXWZSignalDetector(); mXWZSignalDetector = new XCX121SMCXWZSignalDetector();
mXSupDemOBSSignalDetector = new XCX121SMCXSupDemOBSSignalDetector();
} }
// //
@@ -110,12 +106,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
*/ */
void Destroy() override void Destroy() override
{ {
//
delete mDecisionCycleHelper;
delete mAnalyseCycleHelper;
delete mConsolidationCycleHelper;
delete mVisionCycleHelper;
// //
ZeroMemory(mDecisionCycleHelper); ZeroMemory(mDecisionCycleHelper);
ZeroMemory(mAnalyseCycleHelper); ZeroMemory(mAnalyseCycleHelper);
@@ -123,12 +113,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
ZeroMemory(mVisionCycleHelper); ZeroMemory(mVisionCycleHelper);
// //
delete mXWZSignalDetector;
ZeroMemory(mXWZSignalDetector); ZeroMemory(mXWZSignalDetector);
//
delete mXSupDemOBSSignalDetector;
ZeroMemory(mXSupDemOBSSignalDetector);
} }
/** /**
@@ -208,7 +193,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
bool hasXWZSignal = false; bool hasXWZSignal = false;
bool hasXSupDemOBSSignal = false;
// //
// XSupDemOBS Signal ... // XSupDemOBS Signal ...
@@ -223,19 +207,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXWZSignal; hasSignal = hasXWZSignal;
} }
//
// XSupDemOBS Signal ...
X121SMCStrategyXSupDemOBSSignalConditions mXSupDemOBSConditions;
if (useXSupDemOBSSignal && !hasSignal)
{
//
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(
conditions,
mXSupDemOBSConditions //
);
hasSignal = hasXSupDemOBSSignal;
}
// //
result = hasSignal; result = hasSignal;
if (!result) if (!result)
@@ -342,18 +313,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
if (result) if (result)
{ {
// //
if (useXSupDemOBSSignal && if (useXWZSignal &&
hasXSupDemOBSSignal) hasXWZSignal)
{ {
// //
// Configuring Amount Percent and ETC ... // Configuring Amount Percent and ETC ...
bool ignoreEAVolume = mXSupDemOBSConditions.reward > 0 && bool ignoreEAVolume = mXWZConditions.reward > 0 &&
mXSupDemOBSConditions.amountPercent > 0; mXWZConditions.amountPercent > 0;
if (ignoreEAVolume) if (ignoreEAVolume)
{ {
// //
double cReward = mXSupDemOBSConditions.reward; double cReward = mXWZConditions.reward;
double cAmountPercent = mXSupDemOBSConditions.amountPercent; double cAmountPercent = mXWZConditions.amountPercent;
// //
double cRiskReward = risk * cReward; double cRiskReward = risk * cReward;
@@ -385,8 +356,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Fix Signal TP Based On Working Zone ... // Fix Signal TP Based On Working Zone ...
double maxAllowedTP = double maxAllowedTP =
hasLong hasLong
? mXSupDemOBSConditions.workingZone.upper ? mXWZConditions.workingZone.upper
: mXSupDemOBSConditions.workingZone.lower; : mXWZConditions.workingZone.lower;
bool canApplyMaxAlowedTP = (hasLong && bool canApplyMaxAlowedTP = (hasLong &&
signal.tp > maxAllowedTP) || signal.tp > maxAllowedTP) ||
(!hasLong && signal.tp < maxAllowedTP); (!hasLong && signal.tp < maxAllowedTP);
@@ -448,7 +419,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
} }
// //
mXSupDemOBSConditions.Clean(); mXWZConditions.Clean();
// //
return result; return result;
@@ -501,33 +472,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
false // false //
); );
} }
}
//
// XSupDemOBS Guard Detection ...
if (useXSupDemOBSSignal)
{
//
X121SMCGuard xsupDemOBSGuards[];
bool hasGuard = mXSupDemOBSSignalDetector.DetectGuards(
xsupDemOBSGuards,
positions,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
// //
if (hasGuard) Clean(xwzGuards);
{
//
Copy(
xsupDemOBSGuards,
guards,
false //
);
}
} }
// //
@@ -618,51 +565,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
string symbol = GetSymbol(); string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod(); ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
// //
datetime cTime = TimeCurrent(); datetime cTime = TimeCurrent();
// //
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XSUPDEMOBS; ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XWZ;
string providerStr = ToString(provider); string providerStr = ToString(provider);
// //
@@ -813,240 +720,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result; return result;
} }
//
// XSupDemOBS Signal ...
bool DetectXSupDemOBSSignal(
X121SMCStrategyConditions &conditions,
X121SMCStrategyXSupDemOBSSignalConditions &xSupDemOBSConditions //
)
{
//
bool result = false;
//
// Validate Cycle Helpers ...
result =
//
mVisionCycleHelper != NULL &&
mAnalyseCycleHelper != NULL &&
mDecisionCycleHelper != NULL &&
mConsolidationCycleHelper != NULL
//
;
if (!result)
{
return result;
}
//
bool isBullish = false;
bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
XOHCL zBar;
result = zBar.Init(
symbol,
period,
zIndex //
);
if (!result)
{
return result;
}
//
XOHCL cBar;
result = cBar.Init(
symbol,
period,
cIndex //
);
if (!result)
{
return result;
}
//
XOHCL pBar;
result = pBar.Init(
symbol,
period,
pIndex //
);
if (!result)
{
return result;
}
//
double cLL = cBar.FindLowest(7, MODE_LOW);
double cHH = cBar.FindHighest(7, MODE_HIGH);
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XSUPDEMOBS;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXSupDemOBSSignalDetector.mConditions.setupTime;
bool isSetuped = mXSupDemOBSSignalDetector.mConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXSupDemOBSSignalDetector.mConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = mXSupDemOBSSignalDetector.DetectSignalSetup(
symbol,
period,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXSupDemOBSSignalDetector.mConditions.dir;
setupTime = mXSupDemOBSSignalDetector.mConditions.setupTime;
//
if (isSetuped)
{
//
int items = mXSupDemOBSSignalDetector
.AddConditionsIfNotExists();
//
mXSupDemOBSSignalDetector.mConditions.Clean();
}
}
//
int conditionsCount = ArraySize(mXSupDemOBSSignalDetector.mConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXSupDemOBSSignalConditions mTmpConditions[];
Copy(
mXSupDemOBSSignalDetector.mConditionsCollection,
mTmpConditions //
);
X121SMCStrategyXSupDemOBSSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Check Triggers ...
bool canTrigger = mTmpConditions[i].CanTrigger();
datetime triggerTime = mTmpConditions[i].triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = mXSupDemOBSSignalDetector
.DetectSignalTrigger(
mTmpConditions[i],
symbol,
period,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
//
bool isISetuped = mTmpConditions[i].IsSetuped();
if (!isISetuped)
{
//
ArrayRemove(
mXSupDemOBSSignalDetector.mConditionsCollection,
i,
1 //
);
}
continue;
}
//
triggerTime = mTmpConditions[i].triggerTime;
}
//
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mTmpConditions[i];
break;
}
}
//
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXSupDemOBSSignalDetector.mConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
xSupDemOBSConditions = mConditions;
//
mConditions.Clean();
//
return result;
}
// //
// Private ... // Private ...
private: private:
@@ -1063,7 +736,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{ {
// //
useXWZSignal = true; useXWZSignal = true;
useXSupDemOBSSignal = false;
// //
string symbol = GetSymbol(); string symbol = GetSymbol();