From aa1ffb3ed9fdd325f49111a42558cfbdb512718e Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 25 Dec 2024 00:53:38 +0330 Subject: [PATCH] prepare all materials for implementing new test strategy ... --- .../x-121.smc.x-tradehandler.class.mq5 | 16 + X121SMCEA/Experts/x-121.smc.expert.class.mq5 | 6 +- X121SMCEA/Libraries/x-121.smc.lib.mq5 | 35 +- .../Signals/x-121.smc.test.signal.class.mq5 | 1056 +---------- .../Signals/x-121.smc.xpvob.signal.class.mq5 | 1664 +++++++++++++++++ ...class.mq5 => x-121.smc.strategy.class.mq5} | 247 ++- 6 files changed, 1890 insertions(+), 1134 deletions(-) create mode 100644 X121SMCEA/Signals/x-121.smc.xpvob.signal.class.mq5 rename X121SMCEA/Strategy/{x-121.smc.test.strategy.class.mq5 => x-121.smc.strategy.class.mq5} (94%) diff --git a/X121SMCEA/Classes/x-121.smc.x-tradehandler.class.mq5 b/X121SMCEA/Classes/x-121.smc.x-tradehandler.class.mq5 index 712a912f..27fea5b4 100644 --- a/X121SMCEA/Classes/x-121.smc.x-tradehandler.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.x-tradehandler.class.mq5 @@ -3015,6 +3015,22 @@ class XC121SMCTradeHandler : public XCBaseAlert } } + // + // Check Spread ... + double spread = GetSpread(signal.symbol); + double maxAllowedSpread = MaxAllowedSpread(); + if (maxAllowedSpread > 0) + { + // + result = spread <= maxAllowedSpread; + if (!result) + { + // + state = X_SIGNAL_EXECUTION_FAILED_SPREAD; + return result; + } + } + // return result; } diff --git a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 index dd3c8eb5..d1ec948d 100644 --- a/X121SMCEA/Experts/x-121.smc.expert.class.mq5 +++ b/X121SMCEA/Experts/x-121.smc.expert.class.mq5 @@ -24,7 +24,7 @@ #include "../../Classes/x-saherelm.x-expert.class.mq5" #include "../Classes/x-121.smc.x-tradehandler.class.mq5" #include "../Libraries/x-121.smc.lib.mq5" -#include "../Strategy/x-121.smc.test.strategy.class.mq5" +#include "../Strategy/x-121.smc.strategy.class.mq5" // // Definitions ... @@ -1044,7 +1044,7 @@ class XC121SMCExpert : public XCBaseExpert // // Create Class Instance ... XCX121SMCBaseStrategy *iX121SMCStrategy; - iX121SMCStrategy = new XCX121SMCTestStrategy( + iX121SMCStrategy = new XCX121SMCStrategy( _Symbol, _Period // ); @@ -1109,7 +1109,7 @@ class XC121SMCExpert : public XCBaseExpert // // Create Class Instance ... XCX121SMCBaseStrategy *iX121SMCStrategy; - iX121SMCStrategy = new XCX121SMCTestStrategy( + iX121SMCStrategy = new XCX121SMCStrategy( iSymbol, _Period // ); diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index ba3cedac..ad2f8c35 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -34,9 +34,8 @@ const string X121SMCStrategyToken = "X121SMC"; // -const string X121SMCSMPVToken = "X121SMCSMPV"; -const string X121SMCRJBPVToken = "X121SMCRJBPV"; -const string X121SMCVWAPCToken = "X121SMCVWAPC"; +const string X121SMCXTestToken = "X121XTest"; +const string X121SMCXPVOBToken = "X121XPVOB"; // // X121 SMC Providers ... @@ -44,9 +43,8 @@ enum ENUM_X_121_SMC_PROVIDERS { // X_121_SMC_PROVIDER_NONE, - X_121_SMC_PROVIDER_SMPV, - X_121_SMC_PROVIDER_RJBPV, - X_121_SMC_PROVIDER_VWAPC, + X_121_SMC_PROVIDER_XTEST, + X_121_SMC_PROVIDER_XPVOB, }; // @@ -1951,18 +1949,13 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value) switch (value) { // - case X_121_SMC_PROVIDER_SMPV: - result = X121SMCSMPVToken; + case X_121_SMC_PROVIDER_XTEST: + result = X121SMCXTestToken; break; // - case X_121_SMC_PROVIDER_RJBPV: - result = X121SMCRJBPVToken; - break; - - // - case X_121_SMC_PROVIDER_VWAPC: - result = X121SMCVWAPCToken; + case X_121_SMC_PROVIDER_XPVOB: + result = X121SMCXPVOBToken; break; } @@ -1989,17 +1982,13 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value) } // - if (Contains(X121SMCSMPVToken, value)) + if (Contains(X121SMCXTestToken, value)) { - result = X_121_SMC_PROVIDER_SMPV; + result = X_121_SMC_PROVIDER_XTEST; } - else if (Contains(X121SMCRJBPVToken, value)) + else if (Contains(X121SMCXPVOBToken, value)) { - result = X_121_SMC_PROVIDER_RJBPV; - } - else if (Contains(X121SMCVWAPCToken, value)) - { - result = X_121_SMC_PROVIDER_VWAPC; + result = X_121_SMC_PROVIDER_XPVOB; } // diff --git a/X121SMCEA/Signals/x-121.smc.test.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.test.signal.class.mq5 index ab47b9ae..30550e76 100644 --- a/X121SMCEA/Signals/x-121.smc.test.signal.class.mq5 +++ b/X121SMCEA/Signals/x-121.smc.test.signal.class.mq5 @@ -47,15 +47,6 @@ struct X121SMCStrategyTestSignalConditions datetime setupTime; datetime triggerTime; - // - XCOrderBlock *bullishOBs[]; - XCOrderBlock *bearishOBs[]; - - // - XCFVG *activeFVG; - XCFVG *bullishFVGs[]; - XCFVG *bearishFVGs[]; - // // Trigger Props ... @@ -88,9 +79,6 @@ struct X121SMCStrategyTestSignalConditions triggerTime = NULL; // - activeFVG = NULL; - Clean(bullishOBs); - Clean(bearishOBs); } /** @@ -169,54 +157,6 @@ struct X121SMCStrategyTestSignalConditions // // Extensions ... - // - int CountBullishOBs() - { - return ArraySize(bullishOBs); - } - - // - int CountBearishOBs() - { - return ArraySize(bearishOBs); - } - - // - bool HasBullishOB() - { - return IsValidSize(CountBullishOBs()); - } - - // - bool HasBearishOB() - { - return IsValidSize(CountBearishOBs()); - } - - // - int CountBullishFVGs() - { - return ArraySize(bullishFVGs); - } - - // - int CountBearishFVGs() - { - return ArraySize(bearishFVGs); - } - - // - bool HasBullishFVG() - { - return IsValidSize(CountBullishFVGs()); - } - - // - bool HasBearishFVG() - { - return IsValidSize(CountBearishFVGs()); - } - // }; @@ -419,339 +359,26 @@ bool DetectX121SMCTestSiganlSetup( XPOIState consolidationState = consolidationConditions.state; XPOIState visionState = visionConditions.state; - // - // Detect Imbalances ... - - // - XPOIState state = decisionState; - - // - bool hasBullishOB = conditions.HasBullishOB(); - if (!hasBullishOB) - { - // - int count = state.CountBullishOrderBlocks(); - if (IsValidSize(count)) - { - // - for (int i = 0; i < count; i++) - { - // - XCOrderBlock *iOB = state.bullishOrderBlocks[i]; - - // - // Validate Order Block ... - bool isValid = - // - cBar.low > iOB.Upper() - // - ; - if (isValid) - { - // - Add( - iOB, - conditions.bullishOBs // - ); - } - } - } - - // - hasBullishOB = conditions.HasBullishOB(); - } - - // - bool hasBearishOB = conditions.HasBearishOB(); - if (!hasBearishOB) - { - // - int count = state.CountBearishOrderBlocks(); - if (IsValidSize(count)) - { - // - for (int i = 0; i < count; i++) - { - // - XCOrderBlock *iOB = state.bearishOrderBlocks[i]; - - // - // Validate Order Block ... - bool isValid = - // - cBar.high < iOB.Lower() - // - ; - if (isValid) - { - // - Add( - iOB, - conditions.bearishOBs // - ); - } - } - } - - // - hasBearishOB = conditions.HasBearishOB(); - } - - // - result = hasBullishOB || - hasBearishOB; - if (!result) - { - return result; - } - - // - int fvgValidationLength = 5; - - // - bool hasBullishFVG = conditions.HasBullishFVG(); - if (!hasBullishFVG) - { - // - if (hasBullishOB) - { - // - int obsCount = conditions.CountBullishOBs(); - int count = state.CountBullishFairValueGaps(); - for (int i = 0; i < obsCount; i++) - { - // - XCOrderBlock *iOB = conditions.bullishOBs[i]; - - // - for (int j = 0; j < count; j++) - { - // - XCFVG *jFVG = state.bullishFairValueGaps[j]; - - // - bool isValid = - // - cBar.low > iOB.Upper() && - cBar.low > jFVG.Upper() && - // - jFVG.From() > iOB.From() && - (((int)(jFVG.From() - iOB.From())) / PeriodSeconds(state.period)) <= fvgValidationLength - // - ; - if (isValid) - { - // - Add( - jFVG, - conditions.bullishFVGs // - ); - } - } - } - } - - // - hasBullishFVG = conditions.HasBullishFVG(); - } - - // - bool hasBearishFVG = conditions.HasBearishFVG(); - if (!hasBearishFVG) - { - // - if (hasBullishOB) - { - // - int obsCount = conditions.CountBearishOBs(); - int count = state.CountBearishFairValueGaps(); - for (int i = 0; i < obsCount; i++) - { - // - XCOrderBlock *iOB = conditions.bearishOBs[i]; - - // - for (int j = 0; j < count; j++) - { - // - XCFVG *jFVG = state.bearishFairValueGaps[j]; - - // - bool isValid = - // - cBar.high < iOB.Lower() && - cBar.high < jFVG.Lower() && - // - jFVG.From() > iOB.From() && - (((int)(jFVG.From() - iOB.From())) / PeriodSeconds(state.period)) <= fvgValidationLength - // - ; - if (isValid) - { - // - Add( - jFVG, - conditions.bearishFVGs // - ); - } - } - } - } - - // - hasBearishFVG = conditions.HasBearishFVG(); - } - - // - result = (hasBullishOB && - hasBullishFVG) || - (hasBearishOB && - hasBearishFVG); - if (!result) - { - return result; - } - - // - // Detect new Peak or new Vale ... - - // - bool isNewPeak = triggerConditions.x121Conditions.isNewPeak; - double peak = triggerConditions.x121Conditions.peaksBuffer[1]; - bool isNewPeakOverLast = triggerConditions.x121Conditions.isNewPeakOverLast; - bool isNewPeakUnderLast = triggerConditions.x121Conditions.isNewPeakUnderLast; - - // - bool isNewVale = triggerConditions.x121Conditions.isNewVale; - double vale = triggerConditions.x121Conditions.valesBuffer[1]; - bool isNewValeOverLast = triggerConditions.x121Conditions.isNewValeOverLast; - bool isNewValeUnderLast = triggerConditions.x121Conditions.isNewValeUnderLast; - - // - result = isNewPeak || - isNewVale; - if (!result) - { - return result; - } - - // - // Detect Setup Conditions based on Peaks or Vales Occurance ... - bool lookupForLong = isNewVale && hasBullishOB && hasBullishFVG; - bool lookupForShort = isNewPeak && hasBearishOB && hasBearishFVG; - result = lookupForLong || - lookupForShort; - if (!result) - { - return result; - } - - // - XCFVG *fvg = NULL; - double fvgZoneValidationRangePercent = 0; - if (lookupForLong) - { - // - // Long Conditions ... - // Vales must be Happens Inside Bullish Fair Value Gaps ... - int count = conditions.CountBullishFVGs(); - for (int i = 0; i < count; i++) - { - // - XCFVG *iFVG = conditions.bullishFVGs[i]; - - // - bool isValid = - // - vale <= iFVG.Upper() && - vale >= iFVG.Lower() && - (fvgZoneValidationRangePercent <= 0 - ? true - : (vale < iFVG.Upper() - (iFVG.RangePercent() * fvgZoneValidationRangePercent))) - // - ; - if (isValid) - { - // - fvg = iFVG; - break; - } - } - - // - isBullish = - // - fvg != NULL && - fvg.IsValid() - // - ; - if (isBullish) - { - conditions.activeFVG = fvg; - } - } - else if (lookupForShort) - { - // - // Short Conditions ... - // Peaks Must be Happens Inside Bearish Fair Value Gaps ... - int count = conditions.CountBearishFVGs(); - for (int i = 0; i < count; i++) - { - // - XCFVG *iFVG = conditions.bearishFVGs[i]; - - // - bool isValid = - // - peak <= iFVG.Upper() && - peak >= iFVG.Lower() && - (fvgZoneValidationRangePercent <= 0 - ? true - : (peak > iFVG.Lower() + (iFVG.RangePercent() * fvgZoneValidationRangePercent))) - // - ; - if (isValid) - { - // - fvg = iFVG; - break; - } - } - - // - isBearish = - // - fvg != NULL && - fvg.IsValid() - // - ; - if (isBearish) - { - conditions.activeFVG = fvg; - } - } - // result = isBullish || isBearish; if (!result) { // - if (lookupForLong) - { - // - conditions.activeFVG = NULL; - Clean(conditions.bullishOBs); - Clean(conditions.bullishFVGs); - } - else if (lookupForShort) - { - // - conditions.activeFVG = NULL; - Clean(conditions.bearishOBs); - Clean(conditions.bearishFVGs); - } + // if (lookupForLong) + // { + // // + // conditions.activeFVG = NULL; + // Clean(conditions.bullishOBs); + // Clean(conditions.bullishFVGs); + // } + // else if (lookupForShort) + // { + // // + // conditions.activeFVG = NULL; + // Clean(conditions.bearishOBs); + // Clean(conditions.bearishFVGs); + // } // return result; @@ -815,10 +442,6 @@ bool DetectX121SMCTestSiganlTrigger( // int loopback = 10; - // - ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_SMPV; - string providerStr = ToString(provider); - // string symbol = _symbol; ENUM_TIMEFRAMES period = _period; @@ -980,658 +603,15 @@ bool DetectX121SMCTestSiganlTrigger( // // Trigger Conditions ... - XCFVG *iFVG = conditions.activeFVG; - result = iFVG != NULL && - iFVG.IsValid(); - if (!result) - { - return result; - } - - // - bool lookupLong = IsBullish(setupDir) && - iFVG.IsBullish(); - bool lookupShort = IsBearish(setupDir) && - iFVG.IsBearish(); - result = lookupLong || - lookupShort; - if (!result) - { - return result; - } - - // - // Check PEAKS and Vales ... - - // - // Trigger ... - - // - // Peaks and Vales ... - double triggerPeak = triggerConditions.x121Conditions.peaksBuffer[1]; - double triggerVale = triggerConditions.x121Conditions.valesBuffer[1]; - - // - bool isTriggerPeakInsideFVG = - // - triggerPeak <= iFVG.Upper() && - triggerPeak >= iFVG.Lower() - // - ; - bool isTriggerValeInsideFVG = - // - triggerVale <= iFVG.Upper() && - triggerVale >= iFVG.Lower() - // - ; - - // - // VWap ... - - // - bool isTriggerVWapFastBullish = triggerConditions.x121Conditions.isVWapFastBullish; - bool isTriggerVWapMidBullish = triggerConditions.x121Conditions.isVWapMidBullish; - bool isTriggerVWapSlowBullish = triggerConditions.x121Conditions.isVWapSlowBullish; - - // - bool isTriggerVWapFastOverMid = triggerConditions.x121Conditions.isVWapFastOverMid; - bool isTriggerVWapMidOverSlow = triggerConditions.x121Conditions.isVWapMidOverSlow; - - // - bool isTriggerVWapFastBearish = triggerConditions.x121Conditions.isVWapFastBearish; - bool isTriggerVWapMidBearish = triggerConditions.x121Conditions.isVWapMidBearish; - bool isTriggerVWapSlowBearish = triggerConditions.x121Conditions.isVWapSlowBearish; - - // - bool isTriggerVWapFastUnderMid = triggerConditions.x121Conditions.isVWapFastUnderMid; - bool isTriggerVWapMidUnderSlow = triggerConditions.x121Conditions.isVWapMidUnderSlow; - - // - bool isTriggerMarketBullish = - // - // State ... - ( - // - (isTriggerVWapFastBullish && - isTriggerVWapMidBullish && - isTriggerVWapSlowBullish) - // - || - // - (isTriggerVWapMidBullish && - isTriggerVWapSlowBullish) - // - ) - // - && - // - // Order ... - ( - // - (isTriggerVWapFastOverMid && - isTriggerVWapMidOverSlow) - // - || - // - isTriggerVWapMidOverSlow - // - ) - // - ; - - // - bool isTriggerMarketBearish = - // - // State ... - ( - // - (isTriggerVWapFastBearish && - isTriggerVWapMidBearish && - isTriggerVWapSlowBearish) - // - || - // - (isTriggerVWapMidBearish && - isTriggerVWapSlowBearish) - // - ) - // - && - // - // Order ... - ( - // - (isTriggerVWapFastUnderMid && - isTriggerVWapMidUnderSlow) - // - || - // - isTriggerVWapMidUnderSlow - // - ) - // - ; - - // - // Decision ... - - // - double decisionPeak = decisionConditions.x121Conditions.peaksBuffer[1]; - double decisionVale = decisionConditions.x121Conditions.valesBuffer[1]; - - // - bool isDecisionPeakInsideFVG = - // - decisionPeak <= iFVG.Upper() && - decisionPeak >= iFVG.Lower() - // - ; - bool isDecisionValeInsideFVG = - // - decisionVale <= iFVG.Upper() && - decisionVale >= iFVG.Lower() - // - ; - - // - // VWap ... - - // - bool isDecisionVWapFastBullish = decisionConditions.x121Conditions.isVWapFastBullish; - bool isDecisionVWapMidBullish = decisionConditions.x121Conditions.isVWapMidBullish; - bool isDecisionVWapSlowBullish = decisionConditions.x121Conditions.isVWapSlowBullish; - - // - bool isDecisionVWapFastOverMid = decisionConditions.x121Conditions.isVWapFastOverMid; - bool isDecisionVWapMidOverSlow = decisionConditions.x121Conditions.isVWapMidOverSlow; - - // - bool isDecisionVWapFastBearish = decisionConditions.x121Conditions.isVWapFastBearish; - bool isDecisionVWapMidBearish = decisionConditions.x121Conditions.isVWapMidBearish; - bool isDecisionVWapSlowBearish = decisionConditions.x121Conditions.isVWapSlowBearish; - - // - bool isDecisionVWapFastUnderMid = decisionConditions.x121Conditions.isVWapFastUnderMid; - bool isDecisionVWapMidUnderSlow = decisionConditions.x121Conditions.isVWapMidUnderSlow; - - // - bool isDecisionMarketBullish = - // - // State ... - ( - // - (isDecisionVWapFastBullish && - isDecisionVWapMidBullish && - isDecisionVWapSlowBullish) - // - || - // - (isDecisionVWapMidBullish && - isDecisionVWapSlowBullish) - // - ) - // - && - // - // Order ... - ( - // - (isDecisionVWapFastOverMid && - isDecisionVWapMidOverSlow) - // - || - // - isDecisionVWapMidOverSlow - // - ) - // - ; - - // - bool isDecisionMarketBearish = - // - // State ... - ( - // - (isDecisionVWapFastBearish && - isDecisionVWapMidBearish && - isDecisionVWapSlowBearish) - // - || - // - (isDecisionVWapMidBearish && - isDecisionVWapSlowBearish) - // - ) - // - && - // - // Order ... - ( - // - (isDecisionVWapFastUnderMid && - isDecisionVWapMidUnderSlow) - // - || - // - isDecisionVWapMidUnderSlow - // - ) - // - ; - - // - // Analyse ... - - // - double analysePeak = analyseConditions.x121Conditions.peaksBuffer[1]; - double analyseVale = analyseConditions.x121Conditions.valesBuffer[1]; - - // - bool isAnalysePeakInsideFVG = - // - analysePeak <= iFVG.Upper() && - analysePeak >= iFVG.Lower() - // - ; - bool isAnalyseValeInsideFVG = - // - analyseVale <= iFVG.Upper() && - analyseVale >= iFVG.Lower() - // - ; - - // - // VWap ... - - // - bool isAnalyseVWapFastBullish = analyseConditions.x121Conditions.isVWapFastBullish; - bool isAnalyseVWapMidBullish = analyseConditions.x121Conditions.isVWapMidBullish; - bool isAnalyseVWapSlowBullish = analyseConditions.x121Conditions.isVWapSlowBullish; - - // - bool isAnalyseVWapFastOverMid = analyseConditions.x121Conditions.isVWapFastOverMid; - bool isAnalyseVWapMidOverSlow = analyseConditions.x121Conditions.isVWapMidOverSlow; - - // - bool isAnalyseVWapFastBearish = analyseConditions.x121Conditions.isVWapFastBearish; - bool isAnalyseVWapMidBearish = analyseConditions.x121Conditions.isVWapMidBearish; - bool isAnalyseVWapSlowBearish = analyseConditions.x121Conditions.isVWapSlowBearish; - - // - bool isAnalyseVWapFastUnderMid = analyseConditions.x121Conditions.isVWapFastUnderMid; - bool isAnalyseVWapMidUnderSlow = analyseConditions.x121Conditions.isVWapMidUnderSlow; - - // - bool isAnalyseMarketBullish = - // - // State ... - ( - // - (isAnalyseVWapFastBullish && - isAnalyseVWapMidBullish && - isAnalyseVWapSlowBullish) - // - || - // - (isAnalyseVWapMidBullish && - isAnalyseVWapSlowBullish) - // - ) - // - && - // - // Order ... - ( - // - (isAnalyseVWapFastOverMid && - isAnalyseVWapMidOverSlow) - // - || - // - isAnalyseVWapMidOverSlow - // - ) - // - ; - - // - bool isAnalyseMarketBearish = - // - // State ... - ( - // - (isAnalyseVWapFastBearish && - isAnalyseVWapMidBearish && - isAnalyseVWapSlowBearish) - // - || - // - (isAnalyseVWapMidBearish && - isAnalyseVWapSlowBearish) - // - ) - // - && - // - // Order ... - ( - // - (isAnalyseVWapFastUnderMid && - isAnalyseVWapMidUnderSlow) - // - || - // - isAnalyseVWapMidUnderSlow - // - ) - // - ; - - // - // Verification ... - - // - double verificationPeak = verificationConditions.x121Conditions.peaksBuffer[1]; - double verificationVale = verificationConditions.x121Conditions.valesBuffer[1]; - - // - bool isVerificationPeakInsideFVG = - // - verificationPeak <= iFVG.Upper() && - verificationPeak >= iFVG.Lower() - // - ; - bool isVerificationValeInsideFVG = - // - verificationVale <= iFVG.Upper() && - verificationVale >= iFVG.Lower() - // - ; - - // - // VWap ... - - // - bool isVerificationVWapFastBullish = verificationConditions.x121Conditions.isVWapFastBullish; - bool isVerificationVWapMidBullish = verificationConditions.x121Conditions.isVWapMidBullish; - bool isVerificationVWapSlowBullish = verificationConditions.x121Conditions.isVWapSlowBullish; - - // - bool isVerificationVWapFastOverMid = verificationConditions.x121Conditions.isVWapFastOverMid; - bool isVerificationVWapMidOverSlow = verificationConditions.x121Conditions.isVWapMidOverSlow; - - // - bool isVerificationVWapFastBearish = verificationConditions.x121Conditions.isVWapFastBearish; - bool isVerificationVWapMidBearish = verificationConditions.x121Conditions.isVWapMidBearish; - bool isVerificationVWapSlowBearish = verificationConditions.x121Conditions.isVWapSlowBearish; - - // - bool isVerificationVWapFastUnderMid = verificationConditions.x121Conditions.isVWapFastUnderMid; - bool isVerificationVWapMidUnderSlow = verificationConditions.x121Conditions.isVWapMidUnderSlow; - - // - bool isVerificationMarketBullish = - // - // State ... - ( - // - (isVerificationVWapFastBullish && - isVerificationVWapMidBullish && - isVerificationVWapSlowBullish) - // - || - // - (isVerificationVWapMidBullish && - isVerificationVWapSlowBullish) - // - ) - // - && - // - // Order ... - ( - // - (isVerificationVWapFastOverMid && - isVerificationVWapMidOverSlow) - // - || - // - isVerificationVWapMidOverSlow - // - ) - // - ; - - // - bool isVerificationMarketBearish = - // - // State ... - ( - // - (isVerificationVWapFastBearish && - isVerificationVWapMidBearish && - isVerificationVWapSlowBearish) - // - || - // - (isVerificationVWapMidBearish && - isVerificationVWapSlowBearish) - // - ) - // - && - // - // Order ... - ( - // - (isVerificationVWapFastUnderMid && - isVerificationVWapMidUnderSlow) - // - || - // - isVerificationVWapMidUnderSlow - // - ) - // - ; - - // - // Consolidation ... - - // - double consolidationPeak = consolidationConditions.x121Conditions.peaksBuffer[1]; - double consolidationVale = consolidationConditions.x121Conditions.valesBuffer[1]; - - // - bool isConsolidationPeakInsideFVG = - // - consolidationPeak <= iFVG.Upper() && - consolidationPeak >= iFVG.Lower() - // - ; - bool isConsolidationValeInsideFVG = - // - consolidationVale <= iFVG.Upper() && - consolidationVale >= iFVG.Lower() - // - ; - - // - // VWap ... - - // - bool isConsolidationVWapFastBullish = consolidationConditions.x121Conditions.isVWapFastBullish; - bool isConsolidationVWapMidBullish = consolidationConditions.x121Conditions.isVWapMidBullish; - bool isConsolidationVWapSlowBullish = consolidationConditions.x121Conditions.isVWapSlowBullish; - - // - bool isConsolidationVWapFastOverMid = consolidationConditions.x121Conditions.isVWapFastOverMid; - bool isConsolidationVWapMidOverSlow = consolidationConditions.x121Conditions.isVWapMidOverSlow; - - // - bool isConsolidationVWapFastBearish = consolidationConditions.x121Conditions.isVWapFastBearish; - bool isConsolidationVWapMidBearish = consolidationConditions.x121Conditions.isVWapMidBearish; - bool isConsolidationVWapSlowBearish = consolidationConditions.x121Conditions.isVWapSlowBearish; - - // - bool isConsolidationVWapFastUnderMid = consolidationConditions.x121Conditions.isVWapFastUnderMid; - bool isConsolidationVWapMidUnderSlow = consolidationConditions.x121Conditions.isVWapMidUnderSlow; - - // - bool isConsolidationMarketBullish = - // - // State ... - ( - // - (isConsolidationVWapFastBullish && - isConsolidationVWapMidBullish && - isConsolidationVWapSlowBullish) - // - || - // - (isConsolidationVWapMidBullish && - isConsolidationVWapSlowBullish) - // - ) - // - && - // - // Order ... - ( - // - (isConsolidationVWapFastOverMid && - isConsolidationVWapMidOverSlow) - // - || - // - isConsolidationVWapMidOverSlow - // - ) - // - ; - - // - bool isConsolidationMarketBearish = - // - // State ... - ( - // - (isConsolidationVWapFastBearish && - isConsolidationVWapMidBearish && - isConsolidationVWapSlowBearish) - // - || - // - (isConsolidationVWapMidBearish && - isConsolidationVWapSlowBearish) - // - ) - // - && - // - // Order ... - ( - // - (isConsolidationVWapFastUnderMid && - isConsolidationVWapMidUnderSlow) - // - || - // - isConsolidationVWapMidUnderSlow - // - ) - // - ; - - // - // Sar ... - - // - bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish; - bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish; - - // - // Summarize Conditions ... - - // - bool isSamePeak = - triggerPeak == decisionPeak && - triggerPeak == analysePeak && - triggerPeak == verificationPeak; - - // - bool isPeaksInsideFVG = - // - isTriggerPeakInsideFVG && - isDecisionPeakInsideFVG && - isAnalysePeakInsideFVG && - isVerificationPeakInsideFVG - // - ; - - // - bool isSameVale = - triggerVale == decisionVale && - triggerVale == analyseVale && - triggerVale == verificationVale; - - // - bool isValesInsideFVG = - // - isTriggerValeInsideFVG && - isDecisionValeInsideFVG && - isAnalyseValeInsideFVG && - isVerificationValeInsideFVG - // - ; - - // - bool isMarketReadyForLong = - // - // !isTriggerMarketBearish && - // !isDecisionMarketBearish && - // !isAnalyseMarketBearish && - isTriggerMarketBullish && - !isVerificationMarketBearish && - !isConsolidationMarketBearish - // - ; - - // - bool isMarketReadyForShort = - // - // !isTriggerMarketBullish && - // !isDecisionMarketBullish && - // !isAnalyseMarketBullish && - isTriggerMarketBearish && - !isVerificationMarketBullish && - !isConsolidationMarketBullish - // - ; // // Create Trigger ... // - isBullish = - // isSameVale && - lookupLong && - isValesInsideFVG && - // isMarketReadyForLong && - isSarSwitchedToBullish && - triggerVale <= iFVG.Upper() && - triggerVale >= iFVG.Lower(); + isBullish = false; // - isBearish = - // isSamePeak && - lookupShort && - isPeaksInsideFVG && - // isMarketReadyForShort && - isSarSwitchedToBearish && - triggerPeak <= iFVG.Upper() && - triggerPeak >= iFVG.Lower(); + isBearish = false; // result = isBullish || @@ -1655,8 +635,8 @@ bool DetectX121SMCTestSiganlTrigger( // conditions.triggerTime = cTime; conditions.sl = isBullish - ? iFVG.Lower() - : iFVG.Upper(); + ? 0 + : 0; conditions.type = isBullish ? X_POSITION_TYPE_LONG : X_POSITION_TYPE_SHORT; diff --git a/X121SMCEA/Signals/x-121.smc.xpvob.signal.class.mq5 b/X121SMCEA/Signals/x-121.smc.xpvob.signal.class.mq5 new file mode 100644 index 00000000..cca39532 --- /dev/null +++ b/X121SMCEA/Signals/x-121.smc.xpvob.signal.class.mq5 @@ -0,0 +1,1664 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 X121 SMC Signal Class +// ------------------------------------------------- +// Name: +// Description: provide all Signalling functions ... +// +// +// Maintainer: +// ------------ +// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) +// +////////////////////////////////////////////////////// +// +// Global Properties ... +#property library +#property copyright "Copyright 2023, SaherElm IT Center" +#property link "https://www.saherelm.ir" +#property version "1.00" +#property strict + +// +// Imports ... +#include "../Classes/x-121.smc.market.cycle.helper.class.mq5" +#include "../Libraries/x-121.smc.lib.mq5" + +// +// Definitions ... +struct X121SMCStrategyXPVOBSignalConditions +{ + // + // Props ... + + // + string symbol; + ENUM_TIMEFRAMES period; + + // + double sl; + ENUM_X_DIRECTION dir; + ENUM_X_POSITION_TYPES type; + + // + // Setup Props ... + + // + datetime setupTime; + datetime triggerTime; + + // + XCOrderBlock *bullishOBs[]; + XCOrderBlock *bearishOBs[]; + + // + XCFVG *activeFVG; + XCFVG *bullishFVGs[]; + XCFVG *bearishFVGs[]; + + // + // Trigger Props ... + + // + // Constructor ... + X121SMCStrategyXPVOBSignalConditions() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleaning Up ... + */ + void Clean() + { + // + sl = 0; + + // + dir = X_DIRECTION_NONE; + type = X_POSITION_TYPE_NONE; + + // + symbol = NULL; + period = NULL; + setupTime = NULL; + triggerTime = NULL; + + // + activeFVG = NULL; + Clean(bullishOBs); + Clean(bearishOBs); + } + + /** + * Check Condition is Setting Up ... + * + * @param dir: ENUM_X_DIRECTION member, Setting Up Direction ... + * + * @return ( bool ) + */ + bool IsSetuped() + { + // + bool result = false; + + // + result = IsValid(setupTime) && + HasDirection(dir); + if (!result) + { + return result; + } + + // + return result; + } + + /** + * Calculate Setup Age ... + * + * @return ( int ) + */ + int GetSetupAge() + { + // + int result = 0; + + // + if (!IsSetuped()) + { + return result; + } + + // + result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period); + + // + return result; + } + + /** + * Detect How we Can Trigger Signal ... + * + * @return ( bool ) + */ + bool CanTrigger() + { + // + bool result = false; + + // + result = + // + sl > 0 && + IsValid(symbol) && + IsValid(period) && + IsValid(triggerTime) && + type != X_POSITION_TYPE_ALL && + type != X_POSITION_TYPE_NONE + // + ; + + // + return result; + } + + // + // Extensions ... + + // + int CountBullishOBs() + { + return ArraySize(bullishOBs); + } + + // + int CountBearishOBs() + { + return ArraySize(bearishOBs); + } + + // + bool HasBullishOB() + { + return IsValidSize(CountBullishOBs()); + } + + // + bool HasBearishOB() + { + return IsValidSize(CountBearishOBs()); + } + + // + int CountBullishFVGs() + { + return ArraySize(bullishFVGs); + } + + // + int CountBearishFVGs() + { + return ArraySize(bearishFVGs); + } + + // + bool HasBullishFVG() + { + return IsValidSize(CountBullishFVGs()); + } + + // + bool HasBearishFVG() + { + return IsValidSize(CountBearishFVGs()); + } + + // +}; + +// +// Extension Functions ... + +// +// Detect Setup Conditions ... +bool DetectX121SMCXPVOBSiganlSetup( + string _symbol, + ENUM_TIMEFRAMES _period, + // + X121SMCStrategyXPVOBSignalConditions &conditions, + // + XC121SMCCycleHelper *triggerCycleHelper, + XC121SMCCycleHelper *decisionCycleHelper, + XC121SMCCycleHelper *analyseCycleHelper, + XC121SMCCycleHelper *verificationCycleHelper, + XC121SMCCycleHelper *consolidationCycleHelper, + XC121SMCCycleHelper *visionCycleHelper + // +) +{ + // + bool result = false; + + // + bool isBullish = false; + bool isBearish = false; + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + string symbol = _symbol; + ENUM_TIMEFRAMES period = _period; + + // + conditions.symbol = symbol; + conditions.period = period; + + // + XOHCL zBar; + result = zBar.Init( + symbol, + period, + zIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL cBar; + result = cBar.Init( + symbol, + period, + cIndex // + ); + if (!result) + { + return result; + } + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + + // + double ll = cBar.FindLowest(9, MODE_LOW); + double hh = cBar.FindHighest(9, MODE_HIGH); + + // + int zoneValidationDivider = 10; + int validPivotRepetition = triggerCycleHelper.mX121Helper + .GetDonChainLength(); + + // + double selectedSL = 0; + + // + // Cycles Conditions ... + + // + // Trigger ... + ENUM_XPOI_EVENTS triggerPoiEvents[]; + ENUM_X_CYCLE_EVENTS triggerCycleEvents[]; + X121SMCCycleConditions triggerConditions; + result = triggerCycleHelper.GetConditions( + triggerCycleEvents, + triggerPoiEvents, + triggerConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Decision ... + ENUM_XPOI_EVENTS decisionPoiEvents[]; + ENUM_X_CYCLE_EVENTS decisionCycleEvents[]; + X121SMCCycleConditions decisionConditions; + result = decisionCycleHelper.GetConditions( + decisionCycleEvents, + decisionPoiEvents, + decisionConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Analyse ... + ENUM_XPOI_EVENTS analysePoiEvents[]; + ENUM_X_CYCLE_EVENTS analyseCycleEvents[]; + X121SMCCycleConditions analyseConditions; + result = analyseCycleHelper.GetConditions( + analyseCycleEvents, + analysePoiEvents, + analyseConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Verification ... + ENUM_XPOI_EVENTS verificationPoiEvents[]; + ENUM_X_CYCLE_EVENTS verificationCycleEvents[]; + X121SMCCycleConditions verificationConditions; + result = verificationCycleHelper.GetConditions( + verificationCycleEvents, + verificationPoiEvents, + verificationConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Consolidation ... + ENUM_XPOI_EVENTS consolidationPoiEvents[]; + ENUM_X_CYCLE_EVENTS consolidationCycleEvents[]; + X121SMCCycleConditions consolidationConditions; + result = consolidationCycleHelper.GetConditions( + consolidationCycleEvents, + consolidationPoiEvents, + consolidationConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Vision ... + ENUM_XPOI_EVENTS visionPoiEvents[]; + ENUM_X_CYCLE_EVENTS visionCycleEvents[]; + X121SMCCycleConditions visionConditions; + result = visionCycleHelper.GetConditions( + visionCycleEvents, + visionPoiEvents, + visionConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Cycles POI States ... + XPOIState triggerState = triggerConditions.state; + XPOIState decisionState = decisionConditions.state; + XPOIState analyseState = analyseConditions.state; + XPOIState verificationState = verificationConditions.state; + XPOIState consolidationState = consolidationConditions.state; + XPOIState visionState = visionConditions.state; + + // + // Detect Imbalances ... + + // + XPOIState state = decisionState; + + // + bool hasBullishOB = conditions.HasBullishOB(); + if (!hasBullishOB) + { + // + int count = state.CountBullishOrderBlocks(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCOrderBlock *iOB = state.bullishOrderBlocks[i]; + + // + // Validate Order Block ... + bool isValid = + // + cBar.low > iOB.Upper() + // + ; + if (isValid) + { + // + Add( + iOB, + conditions.bullishOBs // + ); + } + } + } + + // + hasBullishOB = conditions.HasBullishOB(); + } + + // + bool hasBearishOB = conditions.HasBearishOB(); + if (!hasBearishOB) + { + // + int count = state.CountBearishOrderBlocks(); + if (IsValidSize(count)) + { + // + for (int i = 0; i < count; i++) + { + // + XCOrderBlock *iOB = state.bearishOrderBlocks[i]; + + // + // Validate Order Block ... + bool isValid = + // + cBar.high < iOB.Lower() + // + ; + if (isValid) + { + // + Add( + iOB, + conditions.bearishOBs // + ); + } + } + } + + // + hasBearishOB = conditions.HasBearishOB(); + } + + // + result = hasBullishOB || + hasBearishOB; + if (!result) + { + return result; + } + + // + int fvgValidationLength = 5; + + // + bool hasBullishFVG = conditions.HasBullishFVG(); + if (!hasBullishFVG) + { + // + if (hasBullishOB) + { + // + int obsCount = conditions.CountBullishOBs(); + int count = state.CountBullishFairValueGaps(); + for (int i = 0; i < obsCount; i++) + { + // + XCOrderBlock *iOB = conditions.bullishOBs[i]; + + // + for (int j = 0; j < count; j++) + { + // + XCFVG *jFVG = state.bullishFairValueGaps[j]; + + // + bool isValid = + // + cBar.low > iOB.Upper() && + cBar.low > jFVG.Upper() && + // + jFVG.From() > iOB.From() && + (((int)(jFVG.From() - iOB.From())) / PeriodSeconds(state.period)) <= fvgValidationLength + // + ; + if (isValid) + { + // + Add( + jFVG, + conditions.bullishFVGs // + ); + } + } + } + } + + // + hasBullishFVG = conditions.HasBullishFVG(); + } + + // + bool hasBearishFVG = conditions.HasBearishFVG(); + if (!hasBearishFVG) + { + // + if (hasBullishOB) + { + // + int obsCount = conditions.CountBearishOBs(); + int count = state.CountBearishFairValueGaps(); + for (int i = 0; i < obsCount; i++) + { + // + XCOrderBlock *iOB = conditions.bearishOBs[i]; + + // + for (int j = 0; j < count; j++) + { + // + XCFVG *jFVG = state.bearishFairValueGaps[j]; + + // + bool isValid = + // + cBar.high < iOB.Lower() && + cBar.high < jFVG.Lower() && + // + jFVG.From() > iOB.From() && + (((int)(jFVG.From() - iOB.From())) / PeriodSeconds(state.period)) <= fvgValidationLength + // + ; + if (isValid) + { + // + Add( + jFVG, + conditions.bearishFVGs // + ); + } + } + } + } + + // + hasBearishFVG = conditions.HasBearishFVG(); + } + + // + result = (hasBullishOB && + hasBullishFVG) || + (hasBearishOB && + hasBearishFVG); + if (!result) + { + return result; + } + + // + // Detect new Peak or new Vale ... + + // + bool isNewPeak = triggerConditions.x121Conditions.isNewPeak; + double peak = triggerConditions.x121Conditions.peaksBuffer[1]; + bool isNewPeakOverLast = triggerConditions.x121Conditions.isNewPeakOverLast; + bool isNewPeakUnderLast = triggerConditions.x121Conditions.isNewPeakUnderLast; + + // + bool isNewVale = triggerConditions.x121Conditions.isNewVale; + double vale = triggerConditions.x121Conditions.valesBuffer[1]; + bool isNewValeOverLast = triggerConditions.x121Conditions.isNewValeOverLast; + bool isNewValeUnderLast = triggerConditions.x121Conditions.isNewValeUnderLast; + + // + result = isNewPeak || + isNewVale; + if (!result) + { + return result; + } + + // + // Detect Setup Conditions based on Peaks or Vales Occurance ... + bool lookupForLong = isNewVale && hasBullishOB && hasBullishFVG; + bool lookupForShort = isNewPeak && hasBearishOB && hasBearishFVG; + result = lookupForLong || + lookupForShort; + if (!result) + { + return result; + } + + // + XCFVG *fvg = NULL; + double fvgZoneValidationRangePercent = 0; + if (lookupForLong) + { + // + // Long Conditions ... + // Vales must be Happens Inside Bullish Fair Value Gaps ... + int count = conditions.CountBullishFVGs(); + for (int i = 0; i < count; i++) + { + // + XCFVG *iFVG = conditions.bullishFVGs[i]; + + // + bool isValid = + // + vale <= iFVG.Upper() && + vale >= iFVG.Lower() && + (fvgZoneValidationRangePercent <= 0 + ? true + : (vale < iFVG.Upper() - (iFVG.RangePercent() * fvgZoneValidationRangePercent))) + // + ; + if (isValid) + { + // + fvg = iFVG; + break; + } + } + + // + isBullish = + // + fvg != NULL && + fvg.IsValid() + // + ; + if (isBullish) + { + conditions.activeFVG = fvg; + } + } + else if (lookupForShort) + { + // + // Short Conditions ... + // Peaks Must be Happens Inside Bearish Fair Value Gaps ... + int count = conditions.CountBearishFVGs(); + for (int i = 0; i < count; i++) + { + // + XCFVG *iFVG = conditions.bearishFVGs[i]; + + // + bool isValid = + // + peak <= iFVG.Upper() && + peak >= iFVG.Lower() && + (fvgZoneValidationRangePercent <= 0 + ? true + : (peak > iFVG.Lower() + (iFVG.RangePercent() * fvgZoneValidationRangePercent))) + // + ; + if (isValid) + { + // + fvg = iFVG; + break; + } + } + + // + isBearish = + // + fvg != NULL && + fvg.IsValid() + // + ; + if (isBearish) + { + conditions.activeFVG = fvg; + } + } + + // + result = isBullish || + isBearish; + if (!result) + { + // + if (lookupForLong) + { + // + conditions.activeFVG = NULL; + Clean(conditions.bullishOBs); + Clean(conditions.bullishFVGs); + } + else if (lookupForShort) + { + // + conditions.activeFVG = NULL; + Clean(conditions.bearishOBs); + Clean(conditions.bearishFVGs); + } + + // + return result; + } + + // + conditions.setupTime = cTime; + conditions.dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + return result; +} + +// +// Detect Trigger Conditions ... +bool DetectX121SMCXPVOBSiganlTrigger( + // + X121SMCStrategyXPVOBSignalConditions &conditions, + // + string _symbol, + ENUM_TIMEFRAMES _period, + // + XC121SMCCycleHelper *triggerCycleHelper, + XC121SMCCycleHelper *decisionCycleHelper, + XC121SMCCycleHelper *analyseCycleHelper, + XC121SMCCycleHelper *verificationCycleHelper, + XC121SMCCycleHelper *consolidationCycleHelper, + XC121SMCCycleHelper *visionCycleHelper, + // + int maxAllowedSetupAge = 60 // + // +) +{ + // + bool result = false; + + // + result = conditions.IsSetuped(); + if (!result) + { + return result; + } + + // + datetime setupTime = conditions.setupTime; + ENUM_X_DIRECTION setupDir = conditions.dir; + + // + bool isBullish = false; + bool isBearish = false; + + // + int zIndex = 0; + int cIndex = zIndex + 1; + int pIndex = cIndex + 1; + int ppIndex = pIndex + 1; + + // + int loopback = 10; + + // + string symbol = _symbol; + ENUM_TIMEFRAMES period = _period; + + // + XOHCL zBar; + result = zBar.Init( + symbol, + period, + zIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL cBar; + result = cBar.Init( + symbol, + period, + cIndex // + ); + if (!result) + { + return result; + } + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + + // + double ll = cBar.FindLowest(9, MODE_LOW); + double hh = cBar.FindHighest(9, MODE_HIGH); + + // + int zoneValidationDivider = 10; + int validPivotRepetition = triggerCycleHelper.mX121Helper + .GetDonChainLength(); + + // + double selectedSL = 0; + + // + // Cycles Conditions ... + + // + // Trigger ... + ENUM_XPOI_EVENTS triggerPoiEvents[]; + ENUM_X_CYCLE_EVENTS triggerCycleEvents[]; + X121SMCCycleConditions triggerConditions; + result = triggerCycleHelper.GetConditions( + triggerCycleEvents, + triggerPoiEvents, + triggerConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Decision ... + ENUM_XPOI_EVENTS decisionPoiEvents[]; + ENUM_X_CYCLE_EVENTS decisionCycleEvents[]; + X121SMCCycleConditions decisionConditions; + result = decisionCycleHelper.GetConditions( + decisionCycleEvents, + decisionPoiEvents, + decisionConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Analyse ... + ENUM_XPOI_EVENTS analysePoiEvents[]; + ENUM_X_CYCLE_EVENTS analyseCycleEvents[]; + X121SMCCycleConditions analyseConditions; + result = analyseCycleHelper.GetConditions( + analyseCycleEvents, + analysePoiEvents, + analyseConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Verification ... + ENUM_XPOI_EVENTS verificationPoiEvents[]; + ENUM_X_CYCLE_EVENTS verificationCycleEvents[]; + X121SMCCycleConditions verificationConditions; + result = verificationCycleHelper.GetConditions( + verificationCycleEvents, + verificationPoiEvents, + verificationConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Consolidation ... + ENUM_XPOI_EVENTS consolidationPoiEvents[]; + ENUM_X_CYCLE_EVENTS consolidationCycleEvents[]; + X121SMCCycleConditions consolidationConditions; + result = consolidationCycleHelper.GetConditions( + consolidationCycleEvents, + consolidationPoiEvents, + consolidationConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Vision ... + ENUM_XPOI_EVENTS visionPoiEvents[]; + ENUM_X_CYCLE_EVENTS visionCycleEvents[]; + X121SMCCycleConditions visionConditions; + result = visionCycleHelper.GetConditions( + visionCycleEvents, + visionPoiEvents, + visionConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Cycles POI States ... + XPOIState triggerState = triggerConditions.state; + XPOIState decisionState = decisionConditions.state; + XPOIState analyseState = analyseConditions.state; + XPOIState verificationState = verificationConditions.state; + XPOIState consolidationState = consolidationConditions.state; + XPOIState visionState = visionConditions.state; + + // + // Trigger Conditions ... + XCFVG *iFVG = conditions.activeFVG; + result = iFVG != NULL && + iFVG.IsValid(); + if (!result) + { + return result; + } + + // + bool lookupLong = IsBullish(setupDir) && + iFVG.IsBullish(); + bool lookupShort = IsBearish(setupDir) && + iFVG.IsBearish(); + result = lookupLong || + lookupShort; + if (!result) + { + return result; + } + + // + // Check PEAKS and Vales ... + + // + // Trigger ... + + // + // Peaks and Vales ... + double triggerPeak = triggerConditions.x121Conditions.peaksBuffer[1]; + double triggerVale = triggerConditions.x121Conditions.valesBuffer[1]; + + // + bool isTriggerPeakInsideFVG = + // + triggerPeak <= iFVG.Upper() && + triggerPeak >= iFVG.Lower() + // + ; + bool isTriggerValeInsideFVG = + // + triggerVale <= iFVG.Upper() && + triggerVale >= iFVG.Lower() + // + ; + + // + // VWap ... + + // + bool isTriggerVWapFastBullish = triggerConditions.x121Conditions.isVWapFastBullish; + bool isTriggerVWapMidBullish = triggerConditions.x121Conditions.isVWapMidBullish; + bool isTriggerVWapSlowBullish = triggerConditions.x121Conditions.isVWapSlowBullish; + + // + bool isTriggerVWapFastOverMid = triggerConditions.x121Conditions.isVWapFastOverMid; + bool isTriggerVWapMidOverSlow = triggerConditions.x121Conditions.isVWapMidOverSlow; + + // + bool isTriggerVWapFastBearish = triggerConditions.x121Conditions.isVWapFastBearish; + bool isTriggerVWapMidBearish = triggerConditions.x121Conditions.isVWapMidBearish; + bool isTriggerVWapSlowBearish = triggerConditions.x121Conditions.isVWapSlowBearish; + + // + bool isTriggerVWapFastUnderMid = triggerConditions.x121Conditions.isVWapFastUnderMid; + bool isTriggerVWapMidUnderSlow = triggerConditions.x121Conditions.isVWapMidUnderSlow; + + // + bool isTriggerMarketBullish = + // + // State ... + ( + // + (isTriggerVWapFastBullish && + isTriggerVWapMidBullish && + isTriggerVWapSlowBullish) + // + || + // + (isTriggerVWapMidBullish && + isTriggerVWapSlowBullish) + // + ) + // + && + // + // Order ... + ( + // + (isTriggerVWapFastOverMid && + isTriggerVWapMidOverSlow) + // + || + // + isTriggerVWapMidOverSlow + // + ) + // + ; + + // + bool isTriggerMarketBearish = + // + // State ... + ( + // + (isTriggerVWapFastBearish && + isTriggerVWapMidBearish && + isTriggerVWapSlowBearish) + // + || + // + (isTriggerVWapMidBearish && + isTriggerVWapSlowBearish) + // + ) + // + && + // + // Order ... + ( + // + (isTriggerVWapFastUnderMid && + isTriggerVWapMidUnderSlow) + // + || + // + isTriggerVWapMidUnderSlow + // + ) + // + ; + + // + // Decision ... + + // + double decisionPeak = decisionConditions.x121Conditions.peaksBuffer[1]; + double decisionVale = decisionConditions.x121Conditions.valesBuffer[1]; + + // + bool isDecisionPeakInsideFVG = + // + decisionPeak <= iFVG.Upper() && + decisionPeak >= iFVG.Lower() + // + ; + bool isDecisionValeInsideFVG = + // + decisionVale <= iFVG.Upper() && + decisionVale >= iFVG.Lower() + // + ; + + // + // VWap ... + + // + bool isDecisionVWapFastBullish = decisionConditions.x121Conditions.isVWapFastBullish; + bool isDecisionVWapMidBullish = decisionConditions.x121Conditions.isVWapMidBullish; + bool isDecisionVWapSlowBullish = decisionConditions.x121Conditions.isVWapSlowBullish; + + // + bool isDecisionVWapFastOverMid = decisionConditions.x121Conditions.isVWapFastOverMid; + bool isDecisionVWapMidOverSlow = decisionConditions.x121Conditions.isVWapMidOverSlow; + + // + bool isDecisionVWapFastBearish = decisionConditions.x121Conditions.isVWapFastBearish; + bool isDecisionVWapMidBearish = decisionConditions.x121Conditions.isVWapMidBearish; + bool isDecisionVWapSlowBearish = decisionConditions.x121Conditions.isVWapSlowBearish; + + // + bool isDecisionVWapFastUnderMid = decisionConditions.x121Conditions.isVWapFastUnderMid; + bool isDecisionVWapMidUnderSlow = decisionConditions.x121Conditions.isVWapMidUnderSlow; + + // + bool isDecisionMarketBullish = + // + // State ... + ( + // + (isDecisionVWapFastBullish && + isDecisionVWapMidBullish && + isDecisionVWapSlowBullish) + // + || + // + (isDecisionVWapMidBullish && + isDecisionVWapSlowBullish) + // + ) + // + && + // + // Order ... + ( + // + (isDecisionVWapFastOverMid && + isDecisionVWapMidOverSlow) + // + || + // + isDecisionVWapMidOverSlow + // + ) + // + ; + + // + bool isDecisionMarketBearish = + // + // State ... + ( + // + (isDecisionVWapFastBearish && + isDecisionVWapMidBearish && + isDecisionVWapSlowBearish) + // + || + // + (isDecisionVWapMidBearish && + isDecisionVWapSlowBearish) + // + ) + // + && + // + // Order ... + ( + // + (isDecisionVWapFastUnderMid && + isDecisionVWapMidUnderSlow) + // + || + // + isDecisionVWapMidUnderSlow + // + ) + // + ; + + // + // Analyse ... + + // + double analysePeak = analyseConditions.x121Conditions.peaksBuffer[1]; + double analyseVale = analyseConditions.x121Conditions.valesBuffer[1]; + + // + bool isAnalysePeakInsideFVG = + // + analysePeak <= iFVG.Upper() && + analysePeak >= iFVG.Lower() + // + ; + bool isAnalyseValeInsideFVG = + // + analyseVale <= iFVG.Upper() && + analyseVale >= iFVG.Lower() + // + ; + + // + // VWap ... + + // + bool isAnalyseVWapFastBullish = analyseConditions.x121Conditions.isVWapFastBullish; + bool isAnalyseVWapMidBullish = analyseConditions.x121Conditions.isVWapMidBullish; + bool isAnalyseVWapSlowBullish = analyseConditions.x121Conditions.isVWapSlowBullish; + + // + bool isAnalyseVWapFastOverMid = analyseConditions.x121Conditions.isVWapFastOverMid; + bool isAnalyseVWapMidOverSlow = analyseConditions.x121Conditions.isVWapMidOverSlow; + + // + bool isAnalyseVWapFastBearish = analyseConditions.x121Conditions.isVWapFastBearish; + bool isAnalyseVWapMidBearish = analyseConditions.x121Conditions.isVWapMidBearish; + bool isAnalyseVWapSlowBearish = analyseConditions.x121Conditions.isVWapSlowBearish; + + // + bool isAnalyseVWapFastUnderMid = analyseConditions.x121Conditions.isVWapFastUnderMid; + bool isAnalyseVWapMidUnderSlow = analyseConditions.x121Conditions.isVWapMidUnderSlow; + + // + bool isAnalyseMarketBullish = + // + // State ... + ( + // + (isAnalyseVWapFastBullish && + isAnalyseVWapMidBullish && + isAnalyseVWapSlowBullish) + // + || + // + (isAnalyseVWapMidBullish && + isAnalyseVWapSlowBullish) + // + ) + // + && + // + // Order ... + ( + // + (isAnalyseVWapFastOverMid && + isAnalyseVWapMidOverSlow) + // + || + // + isAnalyseVWapMidOverSlow + // + ) + // + ; + + // + bool isAnalyseMarketBearish = + // + // State ... + ( + // + (isAnalyseVWapFastBearish && + isAnalyseVWapMidBearish && + isAnalyseVWapSlowBearish) + // + || + // + (isAnalyseVWapMidBearish && + isAnalyseVWapSlowBearish) + // + ) + // + && + // + // Order ... + ( + // + (isAnalyseVWapFastUnderMid && + isAnalyseVWapMidUnderSlow) + // + || + // + isAnalyseVWapMidUnderSlow + // + ) + // + ; + + // + // Verification ... + + // + double verificationPeak = verificationConditions.x121Conditions.peaksBuffer[1]; + double verificationVale = verificationConditions.x121Conditions.valesBuffer[1]; + + // + bool isVerificationPeakInsideFVG = + // + verificationPeak <= iFVG.Upper() && + verificationPeak >= iFVG.Lower() + // + ; + bool isVerificationValeInsideFVG = + // + verificationVale <= iFVG.Upper() && + verificationVale >= iFVG.Lower() + // + ; + + // + // VWap ... + + // + bool isVerificationVWapFastBullish = verificationConditions.x121Conditions.isVWapFastBullish; + bool isVerificationVWapMidBullish = verificationConditions.x121Conditions.isVWapMidBullish; + bool isVerificationVWapSlowBullish = verificationConditions.x121Conditions.isVWapSlowBullish; + + // + bool isVerificationVWapFastOverMid = verificationConditions.x121Conditions.isVWapFastOverMid; + bool isVerificationVWapMidOverSlow = verificationConditions.x121Conditions.isVWapMidOverSlow; + + // + bool isVerificationVWapFastBearish = verificationConditions.x121Conditions.isVWapFastBearish; + bool isVerificationVWapMidBearish = verificationConditions.x121Conditions.isVWapMidBearish; + bool isVerificationVWapSlowBearish = verificationConditions.x121Conditions.isVWapSlowBearish; + + // + bool isVerificationVWapFastUnderMid = verificationConditions.x121Conditions.isVWapFastUnderMid; + bool isVerificationVWapMidUnderSlow = verificationConditions.x121Conditions.isVWapMidUnderSlow; + + // + bool isVerificationMarketBullish = + // + // State ... + ( + // + (isVerificationVWapFastBullish && + isVerificationVWapMidBullish && + isVerificationVWapSlowBullish) + // + || + // + (isVerificationVWapMidBullish && + isVerificationVWapSlowBullish) + // + ) + // + && + // + // Order ... + ( + // + (isVerificationVWapFastOverMid && + isVerificationVWapMidOverSlow) + // + || + // + isVerificationVWapMidOverSlow + // + ) + // + ; + + // + bool isVerificationMarketBearish = + // + // State ... + ( + // + (isVerificationVWapFastBearish && + isVerificationVWapMidBearish && + isVerificationVWapSlowBearish) + // + || + // + (isVerificationVWapMidBearish && + isVerificationVWapSlowBearish) + // + ) + // + && + // + // Order ... + ( + // + (isVerificationVWapFastUnderMid && + isVerificationVWapMidUnderSlow) + // + || + // + isVerificationVWapMidUnderSlow + // + ) + // + ; + + // + // Consolidation ... + + // + double consolidationPeak = consolidationConditions.x121Conditions.peaksBuffer[1]; + double consolidationVale = consolidationConditions.x121Conditions.valesBuffer[1]; + + // + bool isConsolidationPeakInsideFVG = + // + consolidationPeak <= iFVG.Upper() && + consolidationPeak >= iFVG.Lower() + // + ; + bool isConsolidationValeInsideFVG = + // + consolidationVale <= iFVG.Upper() && + consolidationVale >= iFVG.Lower() + // + ; + + // + // VWap ... + + // + bool isConsolidationVWapFastBullish = consolidationConditions.x121Conditions.isVWapFastBullish; + bool isConsolidationVWapMidBullish = consolidationConditions.x121Conditions.isVWapMidBullish; + bool isConsolidationVWapSlowBullish = consolidationConditions.x121Conditions.isVWapSlowBullish; + + // + bool isConsolidationVWapFastOverMid = consolidationConditions.x121Conditions.isVWapFastOverMid; + bool isConsolidationVWapMidOverSlow = consolidationConditions.x121Conditions.isVWapMidOverSlow; + + // + bool isConsolidationVWapFastBearish = consolidationConditions.x121Conditions.isVWapFastBearish; + bool isConsolidationVWapMidBearish = consolidationConditions.x121Conditions.isVWapMidBearish; + bool isConsolidationVWapSlowBearish = consolidationConditions.x121Conditions.isVWapSlowBearish; + + // + bool isConsolidationVWapFastUnderMid = consolidationConditions.x121Conditions.isVWapFastUnderMid; + bool isConsolidationVWapMidUnderSlow = consolidationConditions.x121Conditions.isVWapMidUnderSlow; + + // + bool isConsolidationMarketBullish = + // + // State ... + ( + // + (isConsolidationVWapFastBullish && + isConsolidationVWapMidBullish && + isConsolidationVWapSlowBullish) + // + || + // + (isConsolidationVWapMidBullish && + isConsolidationVWapSlowBullish) + // + ) + // + && + // + // Order ... + ( + // + (isConsolidationVWapFastOverMid && + isConsolidationVWapMidOverSlow) + // + || + // + isConsolidationVWapMidOverSlow + // + ) + // + ; + + // + bool isConsolidationMarketBearish = + // + // State ... + ( + // + (isConsolidationVWapFastBearish && + isConsolidationVWapMidBearish && + isConsolidationVWapSlowBearish) + // + || + // + (isConsolidationVWapMidBearish && + isConsolidationVWapSlowBearish) + // + ) + // + && + // + // Order ... + ( + // + (isConsolidationVWapFastUnderMid && + isConsolidationVWapMidUnderSlow) + // + || + // + isConsolidationVWapMidUnderSlow + // + ) + // + ; + + // + // Sar ... + + // + bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish; + bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish; + + // + // Summarize Conditions ... + + // + bool isSamePeak = + triggerPeak == decisionPeak && + triggerPeak == analysePeak && + triggerPeak == verificationPeak; + + // + bool isPeaksInsideFVG = + // + isTriggerPeakInsideFVG && + isDecisionPeakInsideFVG && + isAnalysePeakInsideFVG && + isVerificationPeakInsideFVG + // + ; + + // + bool isSameVale = + triggerVale == decisionVale && + triggerVale == analyseVale && + triggerVale == verificationVale; + + // + bool isValesInsideFVG = + // + isTriggerValeInsideFVG && + isDecisionValeInsideFVG && + isAnalyseValeInsideFVG && + isVerificationValeInsideFVG + // + ; + + // + bool isMarketReadyForLong = + // + // !isTriggerMarketBearish && + // !isDecisionMarketBearish && + // !isAnalyseMarketBearish && + isTriggerMarketBullish && + !isVerificationMarketBearish && + !isConsolidationMarketBearish + // + ; + + // + bool isMarketReadyForShort = + // + // !isTriggerMarketBullish && + // !isDecisionMarketBullish && + // !isAnalyseMarketBullish && + isTriggerMarketBearish && + !isVerificationMarketBullish && + !isConsolidationMarketBullish + // + ; + + // + // Create Trigger ... + + // + isBullish = + // isSameVale && + lookupLong && + isValesInsideFVG && + // isMarketReadyForLong && + isSarSwitchedToBullish && + triggerVale <= iFVG.Upper() && + triggerVale >= iFVG.Lower(); + + // + isBearish = + // isSamePeak && + lookupShort && + isPeaksInsideFVG && + // isMarketReadyForShort && + isSarSwitchedToBearish && + triggerPeak <= iFVG.Upper() && + triggerPeak >= iFVG.Lower(); + + // + result = isBullish || + isBearish; + if (!result) + { + // + // Cleanup Setup Conditions ... + int setupAge = conditions.GetSetupAge(); + if (IsValidSize(setupAge) && + IsValidSize(maxAllowedSetupAge) && + setupAge >= maxAllowedSetupAge) + { + conditions.Clean(); + } + + // + return result; + } + + // + conditions.triggerTime = cTime; + conditions.sl = isBullish + ? iFVG.Lower() + : iFVG.Upper(); + conditions.type = isBullish + ? X_POSITION_TYPE_LONG + : X_POSITION_TYPE_SHORT; + + // + return result; +} + +// \ No newline at end of file diff --git a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 similarity index 94% rename from X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 rename to X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index 2ee7e19d..9e0809d6 100644 --- a/X121SMCEA/Strategy/x-121.smc.test.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -2,7 +2,7 @@ // // SaherElm IT Center MQL5 Class Library // -------------------------------------- -// Name: XCX121SMCTestStrategy +// Name: XCX121SMCStrategy // Description: provides all based classes for use ... // // @@ -25,14 +25,17 @@ // #include "../Classes/x-121.smc.base.strategy.class.mq5" #include "../Classes/x-121.smc.market.cycle.helper.class.mq5" + +// #include "../Signals/x-121.smc.test.signal.class.mq5" +#include "../Signals/x-121.smc.xpvob.signal.class.mq5" // // Definitions ... // // XStrategy Class Implementation(s) ... -class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy +class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // // Public ... @@ -41,7 +44,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Constructor(s) ... - void XCX121SMCTestStrategy( + void XCX121SMCStrategy( // // Base ... string _symbol, // Trading Symbol @@ -54,7 +57,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // // Deconstructur ... - void ~XCX121SMCTestStrategy() + void ~XCX121SMCStrategy() { } @@ -152,39 +155,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy bool hasSignal = false; // - bool hasSMPVSignal = false; - bool hasRJBPVSignal = false; - bool hasVWAPCSignal = false; bool hasTestSignal = false; + bool hasXPVOBSignal = false; // - // X_121_SMC_PROVIDER_SMPV ... - if (!hasSignal) - { - // - // hasSMPVSignal = DetectSamePeaksAndValesSignal(conditions); - // hasSignal = hasSMPVSignal; - } - - // - // X_121_SMC_PROVIDER_RJBPV ... - if (!hasSignal) - { - // // - // hasRJBPVSignal = DetectRJBPVSignal(conditions); - // hasSignal = hasRJBPVSignal; - } - - // - // X_121_SMC_PROVIDER_VWAPC ... - if (!hasSignal) - { - // // - // hasVWAPCSignal = DetectVWAPCSignal(conditions); - // hasSignal = hasVWAPCSignal; - } - - // + // Test Signal ... if (!hasSignal) { // @@ -192,6 +167,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy hasSignal = hasTestSignal; } + // + // XPVOB Signal ... + if (!hasSignal) + { + // + // hasXPVOBSignal = DetectXPVOBSignal(conditions); + // hasSignal = hasXPVOBSignal; + } + // result = hasSignal; if (!result) @@ -278,7 +262,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy signal.time = TimeCurrent(); // - if (hasTestSignal) + // XPVOB Signal ... + if (hasXPVOBSignal) { // // Add Aditionsal Info ... @@ -515,7 +500,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy // Signalling Functions ... // - // TODO: Remove this ... + // Test Signal ... X121SMCStrategyTestSignalConditions mTestConditions; bool DetectTestSignal( X121SMCStrategyConditions &conditions // @@ -536,7 +521,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy datetime cTime = TimeCurrent(); // - ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_SMPV; + ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XTEST; string providerStr = ToString(provider); // @@ -577,39 +562,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy if (isSetuped) { // - XCFVG *iFVG = mTestConditions.activeFVG; - if (iFVG != NULL && iFVG.IsValid()) - { - // - ClearDraws(); - iFVG.To(cTime); - if (IsBullish(setupDir) && iFVG.IsBullish()) - { - // - XCBullishFairValueGapObject *iObj; - bool isCreated = mPOIDrawer.CreateBullishFairValueGap( - iFVG, - iObj // - ); - if (isCreated) - { - AddObjectIfNotExists(iObj); - } - } - else if (IsBearish(setupDir) && iFVG.IsBearish()) - { - // - XCBearishFairValueGapObject *iObj; - bool isCreated = mPOIDrawer.CreateBearishFairValueGap( - iFVG, - iObj // - ); - if (isCreated) - { - AddObjectIfNotExists(iObj); - } - } - } } // @@ -669,6 +621,161 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy return result; } + // + // XPVOB Signal ... + X121SMCStrategyXPVOBSignalConditions mXPVOBConditions; + bool DetectXPVOBSignal( + X121SMCStrategyConditions &conditions // + ) + { + // + bool result = false; + + // + bool isBullish = false; + bool isBearish = false; + + // + string symbol = GetSymbol(); + ENUM_TIMEFRAMES period = GetPeriod(); + + // + datetime cTime = TimeCurrent(); + + // + ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVOB; + string providerStr = ToString(provider); + + // + // Detect Setup Conditions ... + datetime setupTime = mXPVOBConditions.setupTime; + bool isSetuped = mXPVOBConditions.IsSetuped(); + ENUM_X_DIRECTION setupDir = mXPVOBConditions.dir; + if (!isSetuped) + { + // + // Detect Signal Setup ... + isSetuped = DetectX121SMCXPVOBSiganlSetup( + symbol, + period, + mXPVOBConditions, + mTriggerCycleHelper, + mDecisionCycleHelper, + mAnalyseCycleHelper, + mVerificationCycleHelper, + mConsolidationCycleHelper, + mVisionCycleHelper // + ); + + // + result = isSetuped; + if (!result) + { + return result; + } + + // + setupDir = mXPVOBConditions.dir; + setupTime = mXPVOBConditions.setupTime; + } + + // + // Draw Conditions Active FVG ... + if (isSetuped) + { + // + XCFVG *iFVG = mXPVOBConditions.activeFVG; + if (iFVG != NULL && iFVG.IsValid()) + { + // + ClearDraws(); + iFVG.To(cTime); + if (IsBullish(setupDir) && iFVG.IsBullish()) + { + // + XCBullishFairValueGapObject *iObj; + bool isCreated = mPOIDrawer.CreateBullishFairValueGap( + iFVG, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + else if (IsBearish(setupDir) && iFVG.IsBearish()) + { + // + XCBearishFairValueGapObject *iObj; + bool isCreated = mPOIDrawer.CreateBearishFairValueGap( + iFVG, + iObj // + ); + if (isCreated) + { + AddObjectIfNotExists(iObj); + } + } + } + } + + // + // Detect Trigger Conditions ... + bool canTrigger = mXPVOBConditions.CanTrigger(); + datetime triggerTime = mXPVOBConditions.triggerTime; + if (!canTrigger) + { + // + // Detect Signal Trigger ... + canTrigger = DetectX121SMCXPVOBSiganlTrigger( + mXPVOBConditions, + symbol, + period, + mTriggerCycleHelper, + mDecisionCycleHelper, + mAnalyseCycleHelper, + mVerificationCycleHelper, + mConsolidationCycleHelper, + mVisionCycleHelper // + ); + + // + result = canTrigger; + if (!result) + { + return result; + } + + // + triggerTime = mXPVOBConditions.triggerTime; + } + + // + // Check Signal Direction ... + + // + isBullish = IsBullish(setupDir); + isBearish = IsBearish(setupDir); + result = isBullish || + isBearish; + if (!result) + { + return result; + } + + // + // Issues Signal on Conditions ... + conditions.signalDir = setupDir; + conditions.provider = providerStr; + conditions.sl = mXPVOBConditions.sl; + + // + mXPVOBConditions.Clean(); + + // + return result; + } + // // Private ... private: