diff --git a/Documents/BKP/1/tmp.codes.mq5 b/Documents/BKP/1/tmp.codes.mq5 index aeadfe95..07fd1fbe 100644 --- a/Documents/BKP/1/tmp.codes.mq5 +++ b/Documents/BKP/1/tmp.codes.mq5 @@ -595,3 +595,135 @@ int DrawX121SMCStrategyConditions( // ? conditions.pivotZone.upper // : conditions.pivotZone.lower; } + + +///////////////////////////////////////////////////////////////////////// + + // + // DRAW ... + // + + // + XCBaseObject *drawnObjects[]; + + // + if (hasBullishOrderBlocks) + { + // + for (int i = 0; i < bullishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bullishOBs[i]; + + // + XCBullishOrderBlockObject *iObObj; + bool isCreated = visionCycleHelper + .mPOIDrawer + .CreateBullishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } + } + } + + // + if (hasBearishOrderBlocks) + { + // + for (int i = 0; i < bearishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bearishOBs[i]; + + // + XCBearishOrderBlockObject *iObObj; + bool isCreated = visionCycleHelper + .mPOIDrawer + .CreateBearishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } + } + } + + // + // if (hasOldestBullishOB) + // { + // // + // XCBullishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBullishOrderBlock( + // oldestBullishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasYoungestBullishOB) + // { + // // + // XCBullishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBullishOrderBlock( + // youngestBullishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasOldestBearishOB) + // { + // // + // XCBearishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBearishOrderBlock( + // oldestBearishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasYoungestBearishOB) + // { + // // + // XCBearishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBearishOrderBlock( + // youngestBearishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + +///////////////////////////////////////////////////////////////////////// diff --git a/Documents/BKP/2/tmp.signalling.mq5 b/Documents/BKP/2/tmp.signalling.mq5 new file mode 100644 index 00000000..7b176004 --- /dev/null +++ b/Documents/BKP/2/tmp.signalling.mq5 @@ -0,0 +1,1302 @@ + + // + // 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; + } + +//////////////////////////////////////////////////////// + + + // + // 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; + } + + +///////////////////////////////////////////////////////////////// + + + // + // 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 // + ); + } + +////////////////////////////////////////////////// + +const string X121SMCXPVTToken = "X121XPVT"; +const string X121SMCXRSPVIToken = "X121XRSPVI"; +const string X121SMCXSTRPVToken = "X121XSTRPV"; +const string X121SMCXPZToken = "X121XPZ"; + + // + switch (value) + { + // + case X_121_SMC_PROVIDER_X: + result = X121SMCXToken; + break; + + // + case X_121_SMC_PROVIDER_XPZ: + result = X121SMCXOBPVToken; + break; + + // + case X_121_SMC_PROVIDER_XPVT: + result = X121SMCXPVTToken; + break; + + // + case X_121_SMC_PROVIDER_XRSPVI: + result = X121SMCXRSPVIToken; + break; + + // + case X_121_SMC_PROVIDER_XSTRPV: + result = X121SMCXSTRPVToken; + break; + } + + // + if (Contains(X121SMCXToken, value)) + { + result = X_121_SMC_PROVIDER_X; + } + else if (Contains(X121SMCXOBPVToken, value)) + { + result = X_121_SMC_PROVIDER_XOBPV; + } + else if (Contains(X121SMCXPVTToken, value)) + { + result = X_121_SMC_PROVIDER_XPVT; + } + else if (Contains(X121SMCXRSPVIToken, value)) + { + result = X_121_SMC_PROVIDER_XRSPVI; + } + else if (Contains(X121SMCXSTRPVToken, value)) + { + result = X_121_SMC_PROVIDER_XSTRPV; + } diff --git a/X121SMCEA/Signals/x-121.smc.xpvt.signal.lib.mq5 b/Documents/BKP/2/x-121.smc.xpvt.signal.lib.mq5 similarity index 100% rename from X121SMCEA/Signals/x-121.smc.xpvt.signal.lib.mq5 rename to Documents/BKP/2/x-121.smc.xpvt.signal.lib.mq5 diff --git a/X121SMCEA/Signals/x-121.smc.xpz.signal.lib.mq5 b/Documents/BKP/2/x-121.smc.xpz.signal.lib.mq5 similarity index 100% rename from X121SMCEA/Signals/x-121.smc.xpz.signal.lib.mq5 rename to Documents/BKP/2/x-121.smc.xpz.signal.lib.mq5 diff --git a/X121SMCEA/Signals/x-121.smc.xrspvi.signal.lib.mq5 b/Documents/BKP/2/x-121.smc.xrspvi.signal.lib.mq5 similarity index 100% rename from X121SMCEA/Signals/x-121.smc.xrspvi.signal.lib.mq5 rename to Documents/BKP/2/x-121.smc.xrspvi.signal.lib.mq5 diff --git a/X121SMCEA/Signals/x-121.smc.xstrpv.signal.lib.mq5 b/Documents/BKP/2/x-121.smc.xstrpv.signal.lib.mq5 similarity index 100% rename from X121SMCEA/Signals/x-121.smc.xstrpv.signal.lib.mq5 rename to Documents/BKP/2/x-121.smc.xstrpv.signal.lib.mq5 diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index c09119d8..a8be496f 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -36,10 +36,7 @@ const string X121SMCStrategyToken = "X121SMC"; // const string X121SMCXToken = "X121X"; -const string X121SMCXPZToken = "X121XPZ"; -const string X121SMCXPVTToken = "X121XPVT"; -const string X121SMCXRSPVIToken = "X121XRSPVI"; -const string X121SMCXSTRPVToken = "X121XSTRPV"; +const string X121SMCXOBPVToken = "X121XOBPV"; // // X121 SMC Providers ... @@ -48,10 +45,7 @@ enum ENUM_X_121_SMC_PROVIDERS // X_121_SMC_PROVIDER_NONE, X_121_SMC_PROVIDER_X, - X_121_SMC_PROVIDER_XPZ, - X_121_SMC_PROVIDER_XPVT, - X_121_SMC_PROVIDER_XRSPVI, - X_121_SMC_PROVIDER_XSTRPV, + X_121_SMC_PROVIDER_XOBPV, }; // @@ -711,23 +705,8 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value) break; // - case X_121_SMC_PROVIDER_XPZ: - result = X121SMCXPZToken; - break; - - // - case X_121_SMC_PROVIDER_XPVT: - result = X121SMCXPVTToken; - break; - - // - case X_121_SMC_PROVIDER_XRSPVI: - result = X121SMCXRSPVIToken; - break; - - // - case X_121_SMC_PROVIDER_XSTRPV: - result = X121SMCXSTRPVToken; + case X_121_SMC_PROVIDER_XOBPV: + result = X121SMCXOBPVToken; break; } @@ -758,21 +737,9 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value) { result = X_121_SMC_PROVIDER_X; } - else if (Contains(X121SMCXPZToken, value)) + else if (Contains(X121SMCXOBPVToken, value)) { - result = X_121_SMC_PROVIDER_XPZ; - } - else if (Contains(X121SMCXPVTToken, value)) - { - result = X_121_SMC_PROVIDER_XPVT; - } - else if (Contains(X121SMCXRSPVIToken, value)) - { - result = X_121_SMC_PROVIDER_XRSPVI; - } - else if (Contains(X121SMCXSTRPVToken, value)) - { - result = X_121_SMC_PROVIDER_XSTRPV; + result = X_121_SMC_PROVIDER_XOBPV; } // diff --git a/X121SMCEA/Signals/x-121.smc.x.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.x.signal.lib.mq5 index 034606a7..7bf44dc1 100644 --- a/X121SMCEA/Signals/x-121.smc.x.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.x.signal.lib.mq5 @@ -219,7 +219,7 @@ X121SMCStrategyXSignalConditions mXConditionsCollection[]; // // Detect Setup Conditions ... -bool DetectX121SMCXSiganlSetup( +bool DetectX121SMCXSignalSetup( string _symbol, ENUM_TIMEFRAMES _period, // @@ -1310,7 +1310,7 @@ bool DetectX121SMCXSiganlSetup( // // Detect Trigger Conditions ... -bool DetectX121SMCXSiganlTrigger( +bool DetectX121SMCXSignalTrigger( // X121SMCStrategyXSignalConditions &conditions, // diff --git a/X121SMCEA/Signals/x-121.smc.xobpv.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xobpv.signal.lib.mq5 new file mode 100644 index 00000000..9009eb8c --- /dev/null +++ b/X121SMCEA/Signals/x-121.smc.xobpv.signal.lib.mq5 @@ -0,0 +1,1724 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 X121 SMC Signal Class +// ------------------------------------------------- +// Name: X +// 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 "../../Libraries/x-trade.lib" +#include "../Classes/x-121.smc.market.cycle.helper.class.mq5" +#include "../Libraries/x-121.smc.lib.mq5" + +// +// Definitions ... +struct X121SMCStrategyXOBPVSignalConditions +{ + // + // Props ... + + // + string symbol; + ENUM_TIMEFRAMES period; + + // + double sl; + double target; + ENUM_X_DIRECTION dir; + ENUM_X_POSITION_TYPES type; + + // + // Setup Props ... + + // + datetime setupTime; + datetime triggerTime; + + // + double pivot; + double point; + + // + XCOrderBlock *bullishOBs[]; + XCOrderBlock *bearishOBs[]; + + // + // Constructor ... + X121SMCStrategyXOBPVSignalConditions() + { + Clean(); + } + + // + // Tools ... + + /** + * Cleaning Up ... + */ + void Clean() + { + // + sl = 0; + target = 0; + + // + dir = X_DIRECTION_NONE; + type = X_POSITION_TYPE_NONE; + + // + symbol = NULL; + period = NULL; + setupTime = NULL; + triggerTime = NULL; + + // + ExtensionClean(); + } + + /** + * 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 ... + + /** + * Clean Additional Properties ... + */ + void ExtensionClean() + { + // + pivot = 0; + point = 0; + + // + Clean(bullishOBs); + Clean(bearishOBs); + + // + } + + // + int CountBullishOBs() + { + return ArraySize(bullishOBs); + } + + // + bool HasBullishOBs() + { + return IsValidSize(CountBullishOBs()); + } + + // + int CountBearishOBs() + { + return ArraySize(bearishOBs); + } + + // + bool HasBearishOBs() + { + return IsValidSize(CountBearishOBs()); + } + + // +}; + +// +// Signaller Data Sources ... +X121SMCStrategyXOBPVSignalConditions mXOBPVConditions; +X121SMCStrategyXOBPVSignalConditions mXOBPVConditionsCollection[]; + +// +// Extension Functions ... + +// +// Detect Setup Conditions ... +bool DetectX121SMCXOBPVSignalSetup( + string _symbol, + ENUM_TIMEFRAMES _period, + // + X121SMCStrategyXOBPVSignalConditions &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 = decisionCycleHelper.GetBar( + zBar, + zIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL cBar; + result = decisionCycleHelper.GetBar( + cBar, + cIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL pBar; + result = decisionCycleHelper.GetBar( + pBar, + pIndex // + ); + if (!result) + { + return result; + } + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + int swingLoopback = 3; + double ll = cBar.FindLowest(swingLoopback, MODE_LOW); + double hh = cBar.FindHighest(swingLoopback, MODE_HIGH); + double llDown = cBar.FindLowesttDown(swingLoopback); + double hhUp = cBar.FindHighestUp(swingLoopback); + + // + // 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; + + // + // Cycle X121Conditions ... + X121Conditions triggerXOBPVConditions = triggerConditions.x121Conditions; + X121Conditions decisionXOBPVConditions = decisionConditions.x121Conditions; + X121Conditions analyseXOBPVConditions = analyseConditions.x121Conditions; + X121Conditions verificationXOBPVConditions = verificationConditions.x121Conditions; + X121Conditions consolidationXOBPVConditions = consolidationConditions.x121Conditions; + X121Conditions visionXOBPVConditions = visionConditions.x121Conditions; + + // + // Setup Conditions ... + + // + // Detect Trend ... + + // + // Consolidation ... + ENUM_X_DIRECTION consolidationTrendDir; + bool hasConsolidationTrend = + consolidationCycleHelper + .DetectMarketStructure( + consolidationTrendDir // + ); + bool hasConsolidationBullishTrend = + hasConsolidationTrend && + IsBullish(consolidationTrendDir); + bool hasConsolidationBearishTrend = + hasConsolidationTrend && + IsBearish(consolidationTrendDir); + + // + // Verification ... + ENUM_X_DIRECTION verificationTrendDir; + bool hasVerificationTrend = + verificationCycleHelper + .DetectMarketStructure( + verificationTrendDir // + ); + bool hasVerificationBullishTrend = + hasVerificationTrend && + IsBullish(verificationTrendDir); + bool hasVerificationBearishTrend = + hasVerificationTrend && + IsBearish(verificationTrendDir); + + // + // Analyse ... + ENUM_X_DIRECTION analyseTrendDir; + bool hasAnalyseTrend = + analyseCycleHelper + .DetectMarketStructure( + analyseTrendDir // + ); + bool hasAnalyseBullishTrend = + hasAnalyseTrend && + IsBullish(analyseTrendDir); + bool hasAnalyseBearishTrend = + hasAnalyseTrend && + IsBearish(analyseTrendDir); + + // + // Decision ... + ENUM_X_DIRECTION decisionTrendDir; + bool hasDecisionTrend = + decisionCycleHelper + .DetectMarketStructure( + decisionTrendDir // + ); + bool hasDecisionBullishTrend = + hasDecisionTrend && + IsBullish(decisionTrendDir); + bool hasDecisionBearishTrend = + hasDecisionTrend && + IsBearish(decisionTrendDir); + + // + // Detect Bar State ... + + // + // PinBar ... + ENUM_X_DIRECTION cBarPinDir; + bool isCBarPin = decisionCycleHelper + .mBarAnalyser + .IsPinBar( + cBar, + cBarPinDir, + 1 // + ); + bool isCBarBullishPin = + isCBarPin && + IsBullish(cBarPinDir); + bool isCBarBearishPin = + isCBarPin && + IsBearish(cBarPinDir); + + // + // Engulf ... + ENUM_X_DIRECTION cBarEngulfDir; + bool isCBarEngulfed = decisionCycleHelper + .mBarAnalyser + .IsEngulfBar( + cBar, + cBarEngulfDir, + 0 // Extended ... + ); + bool isCBarBullishEngulfed = + isCBarEngulfed && + IsBullish(cBarEngulfDir); + bool isCBarBearishEngulfed = + isCBarEngulfed && + IsBearish(cBarEngulfDir); + + // + // Momentum ... + ENUM_X_DIRECTION cBarMomentumDir; + bool isCBarMomentum = decisionCycleHelper + .mBarAnalyser + .IsMomentumBar( + cBar, + cBarMomentumDir, + 0 // Extended ... + ); + bool isCBarBullishMomentum = + isCBarMomentum && + IsBullish(cBarMomentumDir); + bool isCBarBearishMomentum = + isCBarMomentum && + IsBearish(cBarMomentumDir); + + // + // Reject ... + ENUM_X_DIRECTION cBarRejectDir; + bool isCBarRejected = decisionCycleHelper + .mBarAnalyser + .IsRejectionBar( + cBar, + cBarRejectDir, + 0 // Extended ... + ); + bool isCBarBullishRejected = + isCBarRejected && + IsBullish(cBarRejectDir); + bool isCBarBearishRejected = + isCBarRejected && + IsBearish(cBarRejectDir); + + // + // Pull Back ... + ENUM_X_DIRECTION cBarPullbackDir; + bool isCBarPullbacked = + decisionCycleHelper + .mBarAnalyser + .HasPullBack( + cBarPullbackDir, + cBar // + ); + bool isCBarBullishPullbacked = + isCBarPullbacked && + IsBullish(cBarPullbackDir); + bool isCBarBearishPullbacked = + isCBarPullbacked && + IsBearish(cBarPullbackDir); + + // + // HH/LL Break ... + + // + bool isCBarBreaksUpHH = IsBarBreak( + hh, + X_DIRECTION_BULLISH, + cBar // + ); + + // + bool isCBarBreaksDownLL = IsBarBreak( + hh, + X_DIRECTION_BEARISH, + cBar // + ); + + // + // Bars Pattern and Power and Pressures ... + + // + bool hasCBarBullishPattern = + decisionCycleHelper + .mBarAnalyser + .HasBullishPattern( + cBar, + 2 // + ); + + // + bool hasCBarBearishPattern = + decisionCycleHelper + .mBarAnalyser + .HasBearishPattern( + cBar, + 2 // + ); + + // + bool isCBarHasBullishPower = + decisionCycleHelper + .mBarAnalyser + .HasBullishPower( + cBar, + 2 // + ); + + // + bool isCBarHasBearishPower = + decisionCycleHelper + .mBarAnalyser + .HasBearishPower( + cBar, + 2 // + ); + + // + bool isCBarHasBullishPressure = + decisionCycleHelper + .mBarAnalyser + .HasBullishPressure( + cBar, + 2 // + ); + + // + bool isCBarHasBearishPressure = + decisionCycleHelper + .mBarAnalyser + .HasBearishPressure( + cBar, + 2 // + ); + + // + // Bar Checking Summary ... + + // + // Bullish ... + bool isCBarBullishFormed = + // + ( + // + hasCBarBullishPattern && + isCBarHasBullishPower && + isCBarHasBullishPressure + // + ) + // + || + // + ( + // + isCBarBullishPin || + isCBarBreaksUpHH || + isCBarBullishEngulfed || + isCBarBullishMomentum || + isCBarBullishRejected + // + ) + // + ; + + // + // Bearish ... + bool isCBarBearishFormed = + // + ( + // + hasCBarBearishPattern && + isCBarHasBearishPower && + isCBarHasBearishPressure + // + ) + // + || + // + ( + // + isCBarBearishPin || + isCBarBreaksDownLL || + isCBarBearishEngulfed || + isCBarBearishMomentum || + isCBarBearishRejected + // + ) + // + ; + + // + // Detect Order Block ... + + // + bool hasBullishOrderBlocks = conditions.HasBullishOBs(); + int bullishOrderBlocksCount = conditions.CountBullishOBs(); + + // + bool hasBearishOrderBlocks = conditions.HasBearishOBs(); + int bearishOrderBlocksCount = conditions.CountBearishOBs(); + + // + bool hasOrderBlocks = hasBullishOrderBlocks && + hasBearishOrderBlocks; + if (!hasOrderBlocks) + { + // + XCOrderBlock *bullishOBs[]; + XCOrderBlock *bearishOBs[]; + bool hasOrderBlocks = visionCycleHelper.DetectOrderBlocks( + bullishOBs, + bearishOBs // + ); + + // + if (!hasBullishOrderBlocks) + { + // + Copy( + bullishOBs, + conditions.bullishOBs // + ); + } + + // + if (!hasBearishOrderBlocks) + { + // + Copy( + bearishOBs, + conditions.bearishOBs // + ); + } + + // + hasBullishOrderBlocks = conditions.HasBullishOBs(); + bullishOrderBlocksCount = conditions.CountBullishOBs(); + + // + hasBearishOrderBlocks = conditions.HasBearishOBs(); + bearishOrderBlocksCount = conditions.CountBearishOBs(); + } + + // + bool hasOldestBullishOB = false; + bool hasYoungestBullishOB = false; + XCOrderBlock *oldestBullishOB = NULL; + XCOrderBlock *youngestBullishOB = NULL; + if (hasBullishOrderBlocks) + { + // + XCZone *zones[]; + bool isConverted = ToZone( + conditions.bullishOBs, + zones // + ); + + // + int oldestIDX = GetOldest(zones); + hasOldestBullishOB = IsValidIndex(oldestIDX); + if (hasOldestBullishOB) + { + oldestBullishOB = conditions.bullishOBs[oldestIDX]; + } + + // + int youngestIDX = GetYoungest(zones); + hasYoungestBullishOB = IsValidIndex(youngestIDX); + if (hasYoungestBullishOB) + { + youngestBullishOB = conditions.bullishOBs[youngestIDX]; + } + } + + // + bool hasOldestBearishOB = false; + bool hasYoungestBearishOB = false; + XCOrderBlock *oldestBearishOB = NULL; + XCOrderBlock *youngestBearishOB = NULL; + if (hasBearishOrderBlocks) + { + // + XCZone *zones[]; + bool isConverted = ToZone( + conditions.bearishOBs, + zones // + ); + + // + int oldestIDX = GetOldest(zones); + hasOldestBearishOB = IsValidIndex(oldestIDX); + if (hasOldestBearishOB) + { + oldestBearishOB = conditions.bearishOBs[oldestIDX]; + } + + // + int youngestIDX = GetYoungest(zones); + hasYoungestBearishOB = IsValidIndex(youngestIDX); + if (hasYoungestBearishOB) + { + youngestBearishOB = conditions.bearishOBs[youngestIDX]; + } + } + + // + bool hasPriceInsideOB = false; + XCOrderBlock *priceInsideOB = NULL; + + // + if (!hasPriceInsideOB && + hasBullishOrderBlocks) + { + // + for (int i = 0; i < bullishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bullishOBs[i]; + + // + bool isInside = IsPriceInsideZone( + decisionXOBPVConditions.valesBuffer[1], + (XCZone *)iOb // + ); + if (isInside) + { + // + hasPriceInsideOB = true; + priceInsideOB = iOb; + break; + } + } + } + + // + if (!hasPriceInsideOB && + hasBearishOrderBlocks) + { + // + for (int i = 0; i < bearishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bearishOBs[i]; + + // + bool isInside = IsPriceInsideZone( + decisionXOBPVConditions.peaksBuffer[1], + (XCZone *)iOb // + ); + if (isInside) + { + // + hasPriceInsideOB = true; + priceInsideOB = iOb; + break; + } + } + } + + // + XStateZones obState; + bool hasOBState = false; + XOHCL priceInsideOBBreakerBar; + if (hasPriceInsideOB) + { + // + XOHCL toBar; + XOHCL fromBar; + ENUM_X_DIRECTION forDir = + priceInsideOB.IsBullish() + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + bool hasBreakerBar = HasBreakerBar( + toBar, + fromBar, + priceInsideOBBreakerBar, + forDir, + priceInsideOB.GetSymbol(), + priceInsideOB.GetPeriod(), + (XCZone *)priceInsideOB // + ); + if (hasBreakerBar) + { + // + CalculateStateZones( + obState, + consolidationState, + priceInsideOB.Upper(), + priceInsideOB.Lower(), + priceInsideOBBreakerBar.time // + ); + } + + // + hasOBState = obState.IsValid(); + } + + // + bool isSameCyclesPeak = + // + triggerXOBPVConditions.peaksBuffer[1] == decisionXOBPVConditions.peaksBuffer[1] && + decisionXOBPVConditions.peaksBuffer[1] == analyseXOBPVConditions.peaksBuffer[1] && + analyseXOBPVConditions.peaksBuffer[1] == verificationXOBPVConditions.peaksBuffer[1] && + verificationXOBPVConditions.peaksBuffer[1] == consolidationXOBPVConditions.peaksBuffer[1] + // + ; + + // + bool isSameCyclesVale = + // + triggerXOBPVConditions.valesBuffer[1] == decisionXOBPVConditions.valesBuffer[1] && + decisionXOBPVConditions.valesBuffer[1] == analyseXOBPVConditions.valesBuffer[1] && + analyseXOBPVConditions.valesBuffer[1] == verificationXOBPVConditions.valesBuffer[1] && + verificationXOBPVConditions.valesBuffer[1] == consolidationXOBPVConditions.valesBuffer[1] + // + ; + + // + bool hasSameCyclesPV = + hasOBState && + hasPriceInsideOB && + (isSameCyclesPeak || + isSameCyclesVale); + + // + // DRAW ... + // + + // + XCBaseObject *drawnObjects[]; + + // + if (hasBullishOrderBlocks) + { + // + for (int i = 0; i < bullishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bullishOBs[i]; + + // + XCBullishOrderBlockObject *iObObj; + bool isCreated = visionCycleHelper + .mPOIDrawer + .CreateBullishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } + } + } + + // + if (hasBearishOrderBlocks) + { + // + for (int i = 0; i < bearishOrderBlocksCount; i++) + { + // + XCOrderBlock *iOb = conditions.bearishOBs[i]; + + // + XCBearishOrderBlockObject *iObObj; + bool isCreated = visionCycleHelper + .mPOIDrawer + .CreateBearishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } + } + } + + // + // if (hasOldestBullishOB) + // { + // // + // XCBullishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBullishOrderBlock( + // oldestBullishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasYoungestBullishOB) + // { + // // + // XCBullishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBullishOrderBlock( + // youngestBullishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasOldestBearishOB) + // { + // // + // XCBearishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBearishOrderBlock( + // oldestBearishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // // + // if (hasYoungestBearishOB) + // { + // // + // XCBearishOrderBlockObject *iObj; + // bool isCreated = visionCycleHelper + // .mPOIDrawer + // .CreateBearishOrderBlock( + // youngestBearishOB, + // iObj // + // ); + // if (isCreated) + // { + // } + // } + + // + if (hasPriceInsideOB) + { + // + bool isBullish = priceInsideOB.IsBullish(); + + // + bool isCreated = false; + XCBaseObject *iObObj = NULL; + if (isBullish) + { + // + XCBullishOrderBlockObject *iObj; + isCreated = visionCycleHelper + .mPOIDrawer + .CreateBullishOrderBlock( + priceInsideOB, + iObj // + ); + + // + if (isCreated) + { + // + iObj.ZoneColor(clrYellow); + iObObj = (XCBaseObject *)iObj; + } + } + else + { + // + XCBearishOrderBlockObject *iObj; + isCreated = visionCycleHelper + .mPOIDrawer + .CreateBearishOrderBlock( + priceInsideOB, + iObj // + ); + + // + if (isCreated) + { + // + iObj.ZoneColor(clrOrangeRed); + iObObj = (XCBaseObject *)iObj; + } + } + + // + if (isCreated) + { + // + Add( + iObObj, + drawnObjects // + ); + } + } + + // + if (hasOBState) + { + // + XCBaseObject *stateObjects[]; + int stateObjectsCount = consolidationCycleHelper + .mPOIDrawer + .DrawStateZones( + obState, + stateObjects // + ); + if (IsValidSize(stateObjectsCount)) + { + // + Copy( + stateObjects, + drawnObjects, + false // + ); + } + } + + // + int drawnCount = ArraySize(drawnObjects); + if (IsValidSize(drawnCount)) + { + } + + // + // + // + + // + // Summarize Conditions ... + + // + bool isCondition1Bullish = + // + hasSameCyclesPV && + isCBarBullishFormed && + priceInsideOB.IsBullish() && + // + (decisionXOBPVConditions.isBreakedUpPrevSar || + decisionXOBPVConditions.isBreakedUpPrevStr || + decisionXOBPVConditions.isVWapMaxBreakedUp || + decisionXOBPVConditions.isBreakedUpPrevCheMax || + decisionXOBPVConditions.isBreakedUpPrevAtrLower) && + // + (decisionXOBPVConditions.isSarSwitchedToBullish || + decisionXOBPVConditions.isStrSwitchedToBullish || + decisionXOBPVConditions.isCheSwitchedToBullish || + decisionXOBPVConditions.isVWapSwitchedToBullishState || + decisionXOBPVConditions.isVWapSwitchedToBullishOrdered) + // + ; + + // + bool isCondition1Bearish = + // + hasSameCyclesPV && + isCBarBearishFormed && + priceInsideOB.IsBearish() && + // + (decisionXOBPVConditions.isBreakedDownPrevSar || + decisionXOBPVConditions.isBreakedDownPrevStr || + decisionXOBPVConditions.isVWapMinBreakedDown || + decisionXOBPVConditions.isBreakedDownPrevCheMin || + decisionXOBPVConditions.isBreakedDownPrevAtrUpper) && + // + (decisionXOBPVConditions.isSarSwitchedToBearish || + decisionXOBPVConditions.isStrSwitchedToBearish || + decisionXOBPVConditions.isCheSwitchedToBearish || + decisionXOBPVConditions.isVWapSwitchedToBearishState || + decisionXOBPVConditions.isVWapSwitchedToBearishOrdered) + // + ; + + // + bool hasCondition1 = isCondition1Bullish || + isCondition1Bearish; + if (hasCondition1) + { + // + ENUM_X_DIRECTION pzDir = + isCondition1Bullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + double point = GetEntry( + conditions.symbol, + pzDir // + ); + + // + // Manipulate Conditions Point ... + + // + conditions.point = point; + + // + // Manipulate Conditions Pivot ... + + // + conditions.pivot = + isCondition1Bullish + ? priceInsideOB.Upper() + : priceInsideOB.Lower(); + } + + // + // + // + + // + isBullish = + // + isCondition1Bullish + // + ; + + // + isBearish = + // + isCondition1Bearish + // + ; + + // + result = isBullish || + isBearish; + if (!result) + { + // + // Cleanup Arrays ... + ArrayFree(triggerPoiEvents); + ArrayFree(triggerCycleEvents); + ArrayFree(decisionPoiEvents); + ArrayFree(decisionCycleEvents); + ArrayFree(analysePoiEvents); + ArrayFree(analyseCycleEvents); + ArrayFree(verificationPoiEvents); + ArrayFree(verificationCycleEvents); + ArrayFree(consolidationPoiEvents); + ArrayFree(consolidationCycleEvents); + ArrayFree(visionPoiEvents); + ArrayFree(visionCycleEvents); + + // + return result; + } + + // + conditions.setupTime = cTime; + conditions.dir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + // Cleanup Arrays ... + ArrayFree(triggerPoiEvents); + ArrayFree(triggerCycleEvents); + ArrayFree(decisionPoiEvents); + ArrayFree(decisionCycleEvents); + ArrayFree(analysePoiEvents); + ArrayFree(analyseCycleEvents); + ArrayFree(verificationPoiEvents); + ArrayFree(verificationCycleEvents); + ArrayFree(consolidationPoiEvents); + ArrayFree(consolidationCycleEvents); + ArrayFree(visionPoiEvents); + ArrayFree(visionCycleEvents); + + // + return result; +} + +// +// Detect Trigger Conditions ... +bool DetectX121SMCXOBPVSignalTrigger( + // + X121SMCStrategyXOBPVSignalConditions &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 = IsBullish(setupDir); + bool isBearish = IsBearish(setupDir); + + // + 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 = decisionCycleHelper.GetBar( + zBar, + zIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL cBar; + result = decisionCycleHelper.GetBar( + cBar, + cIndex // + ); + if (!result) + { + return result; + } + + // + XOHCL pBar; + result = decisionCycleHelper.GetBar( + pBar, + pIndex // + ); + if (!result) + { + return result; + } + + // + double ask = GetAsk(symbol); + double bid = GetBid(symbol); + datetime cTime = TimeCurrent(); + double points = GetPoints(symbol); + + // + int swingLoopback = 9; + double ll = cBar.FindLowest(swingLoopback, MODE_LOW); + double hh = cBar.FindHighest(swingLoopback, MODE_HIGH); + double llDown = cBar.FindLowesttDown(swingLoopback); + double hhUp = cBar.FindHighestUp(swingLoopback); + + // + // Cycles Conditions ... + + // + // Decision ... + ENUM_XPOI_EVENTS decisionPoiEvents[]; + ENUM_X_CYCLE_EVENTS decisionCycleEvents[]; + X121SMCCycleConditions decisionConditions; + result = decisionCycleHelper.GetConditions( + decisionCycleEvents, + decisionPoiEvents, + decisionConditions, + zIndex, + loopback // + ); + if (!result) + { + return result; + } + + // + // Cycles POI States ... + XPOIState decisionState = decisionConditions.state; + + // + // Cycle X121Conditions ... + X121Conditions decisionXOBPVConditions = decisionConditions.x121Conditions; + + // + // Trigger Conditions ... + + // + // Slopes ... + + // + bool isRsiSlopeBullish = decisionXOBPVConditions.isRsiSlopeBullish; + bool isStrSlopeBullish = decisionXOBPVConditions.isStrSlopeBullish; + bool isAtrUpperSlopeBullish = decisionXOBPVConditions.isAtrUpperSlopeBullish; + bool isAtrLowerSlopeBullish = decisionXOBPVConditions.isAtrLowerSlopeBullish; + bool isVwapFastSlopeBullish = decisionXOBPVConditions.isVwapFastSlopeBullish; + bool isVwapMidSlopeBullish = decisionXOBPVConditions.isVwapMidSlopeBullish; + bool isVwapSlowSlopeBullish = decisionXOBPVConditions.isVwapSlowSlopeBullish; + + // + bool isRsiSlopeBearish = decisionXOBPVConditions.isRsiSlopeBearish; + bool isStrSlopeBearish = decisionXOBPVConditions.isStrSlopeBearish; + bool isAtrUpperSlopeBearish = decisionXOBPVConditions.isAtrUpperSlopeBearish; + bool isAtrLowerSlopeBearish = decisionXOBPVConditions.isAtrLowerSlopeBearish; + bool isVwapFastSlopeBearish = decisionXOBPVConditions.isVwapFastSlopeBearish; + bool isVwapMidSlopeBearish = decisionXOBPVConditions.isVwapMidSlopeBearish; + bool isVwapSlowSlopeBearish = decisionXOBPVConditions.isVwapSlowSlopeBearish; + + // + bool isSlopesBullish = + isRsiSlopeBullish && + isStrSlopeBullish && + isAtrUpperSlopeBullish && + isAtrLowerSlopeBullish && + isVwapFastSlopeBullish && + isVwapMidSlopeBullish && + isVwapSlowSlopeBullish; + + // + bool isSlopesBearish = + isRsiSlopeBearish && + isStrSlopeBearish && + isAtrUpperSlopeBearish && + isAtrLowerSlopeBearish && + isVwapFastSlopeBearish && + isVwapMidSlopeBearish && + isVwapSlowSlopeBearish; + + // + double point = conditions.point; + bool isPointBreaked = IsBarBreak( + point, + setupDir, + cBar // + ); + + // + // Summary ... + + // + isBullish = + // + isBullish // && + // isPointBreaked && + // isSlopesBullish + // + ; + + // + isBearish = + // + isBearish // && + // isPointBreaked && + // isSlopesBearish + // + ; + + // + result = isBullish || + isBearish; + if (!result) + { + // + // Cleanup Setup Conditions ... + int setupAge = conditions.GetSetupAge(); + if (IsValidSize(setupAge) && + IsValidSize(maxAllowedSetupAge) && + setupAge >= maxAllowedSetupAge) + { + conditions.Clean(); + } + + // + // Cleanup Arrays ... + ArrayFree(decisionPoiEvents); + ArrayFree(decisionCycleEvents); + + // + return result; + } + + // + // Detect Nearest Pivot Point ... + + // + double entry = GetEntry( + conditions.symbol, + setupDir // + ); + + // + double sls[]; + Add( + conditions.pivot, + sls // + ); + + // + double iAtr = decisionConditions.x121Conditions.atrBuffer[1]; + iAtr *= 1.5; + + // + double slsMin = GetMin(sls); + double slsMax = GetMax(sls); + + // + double sl = isBullish + ? slsMin - iAtr + : slsMax + iAtr; + double risk = MathAbs(entry - sl); + + // + // Filling Conditions Props ... + conditions.sl = sl; + // conditions.target = target; + conditions.triggerTime = cTime; + conditions.type = isBullish + ? X_POSITION_TYPE_LONG + : X_POSITION_TYPE_SHORT; + + // + // Cleanup Arrays ... + ArrayFree(decisionPoiEvents); + ArrayFree(decisionCycleEvents); + + // + return result; +} + +// +bool DetectX121SMCXOBPVGuards( + X121SMCGuard &guards[], + const XPosition &positions[], + XC121SMCCycleHelper *triggerCycleHelper, + XC121SMCCycleHelper *decisionCycleHelper, + XC121SMCCycleHelper *analyseCycleHelper, + XC121SMCCycleHelper *verificationCycleHelper, + XC121SMCCycleHelper *consolidationCycleHelper, + XC121SMCCycleHelper *visionCycleHelper // +) +{ + // + bool result = false; + + // + string provider = ToString(X_121_SMC_PROVIDER_X); + + // + // result = DetectX121SMCGuards( + // provider, + // guards, + // positions, + // triggerCycleHelper, + // decisionCycleHelper, + // analyseCycleHelper, + // verificationCycleHelper, + // consolidationCycleHelper, + // visionCycleHelper // + // ); + + // + return result; +} + +// +int AddX121SMCXOBPVConditionsIfNotExists( + X121SMCStrategyXOBPVSignalConditions &item, + X121SMCStrategyXOBPVSignalConditions &items[], + int maxAllowed = 10 // +) +{ + // + int result = 0; + + // + bool isSetuped = IsValid(item.setupTime) && + HasDirection(item.dir); + if (!isSetuped) + { + return result; + } + + // + int count = ArraySize(items); + if (IsValidSize(count)) + { + // + // Copy Original Items ... + X121SMCStrategyXOBPVSignalConditions tmpItems[]; + Copy( + items, + tmpItems // + ); + + // + // Prese Item Data ... + bool isBullish = IsBullish(item.dir); + + // + for (int i = 0; i < count; i++) + { + // + X121SMCStrategyXOBPVSignalConditions iItem = tmpItems[i]; + + // + bool canRemove = item.dir == iItem.dir && + item.pivot == iItem.pivot; + if (canRemove) + { + // + ArrayRemove( + items, + i, + 1 // + ); + } + } + + // + Clean(tmpItems); + } + + // + AddRef( + item, + items // + ); + + // + // Remove Olds ... + CleanupArray( + items, + maxAllowed // + ); + + // + result = ArraySize(items); + + // + return result; +} + +// +int DrawX121SMCXOBPVConditions( + X121SMCStrategyXOBPVSignalConditions &conditions, + XCBaseObject *&drawnObjects[], + XCPOIDrawer *drawer // +) +{ + // + int result = 0; + + // + Clean(drawnObjects); + + // + if (drawer == NULL) + { + return result; + } + + // + bool isSetuped = conditions.IsSetuped(); + if (!isSetuped) + { + return result; + } + + // + return result; +} + +// diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index ddb5a121..b366c7c3 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -28,10 +28,7 @@ // #include "../Signals/x-121.smc.x.signal.lib.mq5" -#include "../Signals/x-121.smc.xpvt.signal.lib.mq5" -#include "../Signals/x-121.smc.xpz.signal.lib.mq5" -#include "../Signals/x-121.smc.xrspvi.signal.lib.mq5" -#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5" +#include "../Signals/x-121.smc.xobpv.signal.lib.mq5" // // Definitions ... @@ -46,10 +43,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // Props ... bool useXSignal; - bool useXPZSignal; - bool useXPVTSignal; - bool useXRSPVISignal; - bool useXSTRPVSignal; + bool useXOBPVSignal; // // Constructor(s) ... @@ -72,9 +66,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy Destroy(); // - ArrayFree(mXPZConditionsCollection); - ArrayFree(mXRSPVIConditionsCollection); - ArrayFree(mXSTRPVConditionsCollection); + ArrayFree(mXConditionsCollection); + ArrayFree(mXOBPVConditionsCollection); } // @@ -201,10 +194,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // bool hasXSignal = false; - bool hasXPZSignal = false; - bool hasXPVTSignal = false; - bool hasXRSPVISignal = false; - bool hasXSTRPVSignal = false; + bool hasXOBPVSignal = false; // // X Signal ... @@ -216,39 +206,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy } // - // XPZ Signal ... - if (useXPZSignal && !hasSignal) + // XOBPV Signal ... + if (useXOBPVSignal && !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; + hasXOBPVSignal = DetectXOBPVSignal(conditions); + hasSignal = hasXOBPVSignal; } // @@ -425,61 +388,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // XPZ Guard Detection ... - if (useXPZSignal) + if (useXOBPVSignal) { // - 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( + bool hasGuard = DetectX121SMCXOBPVGuards( guards, positions, mTriggerCycleHelper, @@ -608,7 +520,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // // Detect Signal Setup ... - isSetuped = DetectX121SMCXSiganlSetup( + isSetuped = DetectX121SMCXSignalSetup( symbol, period, mXConditions, @@ -682,7 +594,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // // Detect Signal Trigger ... - canTrigger = DetectX121SMCXSiganlTrigger( + canTrigger = DetectX121SMCXSignalTrigger( mTmpConditions[i], symbol, period, @@ -765,8 +677,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy } // - // XPZ Signal ... - bool DetectXPZSignal( + // XOBPV Signal ... + bool DetectXOBPVSignal( X121SMCStrategyConditions &conditions // ) { @@ -831,22 +743,22 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy datetime cTime = TimeCurrent(); // - ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPZ; + ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XOBPV; string providerStr = ToString(provider); // // Detect Setup Conditions ... - datetime setupTime = mXPZConditions.setupTime; - bool isSetuped = mXPZConditions.IsSetuped(); - ENUM_X_DIRECTION setupDir = mXPZConditions.dir; + datetime setupTime = mXOBPVConditions.setupTime; + bool isSetuped = mXOBPVConditions.IsSetuped(); + ENUM_X_DIRECTION setupDir = mXOBPVConditions.dir; if (!isSetuped) { // // Detect Signal Setup ... - isSetuped = DetectX121SMCXPZSiganlSetup( + isSetuped = DetectX121SMCXOBPVSignalSetup( symbol, period, - mXPZConditions, + mXOBPVConditions, mTriggerCycleHelper, mDecisionCycleHelper, mAnalyseCycleHelper, @@ -856,25 +768,25 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy ); // - setupDir = mXPZConditions.dir; - setupTime = mXPZConditions.setupTime; + setupDir = mXOBPVConditions.dir; + setupTime = mXOBPVConditions.setupTime; // if (isSetuped) { // - int items = AddX121SMCXPZConditionsIfNotExists( - mXPZConditions, - mXPZConditionsCollection // + int items = AddX121SMCXOBPVConditionsIfNotExists( + mXOBPVConditions, + mXOBPVConditionsCollection // ); // - mXPZConditions.Clean(); + mXOBPVConditions.Clean(); } } // - int conditionsCount = ArraySize(mXPZConditionsCollection); + int conditionsCount = ArraySize(mXOBPVConditionsCollection); result = IsValidSize(conditionsCount); if (!result) { @@ -884,12 +796,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // Looking For Conditions ... int selectedIndex = 0; - X121SMCStrategyXPZSignalConditions mTmpConditions[]; + X121SMCStrategyXOBPVSignalConditions mTmpConditions[]; Copy( - mXPZConditionsCollection, + mXOBPVConditionsCollection, mTmpConditions // ); - X121SMCStrategyXPZSignalConditions mConditions; + X121SMCStrategyXOBPVSignalConditions mConditions; for (int i = 0; i < conditionsCount; i++) { // @@ -900,7 +812,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // // Detect Signal Trigger ... - canTrigger = DetectX121SMCXPZSiganlTrigger( + canTrigger = DetectX121SMCXOBPVSignalTrigger( mTmpConditions[i], symbol, period, @@ -922,7 +834,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy { // ArrayRemove( - mXPZConditionsCollection, + mXOBPVConditionsCollection, i, 1 // ); @@ -955,661 +867,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy // // 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, + mXOBPVConditionsCollection, selectedIndex, 1 // ); @@ -1651,11 +909,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy void InitialHelpers() { // - useXSignal = true; - useXPZSignal = false; - useXPVTSignal = false; - useXRSPVISignal = false; - useXSTRPVSignal = false; + useXSignal = false; + useXOBPVSignal = true; // string symbol = GetSymbol();