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
-11
View File
@@ -36,7 +36,6 @@ const string X121SMCStrategyToken = "X121SMC";
//
const string X121SMCXWZToken = "X121XWZ";
const string X121SMCXSupDemOBSToken = "X121XSupDemOBS";
//
// X121 SMC Providers ...
@@ -45,7 +44,6 @@ enum ENUM_X_121_SMC_PROVIDERS
//
X_121_SMC_PROVIDER_NONE,
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:
result = X121SMCXWZToken;
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;
}
else if (Contains(X121SMCXSupDemOBSToken, value))
{
result = X_121_SMC_PROVIDER_XSUPDEMOBS;
}
//
return result;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+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);
//
// Detect Start Zone Conditions ...
bool hasCondition = mConditions
.startZone
.HasCondition(
decisionState,
zIndex,
period //
);
ENUM_X_DIRECTION conditionsDir = mConditions
.startZone
.GetDirection();
//
// Detect Condition Priority ...
ENUM_X121SMC_XWZ_PRIORITY bullishPriority;
@@ -617,8 +562,77 @@ class XCX121SMCXWZSignalDetector : public XCBase
? canLookupShort
: 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 &&
hasRewardAmount &&
isPriorityPassed &&
trend == conditionsDir;
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.priority = priority;
mConditions.dir = conditionsDir;
mConditions.amountPercent = amountPercent;
mConditions.pivot = mConditions.GetExit();
mConditions.point = mConditions.GetPoint();
isBullish = mConditions.startZone.IsBullish();
isBearish = mConditions.startZone.IsBearish();
result = isBullish ||
isBearish;
//
mConditions.UpdateTo(cTime);
@@ -869,18 +929,16 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
isBullish =
//
isBullish
// &&
// isPointBreaked
isBullish &&
isPointBreaked
//
;
//
isBearish =
//
isBearish
// &&
// isPointBreaked
isBearish &&
isPointBreaked
//
;
@@ -939,7 +997,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
double iAtr = decisionXConditions.atrBuffer[1];
iAtr *= 1.5;
iAtr *= 2;
//
double slsMin = GetMin(sls);
@@ -2701,30 +2759,37 @@ class XCX121SMCXWZSignalDetector : public XCBase
switch (priority)
{
//
case X121SMC_XWZ_PRIORITY_HIGH:
case X121SMC_XWZ_PRIORITY_STRONG_HIGH:
//
reward = 6;
amountPercent = 2;
break;
//
case X121SMC_XWZ_PRIORITY_HIGH:
//
reward = 4;
amountPercent = 2;
break;
//
case X121SMC_XWZ_PRIORITY_REGULAR:
//
reward = 6;
reward = 3;
amountPercent = 1.5;
break;
//
case X121SMC_XWZ_PRIORITY_LOW:
//
reward = 4;
reward = 2;
amountPercent = 1;
break;
//
case X121SMC_XWZ_PRIORITY_WEAK:
//
reward = 2;
reward = 1;
amountPercent = 0.5;
break;
}
+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()
{
+11 -339
View File
@@ -27,7 +27,6 @@
#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"
//
@@ -43,9 +42,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Props ...
bool useXWZSignal;
bool useXSupDemOBSSignal;
XCX121SMCXWZSignalDetector *mXWZSignalDetector;
XCX121SMCXSupDemOBSSignalDetector *mXSupDemOBSSignalDetector;
//
// Constructor(s) ...
@@ -62,7 +59,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
mXWZSignalDetector = new XCX121SMCXWZSignalDetector();
mXSupDemOBSSignalDetector = new XCX121SMCXSupDemOBSSignalDetector();
}
//
@@ -110,12 +106,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
*/
void Destroy() override
{
//
delete mDecisionCycleHelper;
delete mAnalyseCycleHelper;
delete mConsolidationCycleHelper;
delete mVisionCycleHelper;
//
ZeroMemory(mDecisionCycleHelper);
ZeroMemory(mAnalyseCycleHelper);
@@ -123,12 +113,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
ZeroMemory(mVisionCycleHelper);
//
delete mXWZSignalDetector;
ZeroMemory(mXWZSignalDetector);
//
delete mXSupDemOBSSignalDetector;
ZeroMemory(mXSupDemOBSSignalDetector);
}
/**
@@ -208,7 +193,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool hasXWZSignal = false;
bool hasXSupDemOBSSignal = false;
//
// XSupDemOBS Signal ...
@@ -223,19 +207,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXWZSignal;
}
//
// XSupDemOBS Signal ...
X121SMCStrategyXSupDemOBSSignalConditions mXSupDemOBSConditions;
if (useXSupDemOBSSignal && !hasSignal)
{
//
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(
conditions,
mXSupDemOBSConditions //
);
hasSignal = hasXSupDemOBSSignal;
}
//
result = hasSignal;
if (!result)
@@ -342,18 +313,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
if (result)
{
//
if (useXSupDemOBSSignal &&
hasXSupDemOBSSignal)
if (useXWZSignal &&
hasXWZSignal)
{
//
// Configuring Amount Percent and ETC ...
bool ignoreEAVolume = mXSupDemOBSConditions.reward > 0 &&
mXSupDemOBSConditions.amountPercent > 0;
bool ignoreEAVolume = mXWZConditions.reward > 0 &&
mXWZConditions.amountPercent > 0;
if (ignoreEAVolume)
{
//
double cReward = mXSupDemOBSConditions.reward;
double cAmountPercent = mXSupDemOBSConditions.amountPercent;
double cReward = mXWZConditions.reward;
double cAmountPercent = mXWZConditions.amountPercent;
//
double cRiskReward = risk * cReward;
@@ -385,8 +356,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// Fix Signal TP Based On Working Zone ...
double maxAllowedTP =
hasLong
? mXSupDemOBSConditions.workingZone.upper
: mXSupDemOBSConditions.workingZone.lower;
? mXWZConditions.workingZone.upper
: mXWZConditions.workingZone.lower;
bool canApplyMaxAlowedTP = (hasLong &&
signal.tp > maxAllowedTP) ||
(!hasLong && signal.tp < maxAllowedTP);
@@ -448,7 +419,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
}
//
mXSupDemOBSConditions.Clean();
mXWZConditions.Clean();
//
return result;
@@ -501,33 +472,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
false //
);
}
}
//
// XSupDemOBS Guard Detection ...
if (useXSupDemOBSSignal)
{
//
X121SMCGuard xsupDemOBSGuards[];
bool hasGuard = mXSupDemOBSSignalDetector.DetectGuards(
xsupDemOBSGuards,
positions,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
if (hasGuard)
{
//
Copy(
xsupDemOBSGuards,
guards,
false //
);
}
Clean(xwzGuards);
}
//
@@ -618,51 +565,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
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;
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XWZ;
string providerStr = ToString(provider);
//
@@ -813,240 +720,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
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:
@@ -1063,7 +736,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
useXWZSignal = true;
useXSupDemOBSSignal = false;
//
string symbol = GetSymbol();