From da63c4cb715c71e27b86fcfedeb5bcea962a6bd4 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 25 May 2024 04:25:11 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.provider.class.mq5 | 1450 ++++++++++++++++++-- Classes/x-saherelm.x121.xea.class.mq5 | 369 ++++- Classes/x-saherelm.x121.xmcycle.class.mq5 | 1321 +++++++++++++++++- Classes/x-saherelm.xea.class.mq5 | 30 +- Experts/x-test.x121ea.mq5 | 20 +- Helpers/x-saherelm.xdon.helper.mq5 | 144 ++ Helpers/x-saherelm.xich.helper.mq5 | 72 + Helpers/x-saherelm.xpv.helper.mq5 | 270 ++++ Libraries/x-saherelm.common.lib.mq5 | 11 +- 9 files changed, 3522 insertions(+), 165 deletions(-) diff --git a/Classes/x-saherelm.x121.provider.class.mq5 b/Classes/x-saherelm.x121.provider.class.mq5 index f620fec7..4ace96cb 100644 --- a/Classes/x-saherelm.x121.provider.class.mq5 +++ b/Classes/x-saherelm.x121.provider.class.mq5 @@ -201,11 +201,14 @@ public: // // Current ... + cMarketInputs.pvInputs = this.pvInputs; + cMarketInputs.zgInputs = this.zgInputs; cMarketInputs.mcInputs = this.mcInputs; cMarketInputs.strInputs = this.strInputs; cMarketInputs.oscInputs = this.oscInputs; cMarketInputs.cheInputs = this.cheInputs; cMarketInputs.ichInputs = this.ichInputs; + cMarketInputs.donInputs = this.donInputs; result = cMarketInputs.Init( this.symbol, this.period, @@ -222,11 +225,14 @@ public: // // Short ... + sMarketInputs.pvInputs = this.pvInputs; + sMarketInputs.zgInputs = this.zgInputs; sMarketInputs.mcInputs = this.mcInputs; sMarketInputs.strInputs = this.strInputs; sMarketInputs.oscInputs = this.oscInputs; sMarketInputs.cheInputs = this.cheInputs; sMarketInputs.ichInputs = this.ichInputs; + sMarketInputs.donInputs = this.donInputs; result = sMarketInputs.Init( this.symbol, this.period, @@ -243,11 +249,14 @@ public: // // Medium ... + mMarketInputs.pvInputs = this.pvInputs; + mMarketInputs.zgInputs = this.zgInputs; mMarketInputs.mcInputs = this.mcInputs; mMarketInputs.strInputs = this.strInputs; mMarketInputs.oscInputs = this.oscInputs; mMarketInputs.cheInputs = this.cheInputs; mMarketInputs.ichInputs = this.ichInputs; + mMarketInputs.donInputs = this.donInputs; result = mMarketInputs.Init( this.symbol, this.period, @@ -264,11 +273,14 @@ public: // // Long ... + lMarketInputs.pvInputs = this.pvInputs; + lMarketInputs.zgInputs = this.zgInputs; lMarketInputs.mcInputs = this.mcInputs; lMarketInputs.strInputs = this.strInputs; lMarketInputs.oscInputs = this.oscInputs; lMarketInputs.cheInputs = this.cheInputs; lMarketInputs.ichInputs = this.ichInputs; + lMarketInputs.donInputs = this.donInputs; result = lMarketInputs.Init( this.symbol, this.period, @@ -285,11 +297,14 @@ public: // // Hind ... + hMarketInputs.pvInputs = this.pvInputs; + hMarketInputs.zgInputs = this.zgInputs; hMarketInputs.mcInputs = this.mcInputs; hMarketInputs.strInputs = this.strInputs; hMarketInputs.oscInputs = this.oscInputs; hMarketInputs.cheInputs = this.cheInputs; hMarketInputs.ichInputs = this.ichInputs; + hMarketInputs.donInputs = this.donInputs; result = hMarketInputs.Init( this.symbol, this.period, @@ -709,6 +724,61 @@ public: ArraySetAsSeries(pvHCHHs, true); ArraySetAsSeries(pvHCLLs, true); + // + isZigZagInPeak = false; + isZigZagInVale = false; + isDONAttachedMaxLower = false; + isDONAttachedMinLower = false; + isDONCrossedOverMaxLower = false; + isDONCrossedUnderMaxLower = false; + isDONAttachedMaxUpper = false; + isDONAttachedMinUpper = false; + isDONCrossedOverMaxUpper = false; + isDONCrossedUnderMaxUpper = false; + isPVPeakSameAs = false; + isPVNewPeak = false; + isPVNewPeakOverLast = false; + isPVNewPeakUnderLast = false; + isPVValeSameAs = false; + isPVNewVale = false; + isPVNewValeOverLast = false; + isPVNewValeUnderLast = false; + isPVFiboIncreased = false; + isPVFiboDecreased = false; + isPVFiboSectionChanged = false; + isPVSCBullish = false; + isPVSCHHBullish = false; + isPVSCLLBullish = false; + isPVSCSwitchedToBullish = false; + isPVSCBearish = false; + isPVSCHHBearish = false; + isPVSCLLBearish = false; + isPVSCSwitchedToBearish = false; + isPVMCBullish = false; + isPVMCHHBullish = false; + isPVMCLLBullish = false; + isPVMCSwitchedToBullish = false; + isPVMCBearish = false; + isPVMCHHBearish = false; + isPVMCLLBearish = false; + isPVMCSwitchedToBearish = false; + isPVLCBullish = false; + isPVLCHHBullish = false; + isPVLCLLBullish = false; + isPVLCSwitchedToBullish = false; + isPVLCBearish = false; + isPVLCHHBearish = false; + isPVLCLLBearish = false; + isPVLCSwitchedToBearish = false; + isPVHCBullish = false; + isPVHCHHBullish = false; + isPVHCLLBullish = false; + isPVHCSwitchedToBullish = false; + isPVHCBearish = false; + isPVHCHHBearish = false; + isPVHCLLBearish = false; + isPVHCSwitchedToBearish = false; + // cMarketConditions.Clear(); sMarketConditions.Clear(); @@ -1319,11 +1389,49 @@ public: // mNumberOfItems = 15; + mNumberOfSRVerified = 71; + mMinRequiredSupportAndResistances = 50; } // // Properties Gettr(s) / Setter(s) ... + // + void SetNumberOfSRVerified(int value) + { + mNumberOfSRVerified = value; + } + + // + int GetNumberOfSRVerified() + { + return mNumberOfSRVerified; + } + + // + void SetNumberOfItems(int value) + { + mNumberOfItems = value; + } + + // + int GetNumberOfItems() + { + return mNumberOfItems; + } + + // + void SetMinRequiredSupportAndResistances(int value) + { + mMinRequiredSupportAndResistances = value; + } + + // + int GetMinRequiredSupportAndResistances() + { + return mMinRequiredSupportAndResistances; + } + // // Overrides ... @@ -1657,6 +1765,7 @@ public: // // Reading Market Conditions ... GetMarketConditions(mConditions, barIndex); + AddScores(mConditions); // int signalPusher = 0; @@ -1664,6 +1773,10 @@ public: bool hasShort = false; string provider = ""; + // + double providedSL = 0; + double providedTP = 0; + // // Long ... if (mIsLongEnable) @@ -1677,7 +1790,9 @@ public: POSITION_TYPE_BUY, provider, signalPusher, - mConditions // + mConditions, + providedSL, + providedTP // ); } @@ -1694,7 +1809,9 @@ public: POSITION_TYPE_SELL, provider, signalPusher, - mConditions // + mConditions, + providedSL, + providedTP // ); } @@ -1749,32 +1866,15 @@ public: double r2r = 2; // - if (provider == ToString(X786)) + sl = 0; + tp = 0; + + // + // TP based on SL and Risk to Reward ... + if (providedSL > 0) { // - double maxDonUpper = donHelper.GetMaxUpper(0); - double minDonUpper = donHelper.GetMinUpper(0); - - // - double maxDonLower = donHelper.GetMaxLower(0); - double minDonLower = donHelper.GetMinLower(0); - - // - double peak = pvHelper.GetPeak(0); - double vale = pvHelper.GetVale(0); - - // - double hCHELE2 = hMarket.che.GetLongExit2(0); - double hCHESE2 = hMarket.che.GetShortExit2(0); - - // - double lCHELE2 = lMarket.che.GetLongExit2(0); - double lCHESE2 = lMarket.che.GetShortExit2(0); - - // - sl = hasLong - ? lCHELE2 - : lCHESE2; + sl = providedSL; // double risk = MathAbs(entry - sl); @@ -1787,28 +1887,25 @@ public: ? entry + reward : entry - reward; } - else if (provider == ToString(X121)) - { + else // - double peak = pvHelper.GetPeak(0); - double vale = pvHelper.GetVale(0); + // SL based on TP and Risk to Reward ... + if (providedTP > 0) + { + // + tp = providedTP; - // - sl = hasLong - ? vale - : peak; + // + double reward = MathAbs(entry - tp); - // - double risk = MathAbs(entry - sl); + // + double risk = reward / r2r; - // - double reward = risk * r2r; - - // - tp = hasLong - ? entry + reward - : entry - reward; - } + // + sl = hasLong + ? entry - risk + : entry + risk; + } // result = mSignal.Prepare( @@ -1840,6 +1937,9 @@ public: } } + // + UpdateSupportsAndResistances(); + // return result; } @@ -1851,34 +1951,17 @@ public: // bool result = false; - // // - // XOHCL bar; - // bar.Init( - // GetSymbol(), - // GetPeriod(), - // 0 // - // ); - - // // - // double maxDONUppers = donHelper.GetMaxUpper(0); - // double minDONUppers = donHelper.GetMinUpper(0); - // // double minDONUppers = donHelper.GetMinUpper(1); - - // // - // bool isDONUpAttached = - // // - // bar.high >= maxDONUppers - // // - // ; - // if (isDONUpAttached) - // { - // Print("Force Close Short X786"); - // } + // + // Try to Find Support and Resistances if Configured ... + FindSupportAndResistances(); // return result; } + // + // Tools ... + // void Draw() { @@ -1909,12 +1992,668 @@ public: hMarket.Draw(chID, subWindow, offset); } + // + // Support and Resistances ... + + // + int CountSupportResistances() + { + return ArraySize(mSupportResistances); + } + + // + bool GenerateSupRes( + XOHCLSupRes &supRes, // SupRes Instance ... + ENUM_POSITION_TYPE type, // Position Type ... + int count = 5, + double step = 0, + bool useAtrAsStep = true // + ) + { + // + bool result = false; + + // + if (count <= 0) + { + count = 1; + } + + // + if (step <= 0) + { + // + if (useAtrAsStep) + { + step = cMarket.osc.GetATR(0); + } + else + { + step = 0; + } + } + + // + supRes.Clean(); + + // + double price = GetExit( + GetSymbol(), + type // + ); + + // + result = supRes.Init( + price, + mSupportResistances, + count, + step); + + // + return result; + } + + // + bool GenerateLongSupRes( + XOHCLSupRes &supRes, // SupRes Instance ... + int count = 5, + double step = 0, + bool useAtrAsStep = true // + ) + { + // + bool result = false; + + // + result = GenerateSupRes( + supRes, + POSITION_TYPE_BUY, + count, + step, + useAtrAsStep // + ); + + // + return result; + } + + // + bool GenerateShortSupRes( + XOHCLSupRes &supRes, // SupRes Instance ... + int count = 5, + double step = 0, + bool useAtrAsStep = true // + ) + { + // + bool result = false; + + // + result = GenerateSupRes( + supRes, + POSITION_TYPE_BUY, + count, + step, + useAtrAsStep // + ); + + // + return result; + } + + // + // Peask and Vales Finder ... + + // + double GetMinPeaks() + { + // + double cPeak = cMarket.pv.GetPeak(0); + double sPeak = sMarket.pv.GetPeak(0); + double mPeak = mMarket.pv.GetPeak(0); + double lPeak = lMarket.pv.GetPeak(0); + double hPeak = hMarket.pv.GetPeak(0); + + // + double peaks[] = { + cPeak, + sPeak, + mPeak, + lPeak, + hPeak // + }; + + // + double minPeak = GetMin(peaks); + double maxPeak = GetMax(peaks); + + // + return minPeak; + } + + // + double GetMaxPeaks() + { + // + double cPeak = cMarket.pv.GetPeak(0); + double sPeak = sMarket.pv.GetPeak(0); + double mPeak = mMarket.pv.GetPeak(0); + double lPeak = lMarket.pv.GetPeak(0); + double hPeak = hMarket.pv.GetPeak(0); + + // + double peaks[] = { + cPeak, + sPeak, + mPeak, + lPeak, + hPeak // + }; + + // + double minPeak = GetMin(peaks); + double maxPeak = GetMax(peaks); + + // + return maxPeak; + } + + // + double GetMinVales() + { + // + double cMVale = cMarket.pv.GetVale(0); + double sMVale = sMarket.pv.GetVale(0); + double mMVale = mMarket.pv.GetVale(0); + double lMVale = lMarket.pv.GetVale(0); + double hMVale = hMarket.pv.GetVale(0); + + // + double vales[] = { + cMVale, + sMVale, + mMVale, + lMVale, + hMVale // + }; + + // + double minVale = GetMin(vales); + double maxVale = GetMax(vales); + + // + return minVale; + } + + // + double GetMaxVales() + { + // + double cMVale = cMarket.pv.GetVale(0); + double sMVale = sMarket.pv.GetVale(0); + double mMVale = mMarket.pv.GetVale(0); + double lMVale = lMarket.pv.GetVale(0); + double hMVale = hMarket.pv.GetVale(0); + + // + double vales[] = { + cMVale, + sMVale, + mMVale, + lMVale, + hMVale // + }; + + // + double minVale = GetMin(vales); + double maxVale = GetMax(vales); + + // + return maxVale; + } + // // Protected ... protected: // X121ProviderInputs mInputs; + // + // Support and Resistances ... + + // + // Check has Enough Support and Resistance ... + bool HasEnoughSupportAndResistance() + { + // + bool result = false; + + // + if (mNumberOfSRVerified <= 0 || + mMinRequiredSupportAndResistances <= 0) + { + result = true; + } + else + { + // + int currentSRsCount = CountSupportResistances(); + result = currentSRsCount >= mMinRequiredSupportAndResistances; + } + + // + return result; + } + + // + // Update Bar Index base Support and Resistances .... + void UpdateSupportsAndResistances( + int barIndex = 0 // + ) + { + // + if (mNumberOfSRVerified <= 0 || + mMinRequiredSupportAndResistances <= 0) + { + return; + } + + // + int before = CountSupportResistances(); + + // + // XICH ... + + // + // Current ... + + // + if (cMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified)) + { + // + double selectedKijunSen = cMarket.ich.GetKijunSen(barIndex); + AddSRValue(selectedKijunSen); + } + + // + if (cMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanA = cMarket.ich.GetSenkouSpanA(barIndex); + AddSRValue(selectedSenkouSpanA); + } + + // + if (cMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanB = cMarket.ich.GetSenkouSpanB(barIndex); + AddSRValue(selectedSenkouSpanB); + } + + // + // Short ... + + // + if (sMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified)) + { + // + double selectedKijunSen = sMarket.ich.GetKijunSen(barIndex); + AddSRValue(selectedKijunSen); + } + + // + if (sMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanA = sMarket.ich.GetSenkouSpanA(barIndex); + AddSRValue(selectedSenkouSpanA); + } + + // + if (sMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanB = sMarket.ich.GetSenkouSpanB(barIndex); + AddSRValue(selectedSenkouSpanB); + } + + // + // Medium ... + + // + if (mMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified)) + { + // + double selectedKijunSen = mMarket.ich.GetKijunSen(barIndex); + AddSRValue(selectedKijunSen); + } + + // + if (mMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanA = mMarket.ich.GetSenkouSpanA(barIndex); + AddSRValue(selectedSenkouSpanA); + } + + // + if (mMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanB = mMarket.ich.GetSenkouSpanB(barIndex); + AddSRValue(selectedSenkouSpanB); + } + + // + // Long ... + + // + if (lMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified)) + { + // + double selectedKijunSen = lMarket.ich.GetKijunSen(barIndex); + AddSRValue(selectedKijunSen); + } + + // + if (lMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanA = lMarket.ich.GetSenkouSpanA(barIndex); + AddSRValue(selectedSenkouSpanA); + } + + // + if (lMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanB = lMarket.ich.GetSenkouSpanB(barIndex); + AddSRValue(selectedSenkouSpanB); + } + + // + // Hind ... + + // + if (hMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified)) + { + // + double selectedKijunSen = hMarket.ich.GetKijunSen(barIndex); + AddSRValue(selectedKijunSen); + } + + // + if (hMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanA = hMarket.ich.GetSenkouSpanA(barIndex); + AddSRValue(selectedSenkouSpanA); + } + + // + if (hMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified)) + { + // + double selectedSenkouSpanB = hMarket.ich.GetSenkouSpanB(barIndex); + AddSRValue(selectedSenkouSpanB); + } + + // + // XDON ... + + // + if (donHelper.IsSameUpperO(barIndex, mNumberOfSRVerified)) + { + // + double selectedUpperO = donHelper.GetUpperO(barIndex); + AddSRValue(selectedUpperO); + } + + // + if (donHelper.IsSameLowerO(barIndex, mNumberOfSRVerified)) + { + // + double selectedLowerO = donHelper.GetLowerO(barIndex); + AddSRValue(selectedLowerO); + } + + // + if (donHelper.IsSameUpperC(barIndex, mNumberOfSRVerified)) + { + // + double selectedUpperC = donHelper.GetUpperC(barIndex); + AddSRValue(selectedUpperC); + } + + // + if (donHelper.IsSameLowerC(barIndex, mNumberOfSRVerified)) + { + // + double selectedLowerC = donHelper.GetLowerC(barIndex); + AddSRValue(selectedLowerC); + } + + // + if (donHelper.IsSameUpperH(barIndex, mNumberOfSRVerified)) + { + // + double selectedUpperH = donHelper.GetUpperH(barIndex); + AddSRValue(selectedUpperH); + } + + // + if (donHelper.IsSameLowerH(barIndex, mNumberOfSRVerified)) + { + // + double selectedLowerH = donHelper.GetLowerH(barIndex); + AddSRValue(selectedLowerH); + } + + // + if (donHelper.IsSameUpperL(barIndex, mNumberOfSRVerified)) + { + // + double selectedUpperL = donHelper.GetUpperL(barIndex); + AddSRValue(selectedUpperL); + } + + // + if (donHelper.IsSameLowerL(barIndex, mNumberOfSRVerified)) + { + // + double selectedLowerL = donHelper.GetLowerL(barIndex); + AddSRValue(selectedLowerL); + } + + // + // XPV ... + + // + if (pvHelper.IsSamePeak(barIndex, mNumberOfSRVerified)) + { + // + double selectedPeak = pvHelper.GetPeak(barIndex); + AddSRValue(selectedPeak); + } + + // + if (pvHelper.IsSameVale(barIndex, mNumberOfSRVerified)) + { + // + double selectedVale = pvHelper.GetVale(barIndex); + AddSRValue(selectedVale); + } + + // + if (pvHelper.IsSameFib1(barIndex, mNumberOfSRVerified)) + { + // + double selectedFib1 = pvHelper.GetFib1(barIndex); + AddSRValue(selectedFib1); + } + + // + if (pvHelper.IsSameFib2(barIndex, mNumberOfSRVerified)) + { + // + double selectedFib2 = pvHelper.GetFib2(barIndex); + AddSRValue(selectedFib2); + } + + // + if (pvHelper.IsSameFib3(barIndex, mNumberOfSRVerified)) + { + // + double selectedFib3 = pvHelper.GetFib3(barIndex); + AddSRValue(selectedFib3); + } + + // + if (pvHelper.IsSameFib4(barIndex, mNumberOfSRVerified)) + { + // + double selectedFib4 = pvHelper.GetFib4(barIndex); + AddSRValue(selectedFib4); + } + + // + if (pvHelper.IsSameFib5(barIndex, mNumberOfSRVerified)) + { + // + double selectedFib5 = pvHelper.GetFib5(barIndex); + AddSRValue(selectedFib5); + } + + // + if (pvHelper.IsSameSCHH(barIndex, mNumberOfSRVerified)) + { + // + double selectedSCHH = pvHelper.GetSCHH(barIndex); + AddSRValue(selectedSCHH); + } + + // + if (pvHelper.IsSameSCLL(barIndex, mNumberOfSRVerified)) + { + // + double selectedSCLL = pvHelper.GetSCLL(barIndex); + AddSRValue(selectedSCLL); + } + + // + if (pvHelper.IsSameMCHH(barIndex, mNumberOfSRVerified)) + { + // + double selectedMCHH = pvHelper.GetMCHH(barIndex); + AddSRValue(selectedMCHH); + } + + // + if (pvHelper.IsSameMCLL(barIndex, mNumberOfSRVerified)) + { + // + double selectedMCLL = pvHelper.GetMCLL(barIndex); + AddSRValue(selectedMCLL); + } + + // + if (pvHelper.IsSameLCHH(barIndex, mNumberOfSRVerified)) + { + // + double selectedLCHH = pvHelper.GetLCHH(barIndex); + AddSRValue(selectedLCHH); + } + + // + if (pvHelper.IsSameLCLL(barIndex, mNumberOfSRVerified)) + { + // + double selectedLCLL = pvHelper.GetLCLL(barIndex); + AddSRValue(selectedLCLL); + } + + // + if (pvHelper.IsSameHCHH(barIndex, mNumberOfSRVerified)) + { + // + double selectedHCHH = pvHelper.GetHCHH(barIndex); + AddSRValue(selectedHCHH); + } + + // + if (pvHelper.IsSameHCLL(barIndex, mNumberOfSRVerified)) + { + // + double selectedHCLL = pvHelper.GetHCLL(barIndex); + AddSRValue(selectedHCLL); + } + + // + int after = CountSupportResistances(); + + // + if (after > before) + { + // + string message = "Found: " + ToString(after - before) + " new Pivot ..."; + Print(message); + } + } + + // + void FindSupportAndResistances() + { + // + bool hasEnough = HasEnoughSupportAndResistance(); + if (hasEnough) + { + // + // if (IsNewBar()) + // { + // UpdateSupportsAndResistances(); + // } + return; + } + + // + int idx = 0; + while (!HasEnoughSupportAndResistance()) + { + // + UpdateSupportsAndResistances(idx); + + // + if (HasEnoughSupportAndResistance()) + { + break; + } + + // + idx += 50; + + // + // Print("idx: " + ToString(idx) + ", Count: " + ToString(CountSupportResistances())); + Print("Pivots: " + ToString(CountSupportResistances())); + } + } + + // + void AddSRValue(double value) + { + // + if (value <= 0) + { + return; + } + + // + AddIfNotExists( + value, + mSupportResistances // + ); + } + // // Private ... private: @@ -1924,6 +2663,148 @@ private: // int mNumberOfItems; // Number of Buffer Ites Read in Conditions ... + // + // Support and Resistance ... + + // + int mNumberOfSRVerified; // Number of Verifications for Selecting Support and Resistances ... + + // + int mMinRequiredSupportAndResistances; // Minimum Requirement Supports and Resistances ... + + // + double mSupportResistances[]; // Holds Supports and Resistances ... + + // + // Bullish and Bearish Scores ... + + // + double mBullishScore[]; + double mBearishScore[]; + + // + // Store Market Conditions Scores ... + void AddScores(X121MarketConditions &conditions) + { + // + double bullishScore = 0; + double bearishScore = 0; + conditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + ArraySetAsSeries(mBullishScore, false); + ArraySetAsSeries(mBearishScore, false); + + // + Add( + bullishScore, + mBullishScore // + ); + + // + Add( + bearishScore, + mBearishScore // + ); + + // + ArraySetAsSeries(mBullishScore, true); + ArraySetAsSeries(mBearishScore, true); + } + + // + // Find Bullish Score Averages ... + double GetBullishScoreAverage( + int start = 0, + int count = 7 // + ) + { + // + return GetAverage( + mBullishScore, + start, + count // + ); + } + + // + // Find Bullish Scores Max Value ... + double GetBullishScoreMax( + int start = 0, + int count = 71 // + ) + { + // + return GetMax( + mBullishScore, + start, + count // + ); + } + + // + // Find Bullish Scores Min Value ... + double GetBullishScoreMin( + int start = 0, + int count = 71 // + ) + { + // + return GetMin( + mBullishScore, + start, + count // + ); + } + + // + // Find Bearish Score Averages ... + double GetBearishScoreAverage( + int start = 0, + int count = 7 // + ) + { + // + return GetAverage( + mBearishScore, + start, + count // + ); + } + + // + // Find Bearish Scores Max Value ... + double GetBearishScoreMax( + int start = 0, + int count = 71 // + ) + { + // + return GetMax( + mBearishScore, + start, + count // + ); + } + + // + // Find Bearish Scores Min Value ... + double GetBearishScoreMin( + int start = 0, + int count = 71 // + ) + { + // + return GetMin( + mBearishScore, + start, + count // + ); + } + // // Signallers ... @@ -1943,11 +2824,13 @@ private: // // Detect Signal ... bool HasSpecificSignal( - int barIndex, // Specified Bar Index ... - ENUM_POSITION_TYPE mType, // Specific Signal Type ... - string &provider, // Signal Provider ... - int &signalPusher, // Number Of Same Time Signals ... - X121MarketConditions &mConditions // Specified Market Conition ... + int barIndex, // Specified Bar Index ... + ENUM_POSITION_TYPE mType, // Specific Signal Type ... + string &provider, // Signal Provider ... + int &signalPusher, // Number Of Same Time Signals ... + X121MarketConditions &mConditions, // Specified Market Conition ... + double &providedSL, + double &providedTP // ) { // @@ -1991,7 +2874,9 @@ private: { // hasX121XSPSignal = X121XSPHasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2014,7 +2899,9 @@ private: { // hasXTESTSignal = XTESTHasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2037,7 +2924,9 @@ private: { // hasX786Signal = X786HasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2060,7 +2949,9 @@ private: { // hasX121Signal = X121HasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2083,7 +2974,9 @@ private: { // hasX110Signal = X110HasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2106,7 +2999,9 @@ private: { // hasX92Signal = X92HasSpecifiedLongSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2181,7 +3076,9 @@ private: { // hasX121XSPSignal = X121XSPHasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2204,7 +3101,9 @@ private: { // hasXTESTSignal = XTESTHasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2227,7 +3126,9 @@ private: { // hasX786Signal = X786HasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2250,7 +3151,9 @@ private: { // hasX121Signal = X121HasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2273,7 +3176,9 @@ private: { // hasX110Signal = X110HasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -2296,7 +3201,9 @@ private: { // hasX92Signal = X92HasSpecifiedShortSignal( - mConditions // + mConditions, + providedSL, + providedTP // ); // @@ -3089,7 +3996,9 @@ private: // bool X121XSPHasSpecifiedLongSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // @@ -3101,7 +4010,9 @@ private: // bool XTESTHasSpecifiedLongSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // @@ -3112,13 +4023,20 @@ private: } // + // Use XCHE and XSTR ... bool X786HasSpecifiedLongSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // bool result = false; + // + // TODO: Remove this ... + return result; + // // Check For Long ... bool isSTRLong = @@ -3222,15 +4140,23 @@ private: } // + // Use XMC ... bool X121HasSpecifiedLongSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // bool result = false; // - bool isMCLong = + sl = 0; + tp = 0; + + // + // Current Market ... + bool isCMCLong = // ( // @@ -3246,10 +4172,166 @@ private: // ; + // + // Medium Market ... + bool isMMCLong = + // + ( + // + (mConditions.mMarketConditions.isSlowOverVerifier && + mConditions.mMarketConditions.isFastCrossedOverVerifier) + // + || + // + (mConditions.mMarketConditions.isFastOverVerifier && + mConditions.mMarketConditions.isSlowCrossedOverVerifier) + // + ) + // + ; + + // + // Long Market ... + bool isLMCLong = + // + ( + // + (mConditions.lMarketConditions.isSlowOverVerifier && + mConditions.lMarketConditions.isFastCrossedOverVerifier) + // + || + // + (mConditions.lMarketConditions.isFastOverVerifier && + mConditions.lMarketConditions.isSlowCrossedOverVerifier) + // + ) + // + ; + + // + // Hind Market ... + bool isHMCLong = + // + ( + // + (mConditions.hMarketConditions.isSlowOverVerifier && + mConditions.hMarketConditions.isFastCrossedOverVerifier) + // + || + // + (mConditions.hMarketConditions.isFastOverVerifier && + mConditions.hMarketConditions.isSlowCrossedOverVerifier) + // + ) + // + ; + // result = // - isMCLong + isCMCLong + // + || + // + isMMCLong + // + || + // + isLMCLong + // + || + // + isHMCLong + // + ; + + // + if (result) + { + sl = GetMinPeaks(); + } + + // + return result; + } + + // + // Use XCHE ... + bool X110HasSpecifiedLongSignal( + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... + ) + { + // + bool result = false; + + // + return result; + } + + // + // Use Scores ... + bool X92HasSpecifiedLongSignal( + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... + ) + { + // + bool result = false; + + // + // return false; + + // + double bullishScore = mBullishScore[0]; + double bullishMin100 = GetBullishScoreMin(0, 100); + double bullishMax100 = GetBullishScoreMax(0, 100); + double bullish7AVG = GetBullishScoreAverage(0, 7); + double bullish21AVG = GetBullishScoreAverage(0, 21); + + // + double bearishScore = mBearishScore[0]; + double bearishMin100 = GetBearishScoreMin(0, 100); + double bearishMax100 = GetBearishScoreMax(0, 100); + double bearish7AVG = GetBearishScoreAverage(0, 7); + double bearish21AVG = GetBearishScoreAverage(0, 21); + + // + bool isBullishOverAVGs = + // + bullishScore > bearishScore && + bullishScore > bullish7AVG && + bullishScore > bullish21AVG + // + ; + + // + if (isBullishOverAVGs) + { + sl = GetMinVales(); + } + + // // + // bool isBearishEqualOverMax100 = + // // + // bearishScore > bearish7AVG && + // bearishScore > bearish21AVG && + // bearishScore >= bearishMax100 + // // + // ; + + // // + // if (isBearishEqualOverMax100) + // { + // sl = 0; // GetMaxVales() - PointToPrice(100, GetSymbol()); + // } + + // + result = + // + isBullishOverAVGs // ; @@ -3257,33 +4339,11 @@ private: return result; } - // - bool X110HasSpecifiedLongSignal( - X121MarketConditions &mConditions // - ) - { - // - bool result = false; - - // - return result; - } - - // - bool X92HasSpecifiedLongSignal( - X121MarketConditions &mConditions // - ) - { - // - bool result = false; - - // - return result; - } - // bool X121XSPHasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // @@ -3295,7 +4355,9 @@ private: // bool XTESTHasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // @@ -3306,13 +4368,20 @@ private: } // + // Use XCHE and XSTR ... bool X786HasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // bool result = false; + // + // TODO: Remove this ... + return result; + // // Check For Short ... bool isSTRShort = @@ -3416,15 +4485,22 @@ private: } // + // Use XMC ... bool X121HasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // bool result = false; - + // - bool isMCShort = + // TODO: Remove this ... + return result; + + // + bool isCMCShort = // ( // @@ -3441,19 +4517,91 @@ private: ; // - result = + bool isMMCShort = // - isMCShort + ( + // + (mConditions.mMarketConditions.isSlowUnderVerifier && + mConditions.mMarketConditions.isFastCrossedUnderVerifier) + // + || + // + (mConditions.mMarketConditions.isFastUnderVerifier && + mConditions.mMarketConditions.isSlowCrossedUnderVerifier) + // + ) // ; + // + bool isLMCShort = + // + ( + // + (mConditions.lMarketConditions.isSlowUnderVerifier && + mConditions.lMarketConditions.isFastCrossedUnderVerifier) + // + || + // + (mConditions.lMarketConditions.isFastUnderVerifier && + mConditions.lMarketConditions.isSlowCrossedUnderVerifier) + // + ) + // + ; + + // + bool isHMCShort = + // + ( + // + (mConditions.hMarketConditions.isSlowUnderVerifier && + mConditions.hMarketConditions.isFastCrossedUnderVerifier) + // + || + // + (mConditions.hMarketConditions.isFastUnderVerifier && + mConditions.hMarketConditions.isSlowCrossedUnderVerifier) + // + ) + // + ; + + // + result = + // + isCMCShort + // + || + // + isMMCShort + // + || + // + isLMCShort + // + || + // + isHMCShort + // + ; + + // + if (result) + { + sl = GetMaxPeaks(); + } + // return result; } // + // Use XCHE ... bool X110HasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // @@ -3464,13 +4612,67 @@ private: } // + // Use Scores ... bool X92HasSpecifiedShortSignal( - X121MarketConditions &mConditions // + X121MarketConditions &mConditions, // + double &sl, // Provided SL ... + double &tp // Provided TP ... ) { // bool result = false; + // + double bullishScore = mBullishScore[0]; + double bullishMin100 = GetBullishScoreMin(0, 71); + double bullishMax100 = GetBullishScoreMax(0, 71); + double bullish7AVG = GetBullishScoreAverage(0, 7); + double bullish21AVG = GetBullishScoreAverage(0, 21); + + // + double bearishScore = mBearishScore[0]; + double bearishMin100 = GetBearishScoreMin(0, 71); + double bearishMax100 = GetBearishScoreMax(0, 71); + double bearish7AVG = GetBearishScoreAverage(0, 7); + double bearish21AVG = GetBearishScoreAverage(0, 21); + + // + bool isBearishOverAVGs = + // + bearishScore > bullishScore && + bearishScore > bearish7AVG && + bearishScore > bearish21AVG + // + ; + + // + if (isBearishOverAVGs) + { + sl = GetMaxPeaks(); + } + + // // + // bool isBullishEqualOverMax100 = + // // + // bullishScore > bullish7AVG && + // bullishScore > bullish21AVG && + // bullishScore >= bullishMax100 + // // + // ; + + // // + // if (isBullishEqualOverMax100) + // { + // sl = GetMaxPeaks(); + // } + + // + result = + // + isBearishOverAVGs + // + ; + // return result; } diff --git a/Classes/x-saherelm.x121.xea.class.mq5 b/Classes/x-saherelm.x121.xea.class.mq5 index 163103ad..087a6482 100644 --- a/Classes/x-saherelm.x121.xea.class.mq5 +++ b/Classes/x-saherelm.x121.xea.class.mq5 @@ -289,7 +289,11 @@ public: bool result = false; // - int requiredAgeForSLTrail = 10; + // TODO: + // Make them Configurable ... + int numberOfPositionsForHege = 4; + int levelsOnClose = 6; + int requiredAgeForSLTrail = 3; int requiredDistanceForSLTrail = 10; // @@ -307,10 +311,18 @@ public: // XPosition iPosition = positions[i]; + // + bool canManageState = + // + iPosition.provider == ToString(X786) || + iPosition.provider == ToString(X121) || + iPosition.provider == ToString(X92) + // + ; + // // Position Management for X786 ... - if (iPosition.provider == ToString(X786) || - iPosition.provider == ToString(X121)) + if (canManageState) { // // Check Position in Profit or not ... @@ -318,7 +330,7 @@ public: { // XTrail trail; - bool isTrailedBefore = GetTrail( + bool isTrailedBefore = GetSLTrail( iPosition.ticket, trail // ); @@ -355,6 +367,12 @@ public: ? iPosition.sl + slDiff : iPosition.sl - slDiff; + // // + // double sl = + // IsLong(iPosition.type) + // ? iPosition.entry + (slDiff / 2) + // : iPosition.entry - (slDiff / 2); + // bool isInit = trail.Init( iPosition.ticket, @@ -400,7 +418,7 @@ public: { // // int positionAge = iPosition.GetAge(iPosition.period); - if (trail.level >= 3) + if (trail.level >= levelsOnClose) { // string comment = "EQM Close In Profit ..."; @@ -411,7 +429,7 @@ public: if (isClosed) { // - RemoveTrail(iPosition.ticket); + RemoveSLTrail(iPosition.ticket); // string message = "EQM Close (" + ToString(iPosition.ticket) + ") In Profit ..."; @@ -424,11 +442,20 @@ public: // double slDiff = PointToPrice(priceDistance, iPosition.symbol); + // + double selectedValue = + // + trail.level == 2 + ? iPosition.entry + : iPosition.sl + // + ; + // double sl = IsLong(iPosition.type) - ? iPosition.sl + slDiff - : iPosition.sl - slDiff; + ? selectedValue + slDiff + : selectedValue - slDiff; // // Update Trail Values ... @@ -456,10 +483,10 @@ public: if (isModified) { // - RemoveTrail(trail.ticket); + RemoveSLTrail(trail.ticket); // - AddTrail(trail); + AddSLTrail(trail); // string message = "Position (" + ToString(trail.ticket) + ") Trailed SL on Level: " + ToString(trail.level); @@ -470,11 +497,193 @@ public: } } + // + // Hedge ... + if (positionsCount >= numberOfPositionsForHege) + { + // + double profit = CalculatePositionsProfit(positions); + double requiredProfit = CalculateRequiredProfitForHedge(positions); + + // + bool isReadyForHedge = profit >= requiredProfit; + if (!isReadyForHedge) + { + return result; + } + + // + string comment = "EQM Hedge ..."; + int closed = mTrader.Close( + positions, + comment + // + ); + if (closed > 0) + { + // + string message = "EQM Hedge Positions on Profit: " + ToString(profit); + + // + mAlert.Alert(message); + + // + for (int i = 0; i < positionsCount; i++) + { + RemoveSLTrail(positions[i].ticket); + } + } + } + // // Must false ... return result; } + // + // Here we Can Filter Signals before Sending them to Execution ... + // based on Providers and etc ... + // for Volumes and Benefits ... + int HandleSignalManagement(XSignal &signals[]) override + { + // + int result = 0; + + // + if (ArraySize(signals) <= 0) + { + return result; + } + + // + // Create temp Array for Filtering ... + XSignal tmps[]; + Copy( + signals, + tmps // + ); + int tmpsCount = ArraySize(tmps); + + // + // Cleaning Source ... + Clean(signals); + + // + // Loop through Signals for Management ... + for (int i = 0; i < tmpsCount; i++) + { + // + XSignal iSignal = tmps[i]; + + // + string provider = iSignal.provider; + if (!IsValid(provider)) + { + // + AddRef( + iSignal, + signals // + ); + + // + continue; + } + + // + XPosition positions[]; + int positionsCount = mTrader.GetPositions( + positions, + iSignal.symbol, + iSignal.provider, + NULL, // All Periods ... + iSignal.type // + ); + if (positionsCount <= 5) + { + // + // First Signal in a While of Specific Provider ... + AddRef( + iSignal, + signals // + ); + + // + continue; + } + else + { + // + // not First Signal ... + + // + // Calculate Provider Specified Open Positions Profit ... + double profits = CalculatePositionsProfit(positions); + if (profits > 0) + { + // + AddRef( + iSignal, + signals // + ); + + // + continue; + } + else + { + // + // Find Max In Profit of Same Position ... + Clean(positions); + positionsCount = mTrader.GetInProfitPositions( + positions, + iSignal.symbol, + iSignal.provider, + NULL, // All Periods ... + iSignal.type, + X_POSITION_SELECT_MAX // Max In Profit ... + ); + if (positionsCount <= 0) + { + continue; + } + + // + string comment = "EQM Close Max Profit ..."; + bool isClosed = mTrader.Close( + positions[0].ticket, + comment // + ); + if (isClosed) + { + // + RemoveTrail(positions[0].ticket); + + // + string message = "EQM Close Max In Profit (" + ToString(positions[0].ticket) + ") for new Signal ..."; + + // + mAlert.Alert(message); + + // + AddRef( + iSignal, + signals // + ); + + // + continue; + } + } + } + } + + // + result = ArraySize(signals); + + // + return result; + } + // // Request for Support Signals using Guard ... bool RequestForSupport( @@ -487,6 +696,12 @@ public: { // // TODO: Implement this ... + + // + // Support Senario ... + // Check Support Position Exists or not ... + // Check Positions for Support based on Types ... + // Update Untriggered Positions ... return false; } @@ -544,22 +759,39 @@ private: // Trails Holding ... // - XTrail mTrails[]; + XTrail mSLTrails[]; + XTrail mTPTrails[]; // - int CountTrails() + int CountSLTrails() { - return ArraySize(mTrails); + return ArraySize(mSLTrails); + } + int CountTPTrails() + { + return ArraySize(mTPTrails); } // bool RemoveTrail(ulong ticket) + { + // + bool isSLRemoved = RemoveSLTrail(ticket); + bool isTPRemoved = RemoveTPTrail(ticket); + + // + bool result = isSLRemoved || isTPRemoved; + + // + return result; + } + bool RemoveSLTrail(ulong ticket) { // bool result = false; // - int idx = FindTrailIndex(ticket); + int idx = FindSLTrailIndex(ticket); result = idx >= 0; if (!result) { @@ -568,7 +800,30 @@ private: // result = ArrayRemove( - mTrails, + mSLTrails, + idx, + 1 // + ); + + // + return result; + } + bool RemoveTPTrail(ulong ticket) + { + // + bool result = false; + + // + int idx = FindTPTrailIndex(ticket); + result = idx >= 0; + if (!result) + { + return result; + } + + // + result = ArrayRemove( + mTPTrails, idx, 1 // ); @@ -578,13 +833,13 @@ private: } // - int FindTrailIndex(ulong ticket) + int FindSLTrailIndex(ulong ticket) { // int result = -1; // - int trailsCount = CountTrails(); + int trailsCount = CountSLTrails(); if (ticket <= 0 || trailsCount <= 0) { return result; @@ -594,7 +849,37 @@ private: for (int i = 0; i < trailsCount; i++) { // - XTrail iTrail = mTrails[i]; + XTrail iTrail = mSLTrails[i]; + + // + if (iTrail.ticket == ticket) + { + // + result = i; + break; + } + } + + // + return result; + } + int FindTPTrailIndex(ulong ticket) + { + // + int result = -1; + + // + int trailsCount = CountTPTrails(); + if (ticket <= 0 || trailsCount <= 0) + { + return result; + } + + // + for (int i = 0; i < trailsCount; i++) + { + // + XTrail iTrail = mTPTrails[i]; // if (iTrail.ticket == ticket) @@ -610,7 +895,7 @@ private: } // - bool GetTrail( + bool GetSLTrail( ulong ticket, XTrail &trail // ) @@ -619,7 +904,7 @@ private: bool result = false; // - int idx = FindTrailIndex(ticket); + int idx = FindSLTrailIndex(ticket); result = idx >= 0; if (!result) { @@ -627,14 +912,36 @@ private: } // - trail = mTrails[idx]; + trail = mSLTrails[idx]; + + // + return result; + } + bool GetTPTrail( + ulong ticket, + XTrail &trail // + ) + { + // + bool result = false; + + // + int idx = FindTPTrailIndex(ticket); + result = idx >= 0; + if (!result) + { + return result; + } + + // + trail = mTPTrails[idx]; // return result; } // - void AddTrail( + void AddSLTrail( XTrail &trail // ) { @@ -647,7 +954,23 @@ private: // AddRef( trail, - mTrails // + mSLTrails // + ); + } + void AddTPTrail( + XTrail &trail // + ) + { + // + if (!trail.IsValid()) + { + return; + } + + // + AddRef( + trail, + mTPTrails // ); } diff --git a/Classes/x-saherelm.x121.xmcycle.class.mq5 b/Classes/x-saherelm.x121.xmcycle.class.mq5 index 664f0a8a..accf3255 100644 --- a/Classes/x-saherelm.x121.xmcycle.class.mq5 +++ b/Classes/x-saherelm.x121.xmcycle.class.mq5 @@ -28,6 +28,9 @@ // #include "../Helpers/x-saherelm.xmc.helper.mq5" +#include "../Helpers/x-saherelm.xpv.helper.mq5" +#include "../Helpers/x-saherelm.xzg.helper.mq5" +#include "../Helpers/x-saherelm.xdon.helper.mq5" #include "../Helpers/x-saherelm.xche.helper.mq5" #include "../Helpers/x-saherelm.xosc.helper.mq5" #include "../Helpers/x-saherelm.xstr.helper.mq5" @@ -72,10 +75,13 @@ public: // XMCInputs mcInputs; // MC Inputs ... + XPVInputs pvInputs; // XPV Inputs ... + XZGInputs zgInputs; // XZG Inputs ... XSTRInputs strInputs; // STR Inputs ... XOSCInputs oscInputs; // OSC Inputs ... XCHEInputs cheInputs; // CHE Inputs ... XICHInputs ichInputs; // ICH Inputs ... + XDONInputs donInputs; // XDON Inputs ... // // Constructor ... @@ -121,10 +127,13 @@ public: { // mcInputs.Default(); + pvInputs.Default(); + zgInputs.Default(); strInputs.Default(); oscInputs.Default(); cheInputs.Default(); ichInputs.Default(); + donInputs.Default(); } // @@ -145,9 +154,13 @@ public: ENUM_TIMEFRAMES mHostPeriod, // Host Period ENUM_X_MARKET_CYCLES mCycle, // Init Cycle XMCInputs &mMcInputs, // MC Inputs + XPVInputs &mPvInputs, // XPV Inputs ... + XZGInputs &mZgInputs, // XZG Inputs ... XSTRInputs &mStrInputs, // STR Inputs XOSCInputs &mOscInputs, // OSC Inputs XCHEInputs &mCheInputs, // CHE Inputs + XICHInputs &mIchInputs, // ICH Inputs ... + XDONInputs &mDonInputs, // XDON Inputs ... int mHostBarIndex = 0, // Specified Host Period Bar Index string mPrefix = "" // Prefix ) @@ -171,9 +184,13 @@ public: // mcInputs = mMcInputs; + pvInputs = mPvInputs; + zgInputs = mZgInputs; strInputs = mStrInputs; oscInputs = mOscInputs; cheInputs = mCheInputs; + ichInputs = mIchInputs; + donInputs = mDonInputs; // result = IsValid(); @@ -195,10 +212,13 @@ public: // mcInputs.Clean(); + pvInputs.Clean(); + zgInputs.Clean(); strInputs.Clean(); oscInputs.Clean(); cheInputs.Clean(); ichInputs.Clean(); + donInputs.Clean(); // cBarDrawSpecs.Clean(); @@ -220,10 +240,13 @@ public: { // mcInputs.Default(); + pvInputs.Default(); + zgInputs.Default(); strInputs.Default(); oscInputs.Default(); cheInputs.Default(); ichInputs.Default(); + donInputs.Default(); // drawLabels = false; @@ -254,6 +277,20 @@ public: return result; } + // + result = pvInputs.IsValid(); + if (!result) + { + return result; + } + + // + result = zgInputs.IsValid(); + if (!result) + { + return result; + } + // result = strInputs.IsValid(); if (!result) @@ -282,6 +319,13 @@ public: return result; } + // + result = donInputs.IsValid(); + if (!result) + { + return result; + } + // return result; } @@ -297,9 +341,14 @@ public: result = MathMax(mcInputs.Max(), strInputs.Max()); // + result = MathMax(result, mcInputs.Max()); + result = MathMax(result, pvInputs.Max()); + result = MathMax(result, zgInputs.Max()); + result = MathMax(result, strInputs.Max()); result = MathMax(result, oscInputs.Max()); result = MathMax(result, cheInputs.Max()); result = MathMax(result, ichInputs.Max()); + result = MathMax(result, donInputs.Max()); // return result; @@ -357,6 +406,11 @@ public: double strTrends[]; double strStates[]; + // + // XZG ... + double zigzags[]; + double zigzagPVs[]; + // // XCHE ... double cheLongExit1s[]; @@ -364,6 +418,37 @@ public: double cheShortExit1s[]; double cheShortExit2s[]; + // + // XDON ... + double donUpperOs[]; + double donLowerOs[]; + double donUpperCs[]; + double donLowerCs[]; + double donUpperHs[]; + double donLowerHs[]; + double donUpperLs[]; + double donLowerLs[]; + + // + // XPV ... + double pvPeaks[]; + double pvVales[]; + double pvResistances[]; + double pvSupports[]; + double pvFib1s[]; + double pvFib2s[]; + double pvFib3s[]; + double pvFib4s[]; + double pvFib5s[]; + double pvSCHHs[]; + double pvSCLLs[]; + double pvMCHHs[]; + double pvMCLLs[]; + double pvLCHHs[]; + double pvLCLLs[]; + double pvHCHHs[]; + double pvHCLLs[]; + // // XOSC ... double oscAtrs[]; @@ -382,6 +467,92 @@ public: double oscStochSignals[]; double oscStddevs[]; + // + // XZG ... + + // + bool isZigZagInPeak; + bool isZigZagInVale; + + // + // XDON ... + + // + bool isDONAttachedMaxLower; + bool isDONAttachedMinLower; + bool isDONCrossedOverMaxLower; + bool isDONCrossedUnderMaxLower; + + // + bool isDONAttachedMaxUpper; + bool isDONAttachedMinUpper; + bool isDONCrossedOverMaxUpper; + bool isDONCrossedUnderMaxUpper; + + // + // XPV ... + + // + bool isPVPeakSameAs; + bool isPVNewPeak; + bool isPVNewPeakOverLast; + bool isPVNewPeakUnderLast; + bool isPVValeSameAs; + bool isPVNewVale; + bool isPVNewValeOverLast; + bool isPVNewValeUnderLast; + bool isPVFiboIncreased; + bool isPVFiboDecreased; + bool isPVFiboSectionChanged; + + // + bool isPVSCBullish; + bool isPVSCHHBullish; + bool isPVSCLLBullish; + bool isPVSCSwitchedToBullish; + + // + bool isPVSCBearish; + bool isPVSCHHBearish; + bool isPVSCLLBearish; + bool isPVSCSwitchedToBearish; + + // + bool isPVMCBullish; + bool isPVMCHHBullish; + bool isPVMCLLBullish; + bool isPVMCSwitchedToBullish; + + // + bool isPVMCBearish; + bool isPVMCHHBearish; + bool isPVMCLLBearish; + bool isPVMCSwitchedToBearish; + + // + bool isPVLCBullish; + bool isPVLCHHBullish; + bool isPVLCLLBullish; + bool isPVLCSwitchedToBullish; + + // + bool isPVLCBearish; + bool isPVLCHHBearish; + bool isPVLCLLBearish; + bool isPVLCSwitchedToBearish; + + // + bool isPVHCBullish; + bool isPVHCHHBullish; + bool isPVHCLLBullish; + bool isPVHCSwitchedToBullish; + + // + bool isPVHCBearish; + bool isPVHCHHBearish; + bool isPVHCLLBearish; + bool isPVHCSwitchedToBearish; + // // XICH ... // Ichimoku strategy @@ -870,6 +1041,33 @@ public: Clean(oscStochMains); Clean(oscStochSignals); Clean(oscStddevs); + Clean(zigzags); + Clean(zigzagPVs); + Clean(donUpperOs); + Clean(donLowerOs); + Clean(donUpperCs); + Clean(donLowerCs); + Clean(donUpperHs); + Clean(donLowerHs); + Clean(donUpperLs); + Clean(donLowerLs); + Clean(pvPeaks); + Clean(pvVales); + Clean(pvResistances); + Clean(pvSupports); + Clean(pvFib1s); + Clean(pvFib2s); + Clean(pvFib3s); + Clean(pvFib4s); + Clean(pvFib5s); + Clean(pvSCHHs); + Clean(pvSCLLs); + Clean(pvMCHHs); + Clean(pvMCLLs); + Clean(pvLCHHs); + Clean(pvLCLLs); + Clean(pvHCHHs); + Clean(pvHCLLs); // // Buffers ... @@ -903,6 +1101,88 @@ public: ArraySetAsSeries(oscStochMains, true); ArraySetAsSeries(oscStochSignals, true); ArraySetAsSeries(oscStddevs, true); + ArraySetAsSeries(zigzags, true); + ArraySetAsSeries(zigzagPVs, true); + ArraySetAsSeries(donUpperOs, true); + ArraySetAsSeries(donLowerOs, true); + ArraySetAsSeries(donUpperCs, true); + ArraySetAsSeries(donLowerCs, true); + ArraySetAsSeries(donUpperHs, true); + ArraySetAsSeries(donLowerHs, true); + ArraySetAsSeries(donUpperLs, true); + ArraySetAsSeries(donLowerLs, true); + ArraySetAsSeries(pvPeaks, true); + ArraySetAsSeries(pvVales, true); + ArraySetAsSeries(pvResistances, true); + ArraySetAsSeries(pvSupports, true); + ArraySetAsSeries(pvFib1s, true); + ArraySetAsSeries(pvFib2s, true); + ArraySetAsSeries(pvFib3s, true); + ArraySetAsSeries(pvFib4s, true); + ArraySetAsSeries(pvFib5s, true); + ArraySetAsSeries(pvSCHHs, true); + ArraySetAsSeries(pvSCLLs, true); + ArraySetAsSeries(pvMCHHs, true); + ArraySetAsSeries(pvMCLLs, true); + ArraySetAsSeries(pvLCHHs, true); + ArraySetAsSeries(pvLCLLs, true); + ArraySetAsSeries(pvHCHHs, true); + ArraySetAsSeries(pvHCLLs, true); + + // + isZigZagInPeak = false; + isZigZagInVale = false; + isDONAttachedMaxLower = false; + isDONAttachedMinLower = false; + isDONCrossedOverMaxLower = false; + isDONCrossedUnderMaxLower = false; + isDONAttachedMaxUpper = false; + isDONAttachedMinUpper = false; + isDONCrossedOverMaxUpper = false; + isDONCrossedUnderMaxUpper = false; + isPVPeakSameAs = false; + isPVNewPeak = false; + isPVNewPeakOverLast = false; + isPVNewPeakUnderLast = false; + isPVValeSameAs = false; + isPVNewVale = false; + isPVNewValeOverLast = false; + isPVNewValeUnderLast = false; + isPVFiboIncreased = false; + isPVFiboDecreased = false; + isPVFiboSectionChanged = false; + isPVSCBullish = false; + isPVSCHHBullish = false; + isPVSCLLBullish = false; + isPVSCSwitchedToBullish = false; + isPVSCBearish = false; + isPVSCHHBearish = false; + isPVSCLLBearish = false; + isPVSCSwitchedToBearish = false; + isPVMCBullish = false; + isPVMCHHBullish = false; + isPVMCLLBullish = false; + isPVMCSwitchedToBullish = false; + isPVMCBearish = false; + isPVMCHHBearish = false; + isPVMCLLBearish = false; + isPVMCSwitchedToBearish = false; + isPVLCBullish = false; + isPVLCHHBullish = false; + isPVLCLLBullish = false; + isPVLCSwitchedToBullish = false; + isPVLCBearish = false; + isPVLCHHBearish = false; + isPVLCLLBearish = false; + isPVLCSwitchedToBearish = false; + isPVHCBullish = false; + isPVHCHHBullish = false; + isPVHCLLBullish = false; + isPVHCSwitchedToBullish = false; + isPVHCBearish = false; + isPVHCHHBearish = false; + isPVHCLLBearish = false; + isPVHCSwitchedToBearish = false; // // XTSR ... @@ -1077,6 +1357,269 @@ public: bearScore++; } + // + // XZG ... + if (isZigZagInPeak) + { + // + bullScore--; + bearScore++; + } + if (isZigZagInVale) + { + // + bullScore++; + bearScore--; + } + + // + // XDON ... + if (isDONAttachedMaxLower) + { + // + bullScore++; + bearScore--; + } + if (isDONAttachedMinLower) + { + bearScore++; + } + if (isDONCrossedOverMaxLower) + { + // + bullScore++; + bearScore--; + } + if (isDONCrossedUnderMaxLower) + { + // + bullScore--; + bearScore++; + } + if (isDONAttachedMaxUpper) + { + // + bullScore--; + bearScore++; + } + if (isDONAttachedMinUpper) + { + bullScore++; + } + if (isDONCrossedOverMaxUpper) + { + // + bullScore++; + bearScore--; + } + if (isDONCrossedUnderMaxUpper) + { + // + bullScore--; + bearScore++; + } + + // + // XPV ... + if (isPVPeakSameAs) + { + } + if (isPVNewPeak) + { + } + if (isPVNewPeakOverLast) + { + // + bullScore--; + bearScore++; + } + if (isPVNewPeakUnderLast) + { + // + bullScore++; + bearScore--; + } + if (isPVValeSameAs) + { + } + if (isPVNewVale) + { + } + if (isPVNewValeOverLast) + { + // + bullScore--; + bearScore++; + } + if (isPVNewValeUnderLast) + { + // + bullScore++; + bearScore--; + } + if (isPVFiboSectionChanged) + { + // + if (isPVFiboIncreased) + { + // + bullScore++; + bearScore--; + } + if (isPVFiboDecreased) + { + // + bullScore--; + bearScore++; + } + } + + // + if (isPVSCBullish) + { + bullScore++; + } + if (isPVSCHHBullish) + { + bullScore--; + } + if (isPVSCLLBullish) + { + bullScore++; + } + if (isPVSCSwitchedToBullish) + { + // + bullScore++; + bearScore--; + } + if (isPVSCBearish) + { + bearScore++; + } + if (isPVSCHHBearish) + { + bearScore--; + } + if (isPVSCLLBearish) + { + bearScore++; + } + if (isPVSCSwitchedToBearish) + { + // + bullScore--; + bearScore++; + } + if (isPVMCBullish) + { + bullScore++; + } + if (isPVMCHHBullish) + { + bullScore--; + } + if (isPVMCLLBullish) + { + bullScore++; + } + if (isPVMCSwitchedToBullish) + { + // + bullScore++; + bearScore--; + } + if (isPVMCBearish) + { + bullScore++; + } + if (isPVMCHHBearish) + { + bearScore--; + } + if (isPVMCLLBearish) + { + bearScore++; + } + if (isPVMCSwitchedToBearish) + { + // + bullScore--; + bearScore++; + } + if (isPVLCBullish) + { + bullScore++; + } + if (isPVLCHHBullish) + { + bullScore--; + } + if (isPVLCLLBullish) + { + bullScore++; + } + if (isPVLCSwitchedToBullish) + { + // + bullScore++; + bullScore--; + } + if (isPVLCBearish) + { + bearScore++; + } + if (isPVLCHHBearish) + { + bearScore--; + } + if (isPVLCLLBearish) + { + bearScore++; + } + if (isPVLCSwitchedToBearish) + { + // + bullScore--; + bearScore++; + } + if (isPVHCBullish) + { + bullScore++; + } + if (isPVHCHHBullish) + { + bullScore--; + } + if (isPVHCLLBullish) + { + bullScore++; + } + if (isPVHCSwitchedToBullish) + { + // + bullScore++; + bearScore--; + } + if (isPVHCBearish) + { + bearScore++; + } + if (isPVHCHHBearish) + { + bearScore--; + } + if (isPVHCLLBearish) + { + bearScore++; + } + if (isPVHCSwitchedToBearish) + { + // + bullScore--; + bearScore++; + } + // // XSTR ... if (isTrendBullish) @@ -1624,6 +2167,17 @@ public: ; candlesticStr = SetLabel("Candelstick: ", candlesticStr, separator); + // + // XZG ... + string zigzagStr = + // + ToString("isZigZagInPeak", isZigZagInPeak, ignoreFalseConditions) + + ToString("isZigZagInVale", isZigZagInVale, ignoreFalseConditions) + + "" + // + ; + zigzagStr = SetLabel("XZG: ", zigzagStr, separator); + // // XSTR ... string strStr = @@ -1652,6 +2206,23 @@ public: ; cheStr = SetLabel("XCHE: ", cheStr, separator); + // + // XDON ... + string donStr = + // + ToString("isDONAttachedMaxLower", isDONAttachedMaxLower, ignoreFalseConditions) + + ToString("isDONAttachedMinLower", isDONAttachedMinLower, ignoreFalseConditions) + + ToString("isDONCrossedOverMaxLower", isDONCrossedOverMaxLower, ignoreFalseConditions) + + ToString("isDONCrossedUnderMaxLower", isDONCrossedUnderMaxLower, ignoreFalseConditions) + + ToString("isDONAttachedMaxUpper", isDONAttachedMaxUpper, ignoreFalseConditions) + + ToString("isDONAttachedMinUpper", isDONAttachedMinUpper, ignoreFalseConditions) + + ToString("isDONCrossedOverMaxUpper", isDONCrossedOverMaxUpper, ignoreFalseConditions) + + ToString("isDONCrossedUnderMaxUpper", isDONCrossedUnderMaxUpper, ignoreFalseConditions) + + "" + // + ; + donStr = SetLabel("XDON: ", donStr, separator); + // // XICH ... string ichStr = @@ -1700,6 +2271,58 @@ public: ; mcStr = SetLabel("XMC: ", mcStr, separator); + // + // XPV ... + string pvStr = + // + ToString("isPVPeakSameAs", isPVPeakSameAs, ignoreFalseConditions) + + ToString("isPVNewPeak", isPVNewPeak, ignoreFalseConditions) + + ToString("isPVNewPeakOverLast", isPVNewPeakOverLast, ignoreFalseConditions) + + ToString("isPVNewPeakUnderLast", isPVNewPeakUnderLast, ignoreFalseConditions) + + ToString("isPVValeSameAs", isPVValeSameAs, ignoreFalseConditions) + + ToString("isPVNewVale", isPVNewVale, ignoreFalseConditions) + + ToString("isPVNewValeOverLast", isPVNewValeOverLast, ignoreFalseConditions) + + ToString("isPVNewValeUnderLast", isPVNewValeUnderLast, ignoreFalseConditions) + + ToString("isPVFiboIncreased", isPVFiboIncreased, ignoreFalseConditions) + + ToString("isPVFiboDecreased", isPVFiboDecreased, ignoreFalseConditions) + + ToString("isPVFiboSectionChanged", isPVFiboSectionChanged, ignoreFalseConditions) + + ToString("isPVSCBullish", isPVSCBullish, ignoreFalseConditions) + + ToString("isPVSCHHBullish", isPVSCHHBullish, ignoreFalseConditions) + + ToString("isPVSCLLBullish", isPVSCLLBullish, ignoreFalseConditions) + + ToString("isPVSCSwitchedToBullish", isPVSCSwitchedToBullish, ignoreFalseConditions) + + ToString("isPVSCBearish", isPVSCBearish, ignoreFalseConditions) + + ToString("isPVSCHHBearish", isPVSCHHBearish, ignoreFalseConditions) + + ToString("isPVSCLLBearish", isPVSCLLBearish, ignoreFalseConditions) + + ToString("isPVSCSwitchedToBearish", isPVSCSwitchedToBearish, ignoreFalseConditions) + + ToString("isPVMCBullish", isPVMCBullish, ignoreFalseConditions) + + ToString("isPVMCHHBullish", isPVMCHHBullish, ignoreFalseConditions) + + ToString("isPVMCLLBullish", isPVMCLLBullish, ignoreFalseConditions) + + ToString("isPVMCSwitchedToBullish", isPVMCSwitchedToBullish, ignoreFalseConditions) + + ToString("isPVMCBearish", isPVMCBearish, ignoreFalseConditions) + + ToString("isPVMCHHBearish", isPVMCHHBearish, ignoreFalseConditions) + + ToString("isPVMCLLBearish", isPVMCLLBearish, ignoreFalseConditions) + + ToString("isPVMCSwitchedToBearish", isPVMCSwitchedToBearish, ignoreFalseConditions) + + ToString("isPVLCBullish", isPVLCBullish, ignoreFalseConditions) + + ToString("isPVLCHHBullish", isPVLCHHBullish, ignoreFalseConditions) + + ToString("isPVLCLLBullish", isPVLCLLBullish, ignoreFalseConditions) + + ToString("isPVLCSwitchedToBullish", isPVLCSwitchedToBullish, ignoreFalseConditions) + + ToString("isPVLCBearish", isPVLCBearish, ignoreFalseConditions) + + ToString("isPVLCHHBearish", isPVLCHHBearish, ignoreFalseConditions) + + ToString("isPVLCLLBearish", isPVLCLLBearish, ignoreFalseConditions) + + ToString("isPVLCSwitchedToBearish", isPVLCSwitchedToBearish, ignoreFalseConditions) + + ToString("isPVHCBullish", isPVHCBullish, ignoreFalseConditions) + + ToString("isPVHCHHBullish", isPVHCHHBullish, ignoreFalseConditions) + + ToString("isPVHCLLBullish", isPVHCLLBullish, ignoreFalseConditions) + + ToString("isPVHCSwitchedToBullish", isPVHCSwitchedToBullish, ignoreFalseConditions) + + ToString("isPVHCBearish", isPVHCBearish, ignoreFalseConditions) + + ToString("isPVHCHHBearish", isPVHCHHBearish, ignoreFalseConditions) + + ToString("isPVHCLLBearish", isPVHCLLBearish, ignoreFalseConditions) + + ToString("isPVHCSwitchedToBearish", isPVHCSwitchedToBearish, ignoreFalseConditions) + + "" + // + ; + pvStr = SetLabel("XPV: ", pvStr, separator); + // // XOSC ... @@ -1832,11 +2455,15 @@ public: candlesticStr + (onlySummary ? "" - : strStr + + : zigzagStr + + strStr + cheStr + + donStr + ichStr + mcStr + - oscStr // + pvStr + + oscStr + + "" // ) + "" // @@ -1897,10 +2524,13 @@ public: // // Props ... XSCXMCHelper mc; + XSCXPVHelper pv; + XSCXZGHelper zg; XSCXSTRHelper str; XSCXCHEHelper che; XSCXOSCHelper osc; XSCXICHHelper ich; + XSCXDONHelper don; // // Properties ... @@ -2137,6 +2767,654 @@ public: conditions.isCurrentMidLineOverLastMidLine = isCurrentMidLineOverLastMidLine; conditions.isCurrentMidLineUnderLastMidLine = isCurrentMidLineUnderLastMidLine; + // + // XZG ... + + // + zg.CopyMain( + barIndex, + mNumberOfItems, + conditions.zigzags // + ); + + // + zg.CopyPeaksAndVales( + barIndex, + mNumberOfItems, + conditions.zigzagPVs // + ); + + // + // Looking for Vale ... + bool isZigZagInPeak = conditions.zigzags[curr] < conditions.zigzagPVs[curr]; + conditions.isZigZagInPeak = isZigZagInPeak; + + // + // Looking for Peak ... + bool isZigZagInVale = conditions.zigzags[curr] > conditions.zigzagPVs[curr]; + conditions.isZigZagInVale = isZigZagInVale; + + // + // XDON ... + + // + don.CopyUpperO( + barIndex, + mNumberOfItems, + conditions.donUpperOs // + ); + don.CopyLowerO( + barIndex, + mNumberOfItems, + conditions.donLowerOs // + ); + don.CopyUpperC( + barIndex, + mNumberOfItems, + conditions.donUpperCs // + ); + don.CopyLowerC( + barIndex, + mNumberOfItems, + conditions.donLowerCs // + ); + don.CopyUpperH( + barIndex, + mNumberOfItems, + conditions.donUpperHs // + ); + don.CopyLowerH( + barIndex, + mNumberOfItems, + conditions.donLowerHs // + ); + don.CopyUpperL( + barIndex, + mNumberOfItems, + conditions.donUpperLs // + ); + don.CopyLowerL( + barIndex, + mNumberOfItems, + conditions.donLowerLs // + ); + + // + // Upper ... + + // + double donUpperO = conditions.donUpperOs[curr]; + double donUpperOPrev = conditions.donUpperOs[prev]; + + // + double donUpperC = conditions.donUpperCs[curr]; + double donUpperCPrev = conditions.donUpperCs[prev]; + + // + double donUpperH = conditions.donUpperHs[curr]; + double donUpperHPrev = conditions.donUpperHs[prev]; + + // + double donUpperL = conditions.donUpperLs[curr]; + double donUpperLPrev = conditions.donUpperLs[prev]; + + // + double donUppers[] = { + donUpperO, + donUpperC, + donUpperH, + donUpperL // + }; + double maxDonUpper = GetMax(donUppers); + double minDonUpper = GetMin(donUppers); + + // + double donUpperPrevs[] = { + donUpperOPrev, + donUpperCPrev, + donUpperHPrev, + donUpperLPrev // + }; + double maxDonUpperPrev = GetMax(donUpperPrevs); + double minDonUpperPrev = GetMin(donUpperPrevs); + + // + // Lower ... + + // + double donLowerO = conditions.donLowerOs[curr]; + double donLowerOPrev = conditions.donLowerOs[prev]; + + // + double donLowerC = conditions.donLowerCs[curr]; + double donLowerCPrev = conditions.donLowerCs[prev]; + + // + double donLowerH = conditions.donLowerHs[curr]; + double donLowerHPrev = conditions.donLowerHs[prev]; + + // + double donLowerL = conditions.donLowerLs[curr]; + double donLowerLPrev = conditions.donLowerLs[prev]; + + // + double donLowers[] = { + donLowerO, + donLowerC, + donLowerH, + donLowerL // + }; + double maxDonLower = GetMax(donLowers); + double minDonLower = GetMin(donLowers); + + // + double donLowerPrevs[] = { + donLowerOPrev, + donLowerCPrev, + donLowerHPrev, + donLowerLPrev // + }; + double maxDonLowerPrev = GetMax(donLowerPrevs); + double minDonLowerPrev = GetMin(donLowerPrevs); + + // + bool isDONAttachedMaxLower = conditions.bars[curr].low == maxDonLower; + bool isDONAttachedMinLower = conditions.bars[curr].low == minDonLower; + bool isDONCrossedOverMaxLower = + // + ((conditions.bars[curr].low > maxDonLower) || + (conditions.bars[curr].close > maxDonLower)) + // + && + // + ((conditions.bars[prev].high <= maxDonLower) || + (conditions.bars[prev].open <= maxDonLower)) + // + ; + bool isDONCrossedUnderMaxLower = + // + ((conditions.bars[curr].low < maxDonLower) || + (conditions.bars[curr].close < maxDonLower)) + // + && + // + ((conditions.bars[prev].high >= maxDonLower) || + (conditions.bars[prev].open >= maxDonLower)) + // + ; + + // + bool isDONAttachedMaxUpper = conditions.bars[curr].high == maxDonUpper; + bool isDONAttachedMinUpper = conditions.bars[curr].high == minDonUpper; + bool isDONCrossedOverMaxUpper = + // + ((conditions.bars[curr].low > maxDonUpper) || + (conditions.bars[curr].close > maxDonUpper)) + // + && + // + ((conditions.bars[prev].high <= maxDonUpper) || + (conditions.bars[prev].open <= maxDonUpper)) + // + ; + bool isDONCrossedUnderMaxUpper = + // + ((conditions.bars[curr].low < maxDonUpper) || + (conditions.bars[curr].close < maxDonUpper)) + // + && + // + ((conditions.bars[prev].high >= maxDonUpper) || + (conditions.bars[prev].open >= maxDonUpper)) + // + ; + + // + conditions.isDONAttachedMaxLower = isDONAttachedMaxLower; + conditions.isDONAttachedMinLower = isDONAttachedMinLower; + conditions.isDONCrossedOverMaxLower = isDONCrossedOverMaxLower; + conditions.isDONCrossedUnderMaxLower = isDONCrossedUnderMaxLower; + + // + conditions.isDONAttachedMaxUpper = isDONAttachedMaxUpper; + conditions.isDONAttachedMinUpper = isDONAttachedMinUpper; + conditions.isDONCrossedOverMaxUpper = isDONCrossedOverMaxUpper; + conditions.isDONCrossedUnderMaxUpper = isDONCrossedUnderMaxUpper; + + // + // XPV ... + + // + pv.CopyPeak( + barIndex, + mNumberOfItems, + conditions.pvPeaks // + ); + pv.CopyVale( + barIndex, + mNumberOfItems, + conditions.pvVales // + ); + pv.CopyResistance( + barIndex, + mNumberOfItems, + conditions.pvResistances // + ); + pv.CopySupport( + barIndex, + mNumberOfItems, + conditions.pvSupports // + ); + pv.CopyFib1( + barIndex, + mNumberOfItems, + conditions.pvFib1s // + ); + pv.CopyFib2( + barIndex, + mNumberOfItems, + conditions.pvFib2s // + ); + pv.CopyFib3( + barIndex, + mNumberOfItems, + conditions.pvFib3s // + ); + pv.CopyFib4( + barIndex, + mNumberOfItems, + conditions.pvFib4s // + ); + pv.CopyFib5( + barIndex, + mNumberOfItems, + conditions.pvFib5s // + ); + pv.CopySCHH( + barIndex, + mNumberOfItems, + conditions.pvSCHHs // + ); + pv.CopySCLL( + barIndex, + mNumberOfItems, + conditions.pvSCLLs // + ); + pv.CopyMCHH( + barIndex, + mNumberOfItems, + conditions.pvMCHHs // + ); + pv.CopyMCLL( + barIndex, + mNumberOfItems, + conditions.pvMCLLs // + ); + pv.CopyLCHH( + barIndex, + mNumberOfItems, + conditions.pvLCHHs // + ); + pv.CopyLCLL( + barIndex, + mNumberOfItems, + conditions.pvLCLLs // + ); + pv.CopyHCHH( + barIndex, + mNumberOfItems, + conditions.pvHCHHs // + ); + pv.CopyHCLL( + barIndex, + mNumberOfItems, + conditions.pvHCLLs // + ); + + // + double pvPeak = conditions.pvPeaks[curr]; + double pvPeakPrev = conditions.pvPeaks[prev]; + + // + double pvVale = conditions.pvVales[curr]; + double pvValePrev = conditions.pvVales[prev]; + + // + double pvFib1 = conditions.pvFib1s[curr]; + double pvFib2 = conditions.pvFib2s[curr]; + double pvFib3 = conditions.pvFib3s[curr]; + double pvFib4 = conditions.pvFib4s[curr]; + double pvFib5 = conditions.pvFib5s[curr]; + + // + double pvFib1Prev = conditions.pvFib1s[prev]; + double pvFib2Prev = conditions.pvFib2s[prev]; + double pvFib3Prev = conditions.pvFib3s[prev]; + double pvFib4Prev = conditions.pvFib4s[prev]; + double pvFib5Prev = conditions.pvFib5s[prev]; + + // + bool isPVPeakSameAs = IsSame(conditions.pvPeaks); + bool isPVNewPeak = NotEmpty(pvPeak) && pvPeak != pvPeakPrev; + bool isPVNewPeakOverLast = isPVNewPeak && pvPeak > pvPeakPrev; + bool isPVNewPeakUnderLast = isPVNewPeak && pvPeak < pvPeakPrev; + bool isPVValeSameAs = IsSame(conditions.pvVales); + bool isPVNewVale = NotEmpty(pvVale) && pvVale != pvValePrev; + bool isPVNewValeOverLast = isPVNewVale && pvVale > pvValePrev; + bool isPVNewValeUnderLast = isPVNewVale && pvVale < pvValePrev; + bool isPVFiboIncreased = + // + pvFib1 > pvFib1Prev && + pvFib2 > pvFib2Prev && + pvFib3 > pvFib3Prev && + pvFib4 > pvFib4Prev && + pvFib5 > pvFib5Prev + // + ; + bool isPVFiboDecreased = + // + pvFib1 < pvFib1Prev && + pvFib2 < pvFib2Prev && + pvFib3 < pvFib3Prev && + pvFib4 < pvFib4Prev && + pvFib5 < pvFib5Prev + // + ; + + bool isPVFiboSectionChanged = + // + (isPVNewPeakUnderLast && isPVFiboDecreased) + // + || + // + (isPVNewValeOverLast && isPVFiboIncreased) + // + ; + + // + conditions.isPVPeakSameAs = isPVPeakSameAs; + conditions.isPVNewPeak = isPVNewPeak; + conditions.isPVNewPeakOverLast = isPVNewPeakOverLast; + conditions.isPVNewPeakUnderLast = isPVNewPeakUnderLast; + conditions.isPVValeSameAs = isPVValeSameAs; + conditions.isPVNewVale = isPVNewVale; + conditions.isPVNewValeOverLast = isPVNewValeOverLast; + conditions.isPVNewValeUnderLast = isPVNewValeUnderLast; + conditions.isPVFiboIncreased = isPVFiboIncreased; + conditions.isPVFiboDecreased = isPVFiboDecreased; + conditions.isPVFiboSectionChanged = isPVFiboSectionChanged; + + // + // XPV Cycles ... + + // + double pvSCHH = conditions.pvSCHHs[curr]; + double pvSCLL = conditions.pvSCLLs[curr]; + double pvMCHH = conditions.pvMCHHs[curr]; + double pvMCLL = conditions.pvMCLLs[curr]; + double pvLCHH = conditions.pvLCHHs[curr]; + double pvLCLL = conditions.pvLCLLs[curr]; + double pvHCHH = conditions.pvHCHHs[curr]; + double pvHCLL = conditions.pvHCLLs[curr]; + + // + double pvSCHHPrev = conditions.pvSCHHs[prev]; + double pvSCLLPrev = conditions.pvSCLLs[prev]; + double pvMCHHPrev = conditions.pvMCHHs[prev]; + double pvMCLLPrev = conditions.pvMCLLs[prev]; + double pvLCHHPrev = conditions.pvLCHHs[prev]; + double pvLCLLPrev = conditions.pvLCLLs[prev]; + double pvHCHHPrev = conditions.pvHCHHs[prev]; + double pvHCLLPrev = conditions.pvHCLLs[prev]; + + // + double pvSCHHPrevPrev = conditions.pvSCHHs[prev + 1]; + double pvSCLLPrevPrev = conditions.pvSCLLs[prev + 1]; + double pvMCHHPrevPrev = conditions.pvMCHHs[prev + 1]; + double pvMCLLPrevPrev = conditions.pvMCLLs[prev + 1]; + double pvLCHHPrevPrev = conditions.pvLCHHs[prev + 1]; + double pvLCLLPrevPrev = conditions.pvLCLLs[prev + 1]; + double pvHCHHPrevPrev = conditions.pvHCHHs[prev + 1]; + double pvHCLLPrevPrev = conditions.pvHCLLs[prev + 1]; + + // + // Short ... + + // + bool isPVSCHHBullish = pvSCHH > pvSCHHPrev; + bool isPVSCHHBullishPrev = pvSCHHPrev > pvSCHHPrevPrev; + bool isPVSCLLBullish = pvSCLL > pvSCLLPrev; + bool isPVSCLLBullishPrev = pvSCLLPrev > pvSCLLPrevPrev; + bool isPVSCBullish = + // + isPVSCHHBullish && + isPVSCLLBullish + // + ; + bool isPVSCBullishPrev = + // + isPVSCHHBullishPrev && + isPVSCLLBullishPrev + // + ; + bool isPVSCSwitchedToBullish = + // + isPVSCBullish && + !isPVSCBullishPrev + // + ; + + // + bool isPVSCHHBearish = pvSCHH < pvSCHHPrev; + bool isPVSCHHBearishPrev = pvSCHHPrev < pvSCHHPrevPrev; + bool isPVSCLLBearish = pvSCLL < pvSCLLPrev; + bool isPVSCLLBearishPrev = pvSCLLPrev < pvSCLLPrevPrev; + bool isPVSCBearish = + // + isPVSCHHBearish && + isPVSCLLBearish + // + ; + bool isPVSCBearishPrev = + // + isPVSCHHBearishPrev && + isPVSCLLBearishPrev + // + ; + bool isPVSCSwitchedToBearish = + // + isPVSCBearish && + !isPVSCBearishPrev + // + ; + + // + // Medium ... + + // + bool isPVMCHHBullish = pvMCHH > pvMCHHPrev; + bool isPVMCHHBullishPrev = pvMCHHPrev > pvMCHHPrevPrev; + bool isPVMCLLBullish = pvMCLL > pvMCLLPrev; + bool isPVMCLLBullishPrev = pvMCLLPrev > pvMCLLPrevPrev; + bool isPVMCBullish = + // + isPVMCHHBullish && + isPVMCLLBullish + // + ; + bool isPVMCBullishPrev = + // + isPVMCHHBullishPrev && + isPVMCLLBullishPrev + // + ; + bool isPVMCSwitchedToBullish = + // + isPVMCBullish && + !isPVMCBullishPrev + // + ; + + // + bool isPVMCHHBearish = pvMCHH < pvMCHHPrev; + bool isPVMCHHBearishPrev = pvMCHHPrev < pvMCHHPrevPrev; + bool isPVMCLLBearish = pvMCLL < pvMCLLPrev; + bool isPVMCLLBearishPrev = pvMCLLPrev < pvMCLLPrevPrev; + bool isPVMCBearish = + // + isPVMCHHBearish && + isPVMCLLBearish + // + ; + bool isPVMCBearishPrev = + // + isPVMCHHBearishPrev && + isPVMCLLBearishPrev + // + ; + bool isPVMCSwitchedToBearish = + // + isPVMCBearish && + !isPVMCBearishPrev + // + ; + + // + // Long ... + + // + bool isPVLCHHBullish = pvLCHH > pvLCHHPrev; + bool isPVLCHHBullishPrev = pvLCHHPrev > pvLCHHPrevPrev; + bool isPVLCLLBullish = pvLCLL > pvLCLLPrev; + bool isPVLCLLBullishPrev = pvLCLLPrev > pvLCLLPrevPrev; + bool isPVLCBullish = + // + isPVLCHHBullish && + isPVLCLLBullish + // + ; + bool isPVLCBullishPrev = + // + isPVLCHHBullishPrev && + isPVLCLLBullishPrev + // + ; + bool isPVLCSwitchedToBullish = + // + isPVLCBullish && + !isPVLCBullishPrev + // + ; + + // + bool isPVLCHHBearish = pvLCHH < pvLCHHPrev; + bool isPVLCHHBearishPrev = pvLCHHPrev < pvLCHHPrevPrev; + bool isPVLCLLBearish = pvLCLL < pvLCLLPrev; + bool isPVLCLLBearishPrev = pvLCLLPrev < pvLCLLPrevPrev; + bool isPVLCBearish = + // + isPVLCHHBearish && + isPVLCLLBearish + // + ; + bool isPVLCBearishPrev = + // + isPVLCHHBearishPrev && + isPVLCLLBearishPrev + // + ; + bool isPVLCSwitchedToBearish = + // + isPVLCBearish && + !isPVLCBearishPrev + // + ; + + // + // Hind ... + + // + bool isPVHCHHBullish = pvHCHH > pvHCHHPrev; + bool isPVHCHHBullishPrev = pvHCHHPrev > pvHCHHPrevPrev; + bool isPVHCLLBullish = pvHCLL > pvHCLLPrev; + bool isPVHCLLBullishPrev = pvHCLLPrev > pvHCLLPrevPrev; + bool isPVHCBullish = + // + isPVHCHHBullish && + isPVHCLLBullish + // + ; + bool isPVHCBullishPrev = + // + isPVHCHHBullishPrev && + isPVHCLLBullishPrev + // + ; + bool isPVHCSwitchedToBullish = + // + isPVHCBullish && + !isPVHCBullishPrev + // + ; + + // + bool isPVHCHHBearish = pvHCHH < pvHCHHPrev; + bool isPVHCHHBearishPrev = pvHCHHPrev < pvHCHHPrevPrev; + bool isPVHCLLBearish = pvHCLL < pvHCLLPrev; + bool isPVHCLLBearishPrev = pvHCLLPrev < pvHCLLPrevPrev; + bool isPVHCBearish = + // + isPVHCHHBearish && + isPVHCLLBearish + // + ; + bool isPVHCBearishPrev = + // + isPVHCHHBearishPrev && + isPVHCLLBearishPrev + // + ; + bool isPVHCSwitchedToBearish = + // + isPVHCBearish && + !isPVHCBearishPrev + // + ; + + // + conditions.isPVSCHHBullish = isPVSCHHBullish; + conditions.isPVSCLLBullish = isPVSCLLBullish; + conditions.isPVSCBullish = isPVSCBullish; + conditions.isPVSCSwitchedToBullish = isPVSCSwitchedToBullish; + conditions.isPVSCHHBearish = isPVSCHHBearish; + conditions.isPVSCLLBearish = isPVSCLLBearish; + conditions.isPVSCBearish = isPVSCBearish; + conditions.isPVSCSwitchedToBearish = isPVSCSwitchedToBearish; + conditions.isPVMCHHBullish = isPVMCHHBullish; + conditions.isPVMCLLBullish = isPVMCLLBullish; + conditions.isPVMCBullish = isPVMCBullish; + conditions.isPVMCSwitchedToBullish = isPVMCSwitchedToBullish; + conditions.isPVMCHHBearish = isPVMCHHBearish; + conditions.isPVMCLLBearish = isPVMCLLBearish; + conditions.isPVMCBearish = isPVMCBearish; + conditions.isPVMCSwitchedToBearish = isPVMCSwitchedToBearish; + conditions.isPVLCHHBullish = isPVLCHHBullish; + conditions.isPVLCLLBullish = isPVLCLLBullish; + conditions.isPVLCBullish = isPVLCBullish; + conditions.isPVLCSwitchedToBullish = isPVLCSwitchedToBullish; + conditions.isPVLCHHBearish = isPVLCHHBearish; + conditions.isPVLCLLBearish = isPVLCLLBearish; + conditions.isPVLCBearish = isPVLCBearish; + conditions.isPVLCSwitchedToBearish = isPVLCSwitchedToBearish; + conditions.isPVHCHHBullish = isPVHCHHBullish; + conditions.isPVHCLLBullish = isPVHCLLBullish; + conditions.isPVHCBullish = isPVHCBullish; + conditions.isPVHCSwitchedToBullish = isPVHCSwitchedToBullish; + conditions.isPVHCHHBearish = isPVHCHHBearish; + conditions.isPVHCLLBearish = isPVHCLLBearish; + conditions.isPVHCBearish = isPVHCBearish; + conditions.isPVHCSwitchedToBearish = isPVHCSwitchedToBearish; + // // XSTR ... @@ -2993,6 +4271,32 @@ public: return result; } + // + // XPV ... + result = pv.Init( + symbol, + period, + mInputs.pvInputs + // + ); + if (!result) + { + return result; + } + + // + // XZG ... + result = zg.Init( + symbol, + period, + mInputs.zgInputs + // + ); + if (!result) + { + return result; + } + // // XSTR ... result = str.Init( @@ -3045,6 +4349,19 @@ public: return result; } + // + // XDON ... + result = don.Init( + symbol, + period, + mInputs.donInputs + // + ); + if (!result) + { + return result; + } + // return result; } diff --git a/Classes/x-saherelm.xea.class.mq5 b/Classes/x-saherelm.xea.class.mq5 index d6577428..8c1a8724 100644 --- a/Classes/x-saherelm.xea.class.mq5 +++ b/Classes/x-saherelm.xea.class.mq5 @@ -29,6 +29,14 @@ // Define On Signal Event Handler Type ... typedef void (*TOnSignal)(XSignal &signals[]); +// +// Model Account Profits ... +struct XProfitTracker { + // + int count; // Number of Positions ... + +}; + // // Class Definition ... @@ -535,7 +543,7 @@ public: // // Draw On Chart if anything is required ... virtual void Draw() {} - + // // Check For any Guard Actions ... virtual bool CheckForGuard(XGuard &guards[]) @@ -566,6 +574,19 @@ public: return false; } + // + // Regulary Filtered Signals passed to this + // and here we can do Additional Signal Filtering + // for Signal Management such as (Providers and etc) ... + virtual int HandleSignalManagement(XSignal &signals[]) + { + // + int result = ArraySize(signals); + + // + return result; + } + // // Here we Have to Check Market based // on our Strategy for Trading ... @@ -623,6 +644,13 @@ public: return; } + // + int managedSignalsCount = HandleSignalManagement(filteredSignals); + if (managedSignalsCount <= 0) + { + return; + } + // // Try to Execute Signals ... ENUM_X_SIGNAL_EXECUTION_RESULT reasons[]; diff --git a/Experts/x-test.x121ea.mq5 b/Experts/x-test.x121ea.mq5 index d74d717f..734b9314 100644 --- a/Experts/x-test.x121ea.mq5 +++ b/Experts/x-test.x121ea.mq5 @@ -34,14 +34,14 @@ long x121EAMagicNumber = 78692110; // Magic Number int x121EASlippage = 10; // Slippgae string x121EASymbols = "EURUSDb"; // Symbols // -bool x121EAAllowLong = true; // Allow Long Trades -bool x121EAAllowShort = true; // Allow Short Trades -int x121EAManageInterval = 5; // Manager Check Intervals Seconds -int x121EAMaxAllowedPositions = 0; // Max Allowed Positions -double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades -double x121EAMinProfitPerTrade = 0; // Min Profit Per Trade based On Volume Factor (Hedge) -double x121EAMinProfitPerVolumeFactor = 0; // Min Volume Factor for Calculating Profit (Hedge) -double x121EAMaxAllowedDrawdownFactor = 0; // Max Allowed Drawdown Factor +bool x121EAAllowLong = true; // Allow Long Trades +bool x121EAAllowShort = true; // Allow Short Trades +int x121EAManageInterval = 5; // Manager Check Intervals Seconds +int x121EAMaxAllowedPositions = 5; // Max Allowed Positions +double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades +double x121EAMinProfitPerTrade = 0.4; // Min Profit Per Trade based On Volume Factor (Hedge) +double x121EAMinProfitPerVolumeFactor = 0.01; // Min Volume Factor for Calculating Profit (Hedge) +double x121EAMaxAllowedDrawdownFactor = 0.015; // Max Allowed Drawdown Factor // double x121EAVolume = 0.01; @@ -313,8 +313,8 @@ bool InitialEA() string fontName = "Arial"; ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER; - //false - // Hind Market ... + // + // Hind Market ... iDescriptor.inputs.hMarketPeriod = NULL; iDescriptor.inputs.hMarketMethod = X_PERIOD_AUTO; iDescriptor.inputs.hMarketInputs.drawLabels = false; diff --git a/Helpers/x-saherelm.xdon.helper.mq5 b/Helpers/x-saherelm.xdon.helper.mq5 index 9ee6b2f3..3e7355d0 100644 --- a/Helpers/x-saherelm.xdon.helper.mq5 +++ b/Helpers/x-saherelm.xdon.helper.mq5 @@ -314,6 +314,24 @@ public: ); } + // + bool IsSameUpperO( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + upperOBuffer, + verifier, + barIndex // + ); + } + // // Lower ... @@ -367,6 +385,24 @@ public: ); } + // + bool IsSameLowerO( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lowerOBuffer, + verifier, + barIndex // + ); + } + // // Close ... @@ -423,6 +459,24 @@ public: ); } + // + bool IsSameUpperC( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + upperCBuffer, + verifier, + barIndex // + ); + } + // // Lower ... @@ -476,6 +530,24 @@ public: ); } + // + bool IsSameLowerC( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lowerCBuffer, + verifier, + barIndex // + ); + } + // // High ... @@ -532,6 +604,24 @@ public: ); } + // + bool IsSameUpperH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + upperHBuffer, + verifier, + barIndex // + ); + } + // // Lower ... @@ -585,6 +675,24 @@ public: ); } + // + bool IsSameLowerH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lowerHBuffer, + verifier, + barIndex // + ); + } + // // Low ... @@ -641,6 +749,24 @@ public: ); } + // + bool IsSameUpperL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + upperLBuffer, + verifier, + barIndex // + ); + } + // // Lower ... @@ -694,6 +820,24 @@ public: ); } + // + bool IsSameLowerL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lowerLBuffer, + verifier, + barIndex // + ); + } + // void GetUppers( double &result[], diff --git a/Helpers/x-saherelm.xich.helper.mq5 b/Helpers/x-saherelm.xich.helper.mq5 index 7509f3f4..3a1dcf97 100644 --- a/Helpers/x-saherelm.xich.helper.mq5 +++ b/Helpers/x-saherelm.xich.helper.mq5 @@ -362,6 +362,24 @@ public: ); } + // + bool IsSameTenkanSen( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + tenkanSenBuffer, + verifier, + barIndex // + ); + } + // // KijunSen ... @@ -408,6 +426,24 @@ public: ); } + // + bool IsSameKijunSen( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + kijunSenBuffer, + verifier, + barIndex // + ); + } + // // ChikouSpan ... @@ -518,6 +554,24 @@ public: ); } + // + bool IsSameSenkouSpanA( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + senkouSpanABuffer, + verifier, + barIndex // + ); + } + // // SenkouSpanB ... @@ -573,6 +627,24 @@ public: ); } + // + bool IsSameSenkouSpanB( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + senkouSpanBBuffer, + verifier, + barIndex // + ); + } + // // Future SenkouSpanA ... diff --git a/Helpers/x-saherelm.xpv.helper.mq5 b/Helpers/x-saherelm.xpv.helper.mq5 index 3e4ce052..b78b1831 100644 --- a/Helpers/x-saherelm.xpv.helper.mq5 +++ b/Helpers/x-saherelm.xpv.helper.mq5 @@ -477,6 +477,24 @@ public: ); } + // + bool IsSamePeak( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + peaksBuffer, + verifier, + barIndex // + ); + } + // // Vales ... @@ -530,6 +548,24 @@ public: ); } + // + bool IsSameVale( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + valesBuffer, + verifier, + barIndex // + ); + } + // // Resistance ... @@ -692,6 +728,24 @@ public: ); } + // + bool IsSameFib1( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + fib1Buffer, + verifier, + barIndex // + ); + } + // // Level 2 ... @@ -745,6 +799,24 @@ public: ); } + // + bool IsSameFib2( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + fib2Buffer, + verifier, + barIndex // + ); + } + // // Level 3 ... @@ -798,6 +870,24 @@ public: ); } + // + bool IsSameFib3( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + fib3Buffer, + verifier, + barIndex // + ); + } + // // Level 4 ... @@ -851,6 +941,24 @@ public: ); } + // + bool IsSameFib4( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + fib4Buffer, + verifier, + barIndex // + ); + } + // // Level 5 ... @@ -904,6 +1012,24 @@ public: ); } + // + bool IsSameFib5( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + fib5Buffer, + verifier, + barIndex // + ); + } + // // Cycles ... @@ -963,6 +1089,24 @@ public: ); } + // + bool IsSameSCHH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + scHHBuffer, + verifier, + barIndex // + ); + } + // // LL ... @@ -1016,6 +1160,24 @@ public: ); } + // + bool IsSameSCLL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + scLLBuffer, + verifier, + barIndex // + ); + } + // // Medium ... @@ -1072,6 +1234,24 @@ public: ); } + // + bool IsSameMCHH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + mcHHBuffer, + verifier, + barIndex // + ); + } + // // LL ... @@ -1125,6 +1305,24 @@ public: ); } + // + bool IsSameMCLL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + mcLLBuffer, + verifier, + barIndex // + ); + } + // // Long ... @@ -1181,6 +1379,24 @@ public: ); } + // + bool IsSameLCHH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lcHHBuffer, + verifier, + barIndex // + ); + } + // // LL ... @@ -1234,6 +1450,24 @@ public: ); } + // + bool IsSameLCLL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + lcLLBuffer, + verifier, + barIndex // + ); + } + // // Hind ... @@ -1290,6 +1524,24 @@ public: ); } + // + bool IsSameHCHH( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + hcHHBuffer, + verifier, + barIndex // + ); + } + // // LL ... @@ -1343,6 +1595,24 @@ public: ); } + // + bool IsSameHCLL( + int barIndex, // Start Bar Index + int verifier = 71 // Number of Verifiers + ) + { + // + // Update Calculations ... + Calculate(); + + // + return IsSame( + hcLLBuffer, + verifier, + barIndex // + ); + } + // // Protected ... protected: diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index f4367ab1..7c9fc319 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -3630,8 +3630,9 @@ MqlDateTime GetBarTimeStruct( // template bool IsSame( - T &buffer[], // Search Buffer - int count = 5 // Number of Searchs + T &buffer[], // Search Buffer + int count = 5, // Number of Searchs + int start = 0 // Start ... ) { // @@ -3647,15 +3648,15 @@ bool IsSame( // // Validate Count ... - result = count < bufferSize; + result = start + count < bufferSize; if (!result) { return result; } // - T iTem = buffer[0]; - for (int i = 0; i < count; i++) + T iTem = buffer[start]; + for (int i = start; i < start + count; i++) { // if (iTem != buffer[i])