/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // -------------------------------------- // Name: XCX121SMCStrategy // Description: provides all based classes for use ... // // // 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.base.strategy.class.mq5" #include "../Classes/x-121.smc.market.cycle.helper.class.mq5" // #include "../Signals/x-121.smc.x.signal.lib.mq5" #include "../Signals/x-121.smc.xpz.signal.lib.mq5" #include "../Signals/x-121.smc.xpvt.signal.lib.mq5" #include "../Signals/x-121.smc.xrspvi.signal.lib.mq5" #include "../Signals/x-121.smc.xstrpv.signal.lib.mq5" // // Definitions ... // // XStrategy Class Implementation(s) ... class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // // Public ... public: // // Props ... bool useXSignal; bool useXPZSignal; bool useXPVTSignal; bool useXRSPVISignal; bool useXSTRPVSignal; // // Constructor(s) ... void XCX121SMCStrategy( // // Base ... string _symbol, // Trading Symbol ENUM_TIMEFRAMES _period // Trading TimeFrame ) : XCX121SMCBaseStrategy(_symbol, _period) { InitialHelpers(); } // // Deconstructur ... void ~XCX121SMCStrategy() { // Destroy(); // ArrayFree(mXPZConditionsCollection); ArrayFree(mXRSPVIConditionsCollection); ArrayFree(mXSTRPVConditionsCollection); } // // Getter(s) / Setter(s) ... /** * Get Max Allowed Required POI(s) to Find ... * * @return ( int ) */ int MaxAllowedRequiredPOIs() { return mMaxAllowedRequiredPOIs; } /** * Set Max Allowed Required POI(s) to Find ... * * @param value: number of Required POIs */ void MaxAllowedRequiredPOIs(int value) { // if (value < 10) { value = 10; } // mMaxAllowedRequiredPOIs = value; } // // Overrides Actions ... /** * Destroy All Class Implementations ... */ void Destroy() override { // delete mTriggerCycleHelper; delete mDecisionCycleHelper; delete mAnalyseCycleHelper; delete mVerificationCycleHelper; delete mConsolidationCycleHelper; delete mVisionCycleHelper; } /** * Check Conditions For Signal ... */ bool HasSignal( XSignal &signal, X121SMCStrategyConditions &conditions // ) override { // bool result = false; // signal.Clean(); conditions.Clean(); // int pushers = 0; // double sl = 0; double tp = 0; double risk = 0; double entry = 0; double reward = 0; double r2r = R2R(); string provider = ""; double volume = Volume(); ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; // bool hasLong = false; bool hasShort = false; // double selectedSL = 0; // // Start Calculations ... // // Retrieve Common Data ... string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // datetime cTime = TimeCurrent(); // // Required Value For SL/TP Calculations ... double points = GetPoints(symbol); double pip = GetPipPrice(symbol); double pip2 = 2 * pip; // conditions.time = cTime; conditions.symbol = symbol; conditions.period = period; // // Check Spread for Signalling Conditions ... bool isSpreadPassed = IsSpreadPass(); result = isSpreadPassed; if (!result) { // conditions.Clean(); return result; } // // Detect Signal Conditions ... bool hasSignal = false; // bool hasXSignal = false; bool hasXPZSignal = false; bool hasXPVTSignal = false; bool hasXRSPVISignal = false; bool hasXSTRPVSignal = false; // // X Signal ... if (useXSignal && !hasSignal) { // hasXSignal = DetectXSignal(conditions); hasSignal = hasXSignal; } // // XPZ Signal ... if (useXPZSignal && !hasSignal) { // hasXPZSignal = DetectXPZSignal(conditions); hasSignal = hasXPZSignal; } // // XPVT Signal ... if (useXPVTSignal && !hasSignal) { // hasXPVTSignal = DetectXPVTSignal(conditions); hasSignal = hasXPVTSignal; } // // XRSPVI Signal ... if (useXRSPVISignal && !hasSignal) { // hasXRSPVISignal = DetectXRSPVISignal(conditions); hasSignal = hasXRSPVISignal; } // // XSTRPV Signal ... if (useXSTRPVSignal && !hasSignal) { // hasXSTRPVSignal = DetectXSTRPVSignal(conditions); hasSignal = hasXSTRPVSignal; } // result = hasSignal; if (!result) { // conditions.Clean(); return result; } // // Combine all Signals Conditions ... selectedSL = conditions.sl; provider = conditions.provider; // hasLong = // IsBullish(conditions.signalDir) // ; // hasShort = // IsBearish(conditions.signalDir) // ; // result = hasLong || hasShort; // // Rmove Signal Condition ... if (result) { // // TYPE ... type = hasLong ? POSITION_TYPE_BUY : POSITION_TYPE_SELL; ENUM_X_POSITION_TYPES xType = hasLong ? X_POSITION_TYPE_LONG : X_POSITION_TYPE_SHORT; // entry = GetEntry( conditions.symbol, type // ); // double slAddition = 0; sl = hasLong ? selectedSL - slAddition : selectedSL + slAddition; // // RISK Reward ... risk = hasLong ? entry - sl : sl - entry; reward = risk * r2r; tp = hasLong ? entry + reward : entry - reward; // signal.sl = sl; signal.tp = tp; signal.type = type; signal.mode = mode; signal.entry = entry; signal.volume = volume; signal.symbol = symbol; signal.period = period; signal.pushers = pushers; signal.provider = provider; signal.time = TimeCurrent(); signal.target = conditions.target; // bool canReplaceTarget = signal.target > 0 && (hasLong ? signal.target > signal.tp : signal.target < signal.tp); if (canReplaceTarget) { // signal.tp = conditions.target; signal.target = tp; } // result = PrepareSignal(signal); // if (result) { // // Configure Signal Protector ... // if (useXSTRPVSignal) // { // // // signal.trailSL = false; // signal.fullTPLevel = r2r; // signal.partialCloseOnTPLevel = 2; // signal.partialCloseMultiplier = 0.5; // signal.trailSLStartOnReachTPLevel = 2; // } // // TODO: Remove this ... // XCSignalObject *iObj; // mPOIDrawer.DrawSignal(signal, iObj); // Print(""); } // hasLong = false; hasShort = false; } // return result; } /** * Check for any Guard Actions ... */ bool CheckGuard( X121SMCGuard &guards[], const XPosition &positions[] // ) override { // bool result = false; // Clean(guards); // int count = ArraySize(positions); result = IsValidSize(count); if (!result) { return result; } // // X Guard Detection ... if (useXSignal) { // bool hasGuard = DetectX121SMCXGuards( guards, positions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); } // // XPZ Guard Detection ... if (useXPZSignal) { // bool hasGuard = DetectX121SMCXPZGuards( guards, positions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); } // // XPVT Guard Detection ... if (useXPVTSignal) { // bool hasGuard = DetectX121SMCXPVTGuards( guards, positions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); } // // XSTRPV Guard Detection ... if (useXSTRPVSignal) { // bool hasGuard = DetectX121SMCXSTRPVGuards( guards, positions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); } // // XRSPVI Guard Detection ... if (useXRSPVISignal) { // bool hasGuard = DetectX121SMCXRSPVIGuards( guards, positions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); } // count = ArraySize(guards); result = IsValidSize(count); // return result; } /** * Customize Strategy Identifier ... */ string GetTag() override { return X121SMCStrategyToken; } // // Protected ... protected: // // // Props ... // XC121SMCCycleHelper *mTriggerCycleHelper; XC121SMCCycleHelper *mDecisionCycleHelper; XC121SMCCycleHelper *mAnalyseCycleHelper; XC121SMCCycleHelper *mVerificationCycleHelper; XC121SMCCycleHelper *mConsolidationCycleHelper; XC121SMCCycleHelper *mVisionCycleHelper; // // Actions ... // // Signalling Functions ... // // X Signal ... bool DetectXSignal( X121SMCStrategyConditions &conditions // ) { // bool result = false; // 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_X; string providerStr = ToString(provider); // // Detect Setup Conditions ... datetime setupTime = mXConditions.setupTime; bool isSetuped = mXConditions.IsSetuped(); ENUM_X_DIRECTION setupDir = mXConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... isSetuped = DetectX121SMCXSiganlSetup( symbol, period, mXConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // setupDir = mXConditions.dir; setupTime = mXConditions.setupTime; // // // bool hasPivot = mXConditions.pivotZone.IsValid(); // if (hasPivot) // { // // // XCBaseObject *drawnObjects[]; // int drawnCount = DrawX121SMCXConditions( // mXConditions, // drawnObjects, // mPOIDrawer // // ); // if (IsValidSize(drawnCount)) // { // AddObjectsIfNotExists(drawnObjects); // } // } // if (isSetuped) { // int items = AddX121SMCXConditionsIfNotExists( mXConditions, mXConditionsCollection // ); // mXConditions.Clean(); } } // int conditionsCount = ArraySize(mXConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { return result; } // // Looking For Conditions ... int selectedIndex = 0; X121SMCStrategyXSignalConditions mTmpConditions[]; Copy( mXConditionsCollection, mTmpConditions // ); X121SMCStrategyXSignalConditions 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 = DetectX121SMCXSiganlTrigger( mTmpConditions[i], symbol, period, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // result = canTrigger; if (!result) { // bool isISetuped = mTmpConditions[i].IsSetuped(); if (!isISetuped) { // ArrayRemove( mXConditionsCollection, 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( mXConditionsCollection, 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; // return result; } // // XPZ Signal ... bool DetectXPZSignal( X121SMCStrategyConditions &conditions // ) { // bool result = false; // 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_XPZ; string providerStr = ToString(provider); // // Detect Setup Conditions ... datetime setupTime = mXPZConditions.setupTime; bool isSetuped = mXPZConditions.IsSetuped(); ENUM_X_DIRECTION setupDir = mXPZConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... isSetuped = DetectX121SMCXPZSiganlSetup( symbol, period, mXPZConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // setupDir = mXPZConditions.dir; setupTime = mXPZConditions.setupTime; // if (isSetuped) { // int items = AddX121SMCXPZConditionsIfNotExists( mXPZConditions, mXPZConditionsCollection // ); // mXPZConditions.Clean(); } } // int conditionsCount = ArraySize(mXPZConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { return result; } // // Looking For Conditions ... int selectedIndex = 0; X121SMCStrategyXPZSignalConditions mTmpConditions[]; Copy( mXPZConditionsCollection, mTmpConditions // ); X121SMCStrategyXPZSignalConditions 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 = DetectX121SMCXPZSiganlTrigger( mTmpConditions[i], symbol, period, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // result = canTrigger; if (!result) { // bool isISetuped = mTmpConditions[i].IsSetuped(); if (!isISetuped) { // ArrayRemove( mXPZConditionsCollection, 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( mXPZConditionsCollection, 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; // return result; } // // XPVT Signal ... bool DetectXPVTSignal( X121SMCStrategyConditions &conditions // ) { // bool result = false; // 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_XPVT; string providerStr = ToString(provider); // // Detect Setup Conditions ... datetime setupTime = mXPVTConditions.setupTime; bool isSetuped = mXPVTConditions.IsSetuped(); ENUM_X_DIRECTION setupDir = mXPVTConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... isSetuped = DetectX121SMCXPVTSiganlSetup( symbol, period, mXPVTConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // setupDir = mXPVTConditions.dir; setupTime = mXPVTConditions.setupTime; // if (isSetuped) { // int items = AddX121SMCXPVTConditionsIfNotExists( mXPVTConditions, mXPVTConditionsCollection // ); // mXPVTConditions.Clean(); } } // int conditionsCount = ArraySize(mXPVTConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { return result; } // // Looking For Conditions ... int selectedIndex = 0; X121SMCStrategyXPVTSignalConditions mTmpConditions[]; Copy( mXPVTConditionsCollection, mTmpConditions // ); X121SMCStrategyXPVTSignalConditions 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 = DetectX121SMCXPVTSiganlTrigger( mTmpConditions[i], symbol, period, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // result = canTrigger; if (!result) { // bool isISetuped = mTmpConditions[i].IsSetuped(); if (!isISetuped) { // ArrayRemove( mXPVTConditionsCollection, 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( mXPVTConditionsCollection, 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; // return result; } // // XSTRPV Signal ... bool DetectXSTRPVSignal( X121SMCStrategyConditions &conditions // ) { // bool result = false; // 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_XSTRPV; string providerStr = ToString(provider); // // Detect Setup Conditions ... datetime setupTime = mXSTRPVConditions.setupTime; bool isSetuped = mXSTRPVConditions.IsSetuped(); ENUM_X_DIRECTION setupDir = mXSTRPVConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... isSetuped = DetectX121SMCXSTRPVSiganlSetup( symbol, period, mXSTRPVConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // setupDir = mXSTRPVConditions.dir; setupTime = mXSTRPVConditions.setupTime; // if (isSetuped) { // int items = AddX121SMCXSTRPVConditionsIfNotExists( mXSTRPVConditions, mXSTRPVConditionsCollection // ); // mXSTRPVConditions.Clean(); } } // int conditionsCount = ArraySize(mXSTRPVConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { return result; } // // Looking For Conditions ... int selectedIndex = 0; X121SMCStrategyXSTRPVSignalConditions mTmpConditions[]; Copy( mXSTRPVConditionsCollection, mTmpConditions // ); X121SMCStrategyXSTRPVSignalConditions 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 = DetectX121SMCXSTRPVSiganlTrigger( mTmpConditions[i], symbol, period, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // result = canTrigger; if (!result) { // bool isISetuped = mTmpConditions[i].IsSetuped(); if (!isISetuped) { // ArrayRemove( mXSTRPVConditionsCollection, 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( mXSTRPVConditionsCollection, 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; // return result; } // // XRSPVI Signal ... bool DetectXRSPVISignal( X121SMCStrategyConditions &conditions // ) { // bool result = false; // 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_XRSPVI; string providerStr = ToString(provider); // // Detect Setup Conditions ... datetime setupTime = mXRSPVIConditions.setupTime; bool isSetuped = mXRSPVIConditions.IsSetuped(); ENUM_X_DIRECTION setupDir = mXRSPVIConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... isSetuped = DetectX121SMCXRSPVISiganlSetup( symbol, period, mXRSPVIConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // setupDir = mXRSPVIConditions.dir; setupTime = mXRSPVIConditions.setupTime; // if (isSetuped) { // int items = AddX121SMCXRSPVIConditionsIfNotExists( mXRSPVIConditions, mXRSPVIConditionsCollection // ); // mXRSPVIConditions.Clean(); } } // int conditionsCount = ArraySize(mXRSPVIConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { return result; } // // Looking For Conditions ... int selectedIndex = 0; X121SMCStrategyXRSPVISignalConditions mTmpConditions[]; Copy( mXRSPVIConditionsCollection, mTmpConditions // ); X121SMCStrategyXRSPVISignalConditions 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 = DetectX121SMCXRSPVISiganlTrigger( mTmpConditions[i], symbol, period, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, mVerificationCycleHelper, mConsolidationCycleHelper, mVisionCycleHelper // ); // result = canTrigger; if (!result) { // bool isISetuped = mTmpConditions[i].IsSetuped(); if (!isISetuped) { // ArrayRemove( mXRSPVIConditionsCollection, 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( mXRSPVIConditionsCollection, 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; // return result; } // // Private ... private: // // Props ... // int mMaxAllowedRequiredPOIs; // Max Allowed Required POI(s) to Find ... /** * Initial Required Indicators Helper ... */ void InitialHelpers() { // useXSignal = true; useXPZSignal = false; useXPVTSignal = false; useXRSPVISignal = false; useXSTRPVSignal = false; // string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); // if (mMaxAllowedRequiredPOIs <= 0) { mMaxAllowedRequiredPOIs = 50; } // // Short ... ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period ENUM_TIMEFRAMES scPeriod = NULL; // Time Period // // Medium ... ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period // // Long ... ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period // // Hind ... ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period // // XPV ... X121Inputs x121Inputs; // x121Inputs.Default(); // bool showAll = false; // x121Inputs.showRSI = false; // bool isInited = false; // // XPV ... // x121Inputs.xpvInputs.scMethod = scMethod; x121Inputs.xpvInputs.scPeriod = scPeriod; x121Inputs.xpvInputs.mcMethod = mcMethod; x121Inputs.xpvInputs.mcPeriod = mcPeriod; x121Inputs.xpvInputs.lcMethod = lcMethod; x121Inputs.xpvInputs.lcPeriod = lcPeriod; x121Inputs.xpvInputs.hcMethod = hcMethod; x121Inputs.xpvInputs.hcPeriod = hcPeriod; // x121Inputs.xpvInputs.showSar = showAll || true; x121Inputs.xpvInputs.showPeaks = showAll || true; x121Inputs.xpvInputs.showVales = showAll || true; // // XATR ... x121Inputs.xatrInputs.showATRUpper = showAll || true; x121Inputs.xatrInputs.showATRLower = showAll || true; // x121Inputs.xatrInputs.atrMultiplier = 1.5; x121Inputs.xatrInputs.atrSmoothingMode = X_MA_MODE_EMA; // // XSTR ... x121Inputs.xstrInputs.showStr = true || false; x121Inputs.xstrInputs.showStrUpper = showAll || false; x121Inputs.xstrInputs.showStrLower = showAll || false; // // XCHE ... x121Inputs.xcheInputs.showLE1 = showAll || true; x121Inputs.xcheInputs.showLE2 = showAll || true; x121Inputs.xcheInputs.showSE1 = showAll || true; x121Inputs.xcheInputs.showSE2 = showAll || true; // // XDON ... x121Inputs.xdonInputs.showOpen = showAll || false; x121Inputs.xdonInputs.showClose = showAll || false; x121Inputs.xdonInputs.showLow = showAll || false; x121Inputs.xdonInputs.showHigh = showAll || false; // // XVWAP ... x121Inputs.xvwapInputs.showVWapFast = showAll || false; x121Inputs.xvwapInputs.showVWapMedium = showAll || false; x121Inputs.xvwapInputs.showVWapSlow = showAll || false; // // Initialize Cycle Helpers ... // int requiredPOIS = MaxAllowedRequiredPOIs(); // mTriggerCycleHelper = new XC121SMCCycleHelper(); isInited = mTriggerCycleHelper.Init( symbol, PERIOD_M1, x121Inputs, requiredPOIS // ); // mDecisionCycleHelper = new XC121SMCCycleHelper(); isInited = mDecisionCycleHelper.Init( symbol, PERIOD_M5, x121Inputs, requiredPOIS // ); // mAnalyseCycleHelper = new XC121SMCCycleHelper(); isInited = mAnalyseCycleHelper.Init( symbol, PERIOD_M15, x121Inputs, requiredPOIS // ); // mVerificationCycleHelper = new XC121SMCCycleHelper(); isInited = mVerificationCycleHelper.Init( symbol, PERIOD_M30, x121Inputs, requiredPOIS // ); // mConsolidationCycleHelper = new XC121SMCCycleHelper(); isInited = mConsolidationCycleHelper.Init( symbol, PERIOD_H1, x121Inputs, requiredPOIS // ); // mVisionCycleHelper = new XC121SMCCycleHelper(); isInited = mVisionCycleHelper.Init( symbol, PERIOD_H4, x121Inputs, requiredPOIS // ); } // }; //