From 25b027d2aa16176d8db941ce906b195b3fb0ec4f Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 23 May 2024 07:46:43 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.provider.class.mq5 | 1199 +++++++++++++++++++- Classes/x-saherelm.x121.xmcycle.class.mq5 | 180 ++- Classes/x-saherelm.x5.provider.class.mq5 | 29 +- Documents/BKP/required-long-conditions.mq5 | 286 +++++ Experts/x-test.x121ea.mq5 | 35 +- Helpers/x-saherelm.xzg.helper.mq5 | 4 +- 6 files changed, 1661 insertions(+), 72 deletions(-) create mode 100644 Documents/BKP/required-long-conditions.mq5 diff --git a/Classes/x-saherelm.x121.provider.class.mq5 b/Classes/x-saherelm.x121.provider.class.mq5 index 10fe5d90..6b043841 100644 --- a/Classes/x-saherelm.x121.provider.class.mq5 +++ b/Classes/x-saherelm.x121.provider.class.mq5 @@ -528,6 +528,10 @@ public: double zigzags[]; double zigzagPVs[]; + // + bool isZigZagInPeak; + bool isZigZagInVale; + // // XDON ... double donUpperOs[]; @@ -539,6 +543,18 @@ public: double donUpperLs[]; double donLowerLs[]; + // + bool isDONAttachedMaxLower; + bool isDONAttachedMinLower; + bool isDONCrossedOverMaxLower; + bool isDONCrossedUnderMaxLower; + + // + bool isDONAttachedMaxUpper; + bool isDONAttachedMinUpper; + bool isDONCrossedOverMaxUpper; + bool isDONCrossedUnderMaxUpper; + // // XPV ... double pvPeaks[]; @@ -559,6 +575,67 @@ public: double pvHCHHs[]; double pvHCLLs[]; + // + 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; + // X121MCycleConditions cMarketConditions; // Current Market Conditions X121MCycleConditions sMarketConditions; // Short Market Conditions @@ -577,6 +654,66 @@ public: symbol = NULL; period = NULL; + // + Clean(bars); + 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); + + // + ArraySetAsSeries(bars, 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); + // cMarketConditions.Clear(); sMarketConditions.Clear(); @@ -592,8 +729,8 @@ public: double cMarketMultiplier = 1, // Current Market Score Multiplier double sMarketMultiplier = 1.1, // Short Market Score Multiplier double mMarketMultiplier = 1.2, // Medium Market Score Multiplier - double lMarketMultiplier = 1.3, // Long Market Score Multiplier - double hMarketMultiplier = 1.4 // Hind Market Score Multiplier + double lMarketMultiplier = 1.6, // Long Market Score Multiplier + double hMarketMultiplier = 1.8 // Hind Market Score Multiplier ) { // @@ -670,6 +807,272 @@ public: hMarketBearScore // ; + + // + // Handle Scores for Current Conditions ... + + // + // XZG ... + if (isZigZagInPeak) + { + // + bullishScore--; + bearishScore++; + } + if (isZigZagInVale) + { + // + bullishScore++; + bearishScore--; + } + + // + // XDON ... + if (isDONAttachedMaxLower) + { + // + bullishScore++; + bearishScore--; + } + if (isDONAttachedMinLower) + { + bearishScore++; + } + if (isDONCrossedOverMaxLower) + { + // + bullishScore++; + bearishScore--; + } + if (isDONCrossedUnderMaxLower) + { + // + bullishScore--; + bearishScore++; + } + if (isDONAttachedMaxUpper) + { + // + bullishScore--; + bearishScore++; + } + if (isDONAttachedMinUpper) + { + bullishScore++; + } + if (isDONCrossedOverMaxUpper) + { + // + bullishScore++; + bearishScore--; + } + if (isDONCrossedUnderMaxUpper) + { + // + bullishScore--; + bearishScore++; + } + + // + // XPV ... + if (isPVPeakSameAs) + { + } + if (isPVNewPeak) + { + } + if (isPVNewPeakOverLast) + { + // + bullishScore--; + bearishScore++; + } + if (isPVNewPeakUnderLast) + { + // + bullishScore++; + bearishScore--; + } + if (isPVValeSameAs) + { + } + if (isPVNewVale) + { + } + if (isPVNewValeOverLast) + { + // + bullishScore--; + bearishScore++; + } + if (isPVNewValeUnderLast) + { + // + bullishScore++; + bearishScore--; + } + if (isPVFiboSectionChanged) + { + // + if (isPVFiboIncreased) + { + // + bullishScore++; + bearishScore--; + } + if (isPVFiboDecreased) + { + // + bullishScore--; + bearishScore++; + } + } + + // + if (isPVSCBullish) + { + bullishScore++; + } + if (isPVSCHHBullish) + { + bullishScore--; + } + if (isPVSCLLBullish) + { + bullishScore++; + } + if (isPVSCSwitchedToBullish) + { + // + bullishScore++; + bearishScore--; + } + if (isPVSCBearish) + { + bearishScore++; + } + if (isPVSCHHBearish) + { + bearishScore--; + } + if (isPVSCLLBearish) + { + bearishScore++; + } + if (isPVSCSwitchedToBearish) + { + // + bullishScore--; + bearishScore++; + } + if (isPVMCBullish) + { + bullishScore++; + } + if (isPVMCHHBullish) + { + bullishScore--; + } + if (isPVMCLLBullish) + { + bullishScore++; + } + if (isPVMCSwitchedToBullish) + { + // + bullishScore++; + bearishScore--; + } + if (isPVMCBearish) + { + bullishScore++; + } + if (isPVMCHHBearish) + { + bearishScore--; + } + if (isPVMCLLBearish) + { + bearishScore++; + } + if (isPVMCSwitchedToBearish) + { + // + bullishScore--; + bearishScore++; + } + if (isPVLCBullish) + { + bullishScore++; + } + if (isPVLCHHBullish) + { + bullishScore--; + } + if (isPVLCLLBullish) + { + bullishScore++; + } + if (isPVLCSwitchedToBullish) + { + // + bullishScore++; + bullishScore--; + } + if (isPVLCBearish) + { + bearishScore++; + } + if (isPVLCHHBearish) + { + bearishScore--; + } + if (isPVLCLLBearish) + { + bearishScore++; + } + if (isPVLCSwitchedToBearish) + { + // + bullishScore--; + bearishScore++; + } + if (isPVHCBullish) + { + bullishScore++; + } + if (isPVHCHHBullish) + { + bullishScore--; + } + if (isPVHCLLBullish) + { + bullishScore++; + } + if (isPVHCSwitchedToBullish) + { + // + bullishScore++; + bearishScore--; + } + if (isPVHCBearish) + { + bearishScore++; + } + if (isPVHCHHBearish) + { + bearishScore--; + } + if (isPVHCLLBearish) + { + bearishScore++; + } + if (isPVHCSwitchedToBearish) + { + // + bullishScore--; + bearishScore++; + } } // @@ -677,8 +1080,8 @@ public: double cMarketMultiplier = 1, // Current Market Score Multiplier double sMarketMultiplier = 1.1, // Short Market Score Multiplier double mMarketMultiplier = 1.2, // Medium Market Score Multiplier - double lMarketMultiplier = 1.3, // Long Market Score Multiplier - double hMarketMultiplier = 1.4, // Hind Market Score Multiplier + double lMarketMultiplier = 1.6, // Long Market Score Multiplier + double hMarketMultiplier = 1.8, // Hind Market Score Multiplier const string separator = "\n", // Separator string provided = NULL, // Additional Info about Type, Provider and Symbol const bool ignoreFalseConditions = true // Ignore False Conditions @@ -715,6 +1118,7 @@ public: mMarketConditions.GetTitle() + separator + lMarketConditions.GetTitle() + separator + hMarketConditions.GetTitle() + separator + + "-----------" + separator + "Scores: " + separator + "-----------" + separator + "Bullish: " + ToString(bullScore) + separator + @@ -1158,8 +1562,6 @@ public: // // Reading Market Conditions ... GetMarketConditions(mConditions, barIndex); - string mConditionsStr = mConditions.GenerateSummary(); - Print(mConditionsStr); // int signalPusher = 0; @@ -1221,12 +1623,17 @@ public: // TODO: Make this Configurable ... string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); - double tpPoint = 30; + double tpPoint = 60; + double slPoint = 30; double volume = 0.01; double tpPrice = PointToPrice( tpPoint, symbol // ); + double slPrice = PointToPrice( + slPoint, + symbol // + ); ENUM_POSITION_TYPE type = hasLong ? POSITION_TYPE_BUY : POSITION_TYPE_SELL; @@ -1238,7 +1645,9 @@ public: double tp = hasLong ? entry + tpPrice : entry - tpPrice; - double sl = 0; + double sl = hasLong + ? entry - slPrice + : entry + slPrice; ENUM_X_SIGNAL_MANAGING_ACTIONS action = X_SIGNAL_USE_NOTHING; // @@ -1278,6 +1687,9 @@ public: // void Draw() { + // + return; + // // ulong chID = 0; @@ -1756,6 +2168,25 @@ private: int barIndex = 0 // Specified Bar Index ) { + // + mConditions.Clear(); + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex >= CountBars()) + { + barIndex = CountBars() + 2; + } + + // + int curr = barIndex + 1; + int prev = curr + 1; + // mConditions.symbol = GetSymbol(); mConditions.period = GetPeriod(); @@ -1765,38 +2196,698 @@ private: barIndex // ); + // + GetBars( + mConditions.bars, + mConditions.symbol, + mConditions.period, + barIndex, + mNumberOfItems // + ); + + // + // XZG ... + + // + zgHelper.CopyMain( + barIndex, + mNumberOfItems, + mConditions.zigzags // + ); + + // + zgHelper.CopyPeaksAndVales( + barIndex, + mNumberOfItems, + mConditions.zigzagPVs // + ); + + // + // Looking for Vale ... + bool isZigZagInPeak = mConditions.zigzags[curr] < mConditions.zigzagPVs[curr]; + mConditions.isZigZagInPeak = isZigZagInPeak; + + // + // Looking for Peak ... + bool isZigZagInVale = mConditions.zigzags[curr] > mConditions.zigzagPVs[curr]; + mConditions.isZigZagInVale = isZigZagInVale; + + // + // XDON ... + + // + donHelper.CopyUpperO( + barIndex, + mNumberOfItems, + mConditions.donUpperOs // + ); + donHelper.CopyLowerO( + barIndex, + mNumberOfItems, + mConditions.donLowerOs // + ); + donHelper.CopyUpperC( + barIndex, + mNumberOfItems, + mConditions.donUpperCs // + ); + donHelper.CopyLowerC( + barIndex, + mNumberOfItems, + mConditions.donLowerCs // + ); + donHelper.CopyUpperH( + barIndex, + mNumberOfItems, + mConditions.donUpperHs // + ); + donHelper.CopyLowerH( + barIndex, + mNumberOfItems, + mConditions.donLowerHs // + ); + donHelper.CopyUpperL( + barIndex, + mNumberOfItems, + mConditions.donUpperLs // + ); + donHelper.CopyLowerL( + barIndex, + mNumberOfItems, + mConditions.donLowerLs // + ); + + // + // Upper ... + + // + double donUpperO = mConditions.donUpperOs[curr]; + double donUpperOPrev = mConditions.donUpperOs[prev]; + + // + double donUpperC = mConditions.donUpperCs[curr]; + double donUpperCPrev = mConditions.donUpperCs[prev]; + + // + double donUpperH = mConditions.donUpperHs[curr]; + double donUpperHPrev = mConditions.donUpperHs[prev]; + + // + double donUpperL = mConditions.donUpperLs[curr]; + double donUpperLPrev = mConditions.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 = mConditions.donLowerOs[curr]; + double donLowerOPrev = mConditions.donLowerOs[prev]; + + // + double donLowerC = mConditions.donLowerCs[curr]; + double donLowerCPrev = mConditions.donLowerCs[prev]; + + // + double donLowerH = mConditions.donLowerHs[curr]; + double donLowerHPrev = mConditions.donLowerHs[prev]; + + // + double donLowerL = mConditions.donLowerLs[curr]; + double donLowerLPrev = mConditions.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 = mConditions.bars[curr].low == maxDonLower; + bool isDONAttachedMinLower = mConditions.bars[curr].low == minDonLower; + bool isDONCrossedOverMaxLower = + // + ((mConditions.bars[curr].low > maxDonLower) || + (mConditions.bars[curr].close > maxDonLower)) + // + && + // + ((mConditions.bars[prev].high <= maxDonLower) || + (mConditions.bars[prev].open <= maxDonLower)) + // + ; + bool isDONCrossedUnderMaxLower = + // + ((mConditions.bars[curr].low < maxDonLower) || + (mConditions.bars[curr].close < maxDonLower)) + // + && + // + ((mConditions.bars[prev].high >= maxDonLower) || + (mConditions.bars[prev].open >= maxDonLower)) + // + ; + + // + bool isDONAttachedMaxUpper = mConditions.bars[curr].high == maxDonUpper; + bool isDONAttachedMinUpper = mConditions.bars[curr].high == minDonUpper; + bool isDONCrossedOverMaxUpper = + // + ((mConditions.bars[curr].low > maxDonUpper) || + (mConditions.bars[curr].close > maxDonUpper)) + // + && + // + ((mConditions.bars[prev].high <= maxDonUpper) || + (mConditions.bars[prev].open <= maxDonUpper)) + // + ; + bool isDONCrossedUnderMaxUpper = + // + ((mConditions.bars[curr].low < maxDonUpper) || + (mConditions.bars[curr].close < maxDonUpper)) + // + && + // + ((mConditions.bars[prev].high >= maxDonUpper) || + (mConditions.bars[prev].open >= maxDonUpper)) + // + ; + + // + mConditions.isDONAttachedMaxLower = isDONAttachedMaxLower; + mConditions.isDONAttachedMinLower = isDONAttachedMinLower; + mConditions.isDONCrossedOverMaxLower = isDONCrossedOverMaxLower; + mConditions.isDONCrossedUnderMaxLower = isDONCrossedUnderMaxLower; + + // + mConditions.isDONAttachedMaxUpper = isDONAttachedMaxUpper; + mConditions.isDONAttachedMinUpper = isDONAttachedMinUpper; + mConditions.isDONCrossedOverMaxUpper = isDONCrossedOverMaxUpper; + mConditions.isDONCrossedUnderMaxUpper = isDONCrossedUnderMaxUpper; + + // + // XPV ... + + // + pvHelper.CopyPeak( + barIndex, + mNumberOfItems, + mConditions.pvPeaks // + ); + pvHelper.CopyVale( + barIndex, + mNumberOfItems, + mConditions.pvVales // + ); + pvHelper.CopyResistance( + barIndex, + mNumberOfItems, + mConditions.pvResistances // + ); + pvHelper.CopySupport( + barIndex, + mNumberOfItems, + mConditions.pvSupports // + ); + pvHelper.CopyFib1( + barIndex, + mNumberOfItems, + mConditions.pvFib1s // + ); + pvHelper.CopyFib2( + barIndex, + mNumberOfItems, + mConditions.pvFib2s // + ); + pvHelper.CopyFib3( + barIndex, + mNumberOfItems, + mConditions.pvFib3s // + ); + pvHelper.CopyFib4( + barIndex, + mNumberOfItems, + mConditions.pvFib4s // + ); + pvHelper.CopyFib5( + barIndex, + mNumberOfItems, + mConditions.pvFib5s // + ); + pvHelper.CopySCHH( + barIndex, + mNumberOfItems, + mConditions.pvSCHHs // + ); + pvHelper.CopySCLL( + barIndex, + mNumberOfItems, + mConditions.pvSCLLs // + ); + pvHelper.CopyMCHH( + barIndex, + mNumberOfItems, + mConditions.pvMCHHs // + ); + pvHelper.CopyMCLL( + barIndex, + mNumberOfItems, + mConditions.pvMCLLs // + ); + pvHelper.CopyLCHH( + barIndex, + mNumberOfItems, + mConditions.pvLCHHs // + ); + pvHelper.CopyLCLL( + barIndex, + mNumberOfItems, + mConditions.pvLCLLs // + ); + pvHelper.CopyHCHH( + barIndex, + mNumberOfItems, + mConditions.pvHCHHs // + ); + pvHelper.CopyHCLL( + barIndex, + mNumberOfItems, + mConditions.pvHCLLs // + ); + + // + double pvPeak = mConditions.pvPeaks[curr]; + double pvPeakPrev = mConditions.pvPeaks[prev]; + + // + double pvVale = mConditions.pvVales[curr]; + double pvValePrev = mConditions.pvVales[prev]; + + // + double pvFib1 = mConditions.pvFib1s[curr]; + double pvFib2 = mConditions.pvFib2s[curr]; + double pvFib3 = mConditions.pvFib3s[curr]; + double pvFib4 = mConditions.pvFib4s[curr]; + double pvFib5 = mConditions.pvFib5s[curr]; + + // + double pvFib1Prev = mConditions.pvFib1s[prev]; + double pvFib2Prev = mConditions.pvFib2s[prev]; + double pvFib3Prev = mConditions.pvFib3s[prev]; + double pvFib4Prev = mConditions.pvFib4s[prev]; + double pvFib5Prev = mConditions.pvFib5s[prev]; + + // + bool isPVPeakSameAs = IsSame(mConditions.pvPeaks); + bool isPVNewPeak = NotEmpty(pvPeak) && pvPeak != pvPeakPrev; + bool isPVNewPeakOverLast = isPVNewPeak && pvPeak > pvPeakPrev; + bool isPVNewPeakUnderLast = isPVNewPeak && pvPeak < pvPeakPrev; + bool isPVValeSameAs = IsSame(mConditions.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) + // + ; + + // + mConditions.isPVPeakSameAs = isPVPeakSameAs; + mConditions.isPVNewPeak = isPVNewPeak; + mConditions.isPVNewPeakOverLast = isPVNewPeakOverLast; + mConditions.isPVNewPeakUnderLast = isPVNewPeakUnderLast; + mConditions.isPVValeSameAs = isPVValeSameAs; + mConditions.isPVNewVale = isPVNewVale; + mConditions.isPVNewValeOverLast = isPVNewValeOverLast; + mConditions.isPVNewValeUnderLast = isPVNewValeUnderLast; + mConditions.isPVFiboIncreased = isPVFiboIncreased; + mConditions.isPVFiboDecreased = isPVFiboDecreased; + mConditions.isPVFiboSectionChanged = isPVFiboSectionChanged; + + // + // XPV Cycles ... + + // + double pvSCHH = mConditions.pvSCHHs[curr]; + double pvSCLL = mConditions.pvSCLLs[curr]; + double pvMCHH = mConditions.pvMCHHs[curr]; + double pvMCLL = mConditions.pvMCLLs[curr]; + double pvLCHH = mConditions.pvLCHHs[curr]; + double pvLCLL = mConditions.pvLCLLs[curr]; + double pvHCHH = mConditions.pvHCHHs[curr]; + double pvHCLL = mConditions.pvHCLLs[curr]; + + // + double pvSCHHPrev = mConditions.pvSCHHs[prev]; + double pvSCLLPrev = mConditions.pvSCLLs[prev]; + double pvMCHHPrev = mConditions.pvMCHHs[prev]; + double pvMCLLPrev = mConditions.pvMCLLs[prev]; + double pvLCHHPrev = mConditions.pvLCHHs[prev]; + double pvLCLLPrev = mConditions.pvLCLLs[prev]; + double pvHCHHPrev = mConditions.pvHCHHs[prev]; + double pvHCLLPrev = mConditions.pvHCLLs[prev]; + + // + double pvSCHHPrevPrev = mConditions.pvSCHHs[prev + 1]; + double pvSCLLPrevPrev = mConditions.pvSCLLs[prev + 1]; + double pvMCHHPrevPrev = mConditions.pvMCHHs[prev + 1]; + double pvMCLLPrevPrev = mConditions.pvMCLLs[prev + 1]; + double pvLCHHPrevPrev = mConditions.pvLCHHs[prev + 1]; + double pvLCLLPrevPrev = mConditions.pvLCLLs[prev + 1]; + double pvHCHHPrevPrev = mConditions.pvHCHHs[prev + 1]; + double pvHCLLPrevPrev = mConditions.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 + // + ; + + // + mConditions.isPVSCHHBullish = isPVSCHHBullish; + mConditions.isPVSCLLBullish = isPVSCLLBullish; + mConditions.isPVSCBullish = isPVSCBullish; + mConditions.isPVSCSwitchedToBullish = isPVSCSwitchedToBullish; + mConditions.isPVSCHHBearish = isPVSCHHBearish; + mConditions.isPVSCLLBearish = isPVSCLLBearish; + mConditions.isPVSCBearish = isPVSCBearish; + mConditions.isPVSCSwitchedToBearish = isPVSCSwitchedToBearish; + mConditions.isPVMCHHBullish = isPVMCHHBullish; + mConditions.isPVMCLLBullish = isPVMCLLBullish; + mConditions.isPVMCBullish = isPVMCBullish; + mConditions.isPVMCSwitchedToBullish = isPVMCSwitchedToBullish; + mConditions.isPVMCHHBearish = isPVMCHHBearish; + mConditions.isPVMCLLBearish = isPVMCLLBearish; + mConditions.isPVMCBearish = isPVMCBearish; + mConditions.isPVMCSwitchedToBearish = isPVMCSwitchedToBearish; + mConditions.isPVLCHHBullish = isPVLCHHBullish; + mConditions.isPVLCLLBullish = isPVLCLLBullish; + mConditions.isPVLCBullish = isPVLCBullish; + mConditions.isPVLCSwitchedToBullish = isPVLCSwitchedToBullish; + mConditions.isPVLCHHBearish = isPVLCHHBearish; + mConditions.isPVLCLLBearish = isPVLCLLBearish; + mConditions.isPVLCBearish = isPVLCBearish; + mConditions.isPVLCSwitchedToBearish = isPVLCSwitchedToBearish; + mConditions.isPVHCHHBullish = isPVHCHHBullish; + mConditions.isPVHCLLBullish = isPVHCLLBullish; + mConditions.isPVHCBullish = isPVHCBullish; + mConditions.isPVHCSwitchedToBullish = isPVHCSwitchedToBullish; + mConditions.isPVHCHHBearish = isPVHCHHBearish; + mConditions.isPVHCLLBearish = isPVHCLLBearish; + mConditions.isPVHCBearish = isPVHCBearish; + mConditions.isPVHCSwitchedToBearish = isPVHCSwitchedToBearish; + + // + // X121 Cycles Conditions ... + // cMarket.GetMarketConditions( mConditions.cMarketConditions, - 0, + barIndex, mNumberOfItems // ); // sMarket.GetMarketConditions( mConditions.sMarketConditions, - 0, + barIndex, mNumberOfItems // ); // mMarket.GetMarketConditions( mConditions.mMarketConditions, - 0, + barIndex, mNumberOfItems // ); // lMarket.GetMarketConditions( mConditions.lMarketConditions, - 0, + barIndex, mNumberOfItems // ); // hMarket.GetMarketConditions( mConditions.hMarketConditions, - 0, + barIndex, mNumberOfItems // ); } @@ -1839,6 +2930,38 @@ private: // bool result = false; + // + double bullishScore = 0; + double bearishScore = 0; + + // + mConditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + result = + // + mConditions.bars[1].low == mConditions.bars[2].low && + mConditions.bars[1].low == mConditions.pvVales[1] && + mConditions.bars[2].low == mConditions.pvVales[2] + // + ; + if (result) + { + // + Print("bullishScore: " + ToString(bullishScore)); + Print("bearishScore: " + ToString(bearishScore)); + + // + Print(mConditions.GenerateSummary()); + + // + Print(mConditions.pvVales[0]); + ArrayPrint(mConditions.pvVales); + } + // return result; } @@ -1911,6 +3034,56 @@ private: // bool result = false; + // // + // double bullishScore = 0; + // double bearishScore = 0; + + // // + // mConditions.GenerateScore( + // bullishScore, + // bearishScore // + // ); + + // + // result = + // // + // bullishScore < bearishScore && + // mConditions.zigzags[prev] == mConditions.pvPeaks[prev] + // // + // ; + + // // + // for (int i = 1; i < 6; i++) + // { + // // + // X121MarketConditions iConditions; + // GetMarketConditions(iConditions, i); + + // // + // double iBullishScore = 0; + // double iBearishScore = 0; + + // // + // iConditions.GenerateScore( + // iBullishScore, + // iBearishScore, + // 1); + + // // + // bullishScore += iBullishScore; + // bearishScore += iBearishScore; + // } + + // // + // result = + // // + // bearishScore > bullishScore && + // (bullishScore < 0 + // ? bearishScore > MathAbs(bullishScore) + // : bearishScore > bullishScore * 2) + // // + // ; + // return result; } diff --git a/Classes/x-saherelm.x121.xmcycle.class.mq5 b/Classes/x-saherelm.x121.xmcycle.class.mq5 index 4f96595f..0bf4cd7b 100644 --- a/Classes/x-saherelm.x121.xmcycle.class.mq5 +++ b/Classes/x-saherelm.x121.xmcycle.class.mq5 @@ -488,7 +488,9 @@ public: // // XSTR ... bool isTrendBullish; + bool isTrendSwitchedToBullish; bool isTrendBearish; + bool isTrendSwitchedToBearish; // // XCHE ... @@ -835,6 +837,7 @@ public: // // Buffers ... + Clean(bars); Clean(ichTenkanSens); Clean(ichKijunSens); Clean(ichChikouSpans); @@ -865,10 +868,45 @@ public: Clean(oscStochSignals); Clean(oscStddevs); + // + // Buffers ... + ArraySetAsSeries(bars, true); + ArraySetAsSeries(ichTenkanSens, true); + ArraySetAsSeries(ichKijunSens, true); + ArraySetAsSeries(ichChikouSpans, true); + ArraySetAsSeries(ichSenkouSpanAs, true); + ArraySetAsSeries(ichSenkouSpanBs, true); + ArraySetAsSeries(mcFasts, true); + ArraySetAsSeries(mcSlows, true); + ArraySetAsSeries(mcVerifiers, true); + ArraySetAsSeries(strTrends, true); + ArraySetAsSeries(strStates, true); + ArraySetAsSeries(cheLongExit1s, true); + ArraySetAsSeries(cheLongExit2s, true); + ArraySetAsSeries(cheShortExit1s, true); + ArraySetAsSeries(cheShortExit2s, true); + ArraySetAsSeries(oscAtrs, true); + ArraySetAsSeries(oscRviMains, true); + ArraySetAsSeries(oscRviSignals, true); + ArraySetAsSeries(oscBullPs, true); + ArraySetAsSeries(oscBearPs, true); + ArraySetAsSeries(oscVolumes, true); + ArraySetAsSeries(oscRsis, true); + ArraySetAsSeries(oscCcis, true); + ArraySetAsSeries(oscMomentums, true); + ArraySetAsSeries(oscSars, true); + ArraySetAsSeries(oscMacdMains, true); + ArraySetAsSeries(oscMacdSignals, true); + ArraySetAsSeries(oscStochMains, true); + ArraySetAsSeries(oscStochSignals, true); + ArraySetAsSeries(oscStddevs, true); + // // XTSR ... isTrendBullish = false; isTrendBearish = false; + isTrendSwitchedToBullish = false; + isTrendSwitchedToBearish = false; // // XCHE ... @@ -1046,6 +1084,18 @@ public: { bearScore++; } + if (isTrendSwitchedToBullish) + { + // + bullScore++; + bearScore--: + } + if (isTrendSwitchedToBearish) + { + // + bullScore--; + bearScore++: + } // // XICH ... @@ -1505,6 +1555,8 @@ public: // ToString("isTrendBullish", isTrendBullish, ignoreFalseConditions) + ToString("isTrendBearish", isTrendBearish, ignoreFalseConditions) + + ToString("isTrendSwitchedToBullish", isTrendSwitchedToBullish, ignoreFalseConditions) + + ToString("isTrendSwitchedToBearish", isTrendSwitchedToBearish, ignoreFalseConditions) + "" // ; @@ -1887,6 +1939,10 @@ public: barIndex = CountBars() + 2; } + // + int curr = barIndex + 1; + int prev = curr + 1; + // // Here i Have to Calculate Market Conditions based on // Several Indicator/Oscillator(s) ... @@ -2016,18 +2072,42 @@ public: // bool isTrendBullish = // - str.IsBullish(str.GetState(barIndex)) + str.IsBullish(str.GetState(curr)) // ; bool isTrendBearish = // - str.IsBearish(str.GetState(barIndex)) + str.IsBearish(str.GetState(curr)) + // + ; + + // + bool isTrendBullishPrev = + // + str.IsBullish(str.GetState(prev)) + // + ; + bool isTrendBearishPrev = + // + str.IsBearish(str.GetState(prev)) // ; // conditions.isTrendBullish = isTrendBullish; conditions.isTrendBearish = isTrendBearish; + conditions.isTrendSwitchedToBullish = + // + isTrendBullish && + !isTrendBullishPrev + // + ; + conditions.isTrendSwitchedToBearish = + // + isTrendBearish && + !isTrendBearishPrev + // + ; // // XCHE ... @@ -2057,24 +2137,24 @@ public: // bool isCHEInLong = // - NotEmpty(che.GetLongExit1(barIndex)) + NotEmpty(che.GetLongExit1(curr)) // ; bool isCHEInStrongLong = // isCHEInLong && - NotEmpty(che.GetLongExit2(barIndex)) + NotEmpty(che.GetLongExit2(curr)) // ; bool isCHEInShort = // - NotEmpty(che.GetShortExit1(barIndex)) + NotEmpty(che.GetShortExit1(curr)) // ; bool isCHEInStrongShort = // isCHEInShort && - NotEmpty(che.GetShortExit2(barIndex)) + NotEmpty(che.GetShortExit2(curr)) // ; @@ -2107,68 +2187,68 @@ public: // bool isFastOverSlow = // - conditions.mcFasts[0] > conditions.mcSlows[0] && - conditions.mcFasts[1] > conditions.mcSlows[1] + conditions.mcFasts[curr] > conditions.mcSlows[curr] && + conditions.mcFasts[prev] > conditions.mcSlows[prev] // ; bool isFastUnderSlow = // - conditions.mcFasts[0] < conditions.mcSlows[0] && - conditions.mcFasts[1] < conditions.mcSlows[1] + conditions.mcFasts[curr] < conditions.mcSlows[curr] && + conditions.mcFasts[prev] < conditions.mcSlows[prev] // ; bool isFastOverVerifier = // - conditions.mcFasts[0] > conditions.mcVerifiers[0] && - conditions.mcFasts[1] > conditions.mcVerifiers[1] + conditions.mcFasts[curr] > conditions.mcVerifiers[curr] && + conditions.mcFasts[prev] > conditions.mcVerifiers[prev] // ; bool isFastUnderVerifier = // - conditions.mcFasts[0] < conditions.mcVerifiers[0] && - conditions.mcFasts[1] < conditions.mcVerifiers[1] + conditions.mcFasts[curr] < conditions.mcVerifiers[curr] && + conditions.mcFasts[prev] < conditions.mcVerifiers[prev] // ; bool isSlowOverVerifier = // - conditions.mcSlows[0] > conditions.mcVerifiers[0] && - conditions.mcSlows[1] > conditions.mcVerifiers[1] + conditions.mcSlows[curr] > conditions.mcVerifiers[curr] && + conditions.mcSlows[prev] > conditions.mcVerifiers[prev] // ; bool isSlowUnderVerifier = // - conditions.mcSlows[0] < conditions.mcVerifiers[0] && - conditions.mcSlows[1] < conditions.mcVerifiers[1] + conditions.mcSlows[curr] < conditions.mcVerifiers[curr] && + conditions.mcSlows[prev] < conditions.mcVerifiers[prev] // ; bool isCloseOverFast = // - pBar.close > conditions.mcFasts[1] + pBar.close > conditions.mcFasts[prev] // ; bool isCloseUnderFast = // - pBar.close < conditions.mcFasts[1] + pBar.close < conditions.mcFasts[prev] // ; bool isCloseOverSlow = // - pBar.close > conditions.mcSlows[1] + pBar.close > conditions.mcSlows[prev] // ; bool isCloseUnderSlow = // - pBar.close < conditions.mcSlows[1] + pBar.close < conditions.mcSlows[prev] // ; bool isCloseOverVerifier = // - pBar.close > conditions.mcVerifiers[1] + pBar.close > conditions.mcVerifiers[prev] // ; bool isCloseUnderVerifier = // - pBar.close < conditions.mcVerifiers[1] + pBar.close < conditions.mcVerifiers[prev] // ; @@ -2217,28 +2297,28 @@ public: ); // - double tenkanSen = ich.GetTenkanSen(barIndex); - double tenkanSenPrev = ich.GetTenkanSen(barIndex + 1); + double tenkanSen = ich.GetTenkanSen(curr); + double tenkanSenPrev = ich.GetTenkanSen(prev); // - double kijunSen = ich.GetKijunSen(barIndex); - double kijunSenPrev = ich.GetKijunSen(barIndex + 1); + double kijunSen = ich.GetKijunSen(curr); + double kijunSenPrev = ich.GetKijunSen(prev); // - double senkouSpanA = ich.GetSenkouSpanA(barIndex); - double senkouSpanAPrev = ich.GetSenkouSpanA(barIndex + 1); + double senkouSpanA = ich.GetSenkouSpanA(curr); + double senkouSpanAPrev = ich.GetSenkouSpanA(prev); // - double senkouSpanB = ich.GetSenkouSpanB(barIndex); - double senkouSpanBPrev = ich.GetSenkouSpanB(barIndex + 1); + double senkouSpanB = ich.GetSenkouSpanB(curr); + double senkouSpanBPrev = ich.GetSenkouSpanB(prev); // - double futureSenkouSpanA = ich.GetFutureSenkouSpanA(barIndex); - double futureSenkouSpanAPrev = ich.GetFutureSenkouSpanA(barIndex + 1); + double futureSenkouSpanA = ich.GetFutureSenkouSpanA(curr); + double futureSenkouSpanAPrev = ich.GetFutureSenkouSpanA(prev); // - double futureSenkouSpanB = ich.GetFutureSenkouSpanB(barIndex); - double futureSenkouSpanBPrev = ich.GetFutureSenkouSpanB(barIndex + 1); + double futureSenkouSpanB = ich.GetFutureSenkouSpanB(curr); + double futureSenkouSpanBPrev = ich.GetFutureSenkouSpanB(prev); // bool isSenkouSpanAOverB = senkouSpanA > senkouSpanB; @@ -2335,8 +2415,8 @@ public: ); // - double rvi = osc.GetRVI(barIndex); - double rviSignal = osc.GetRVISignal(barIndex); + double rvi = osc.GetRVI(curr); + double rviSignal = osc.GetRVISignal(curr); // bool isRVILongStart = @@ -2385,7 +2465,7 @@ public: ); // - double rsi = osc.GetRSI(barIndex); + double rsi = osc.GetRSI(curr); // bool isRSIUnder50 = @@ -2426,8 +2506,8 @@ public: ); // - double bullp = osc.GetBullPower(barIndex); - double bullpLast = osc.GetBullPower(barIndex + 1); + double bullp = osc.GetBullPower(curr); + double bullpLast = osc.GetBullPower(prev); // bool isBullPowerOverLast = @@ -2468,8 +2548,8 @@ public: ); // - double bearp = osc.GetBearPower(barIndex); - double bearpLast = osc.GetBearPower(barIndex + 1); + double bearp = osc.GetBearPower(curr); + double bearpLast = osc.GetBearPower(prev); // bool isBearPowerOverLast = @@ -2510,7 +2590,7 @@ public: ); // - double cci = osc.GetCCI(barIndex); + double cci = osc.GetCCI(curr); // bool isCCIPositive = @@ -2556,8 +2636,8 @@ public: ); // - double macd = osc.GetMACD(barIndex); - double macdSignal = osc.GetMACDSignal(barIndex); + double macd = osc.GetMACD(curr); + double macdSignal = osc.GetMACDSignal(curr); // bool isMACDPositiove = @@ -2603,8 +2683,8 @@ public: ); // - double stoch = osc.GetSTOCH(barIndex); - double stochSignal = osc.GetSTOCHSignal(barIndex); + double stoch = osc.GetSTOCH(curr); + double stochSignal = osc.GetSTOCHSignal(curr); // bool isStochKOverD = @@ -2670,8 +2750,8 @@ public: double stdDevAVG = GetAverage(stdDevs); // - double stdDev = osc.GetSTDDEV(barIndex); - double stdDevLast = osc.GetSTDDEV(barIndex + 1); + double stdDev = osc.GetSTDDEV(curr); + double stdDevLast = osc.GetSTDDEV(prev); // bool isSTDDEVOverAVG = diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 8b5a7748..60faa8e4 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -554,6 +554,7 @@ public: void Clear() { // + Clean(bars); Clean(tsCurrents); Clean(tsNearests); Clean(tsMediests); @@ -585,6 +586,7 @@ public: Clean(chlhHotStates); // + ArraySetAsSeries(bars, true); ArraySetAsSeries(tsCurrents, true); ArraySetAsSeries(tsNearests, true); ArraySetAsSeries(tsMediests, true); @@ -2507,13 +2509,38 @@ public: } // - virtual void GetMarketConditions( + void GetMarketConditions( X5MarketConditions &mConditions, // Market Conditions Result int barIndex = 0 // Specified Bar Index ) { // mConditions.Clear(); + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex >= CountBars()) + { + barIndex = CountBars() + 2; + } + + // + int curr = barIndex + 1; + int prev = curr + 1; + + // + GetBars( + mConditions.bars, + mConditions.symbol, + mConditions.period, + barIndex, + mNumberOfItems // + ); // // XTM ... diff --git a/Documents/BKP/required-long-conditions.mq5 b/Documents/BKP/required-long-conditions.mq5 new file mode 100644 index 00000000..2c48e470 --- /dev/null +++ b/Documents/BKP/required-long-conditions.mq5 @@ -0,0 +1,286 @@ + // + bool result = false; + + // + double bullishScore = 0; + double bearishScore = 0; + + // + mConditions.GenerateScore( + bullishScore, + bearishScore // + ); + + // + bool scorePassed = bearishScore > 2 * bullishScore; + + // + // Candlestick ... + bool cMCandlestickPassed = + // + mConditions.cMarketConditions.isLastBullish || + mConditions.cMarketConditions.isCurrentBullish || + mConditions.cMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + bool sMCandlestickPassed = + // + mConditions.sMarketConditions.isLastBullish || + mConditions.sMarketConditions.isCurrentBullish || + mConditions.sMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + bool mMCandlestickPassed = + // + mConditions.mMarketConditions.isLastBullish || + mConditions.mMarketConditions.isCurrentBullish || + mConditions.mMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + bool lMCandlestickPassed = + // + mConditions.lMarketConditions.isLastBullish || + mConditions.lMarketConditions.isCurrentBullish || + mConditions.lMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + bool hMCandlestickPassed = + // + mConditions.hMarketConditions.isLastBullish || + mConditions.hMarketConditions.isCurrentBullish || + mConditions.hMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + bool marketsCandlesticPassed = + // + cMCandlestickPassed && + sMCandlestickPassed && + mMCandlestickPassed && + lMCandlestickPassed && + hMCandlestickPassed + // + ; + + // + + + // // + // isSenkouSpanAOverB + // isSenkouSpanAOverLast + // isFutureSenkouSpanAOverB + // isFutureSenkouSpanAOverLast + + // // + // isCloseOverKijunSen + + // // + // isTenkanSenOverKijunSen + // isTenkanSenCrossedOverKijunSen + + // // + // isFastOverSlow + // isFastOverVerifier + // isSlowOverVerifier + // isCloseOverFast + // isCloseOverSlow + // isCloseOverVerifier + + // // + // isTrendBullish + + // // + // isCHEInLong + // isCHEInStrongLong + + // // + // isRVILongStart + + // // + // isBullPowerOverLast + // isBullPowerOverZero + + // // + // isBearPoswerUnderLast + // isBearPoswerUnderZero + + // // + // isCCIPositive + // isCCIOverPositiveHundred + + // // + // isSTDDEVOverAVG + // isSTDDEVOverLast + + // // + // isMACDPositiove + // isMACDOverSignal + + // + // isDONAttachedMinLower + // isDONCrossedOverMaxLower + + // + // isPVFiboIncreased + // isPVNewPeakUnderLast + + // // + // isPVSCBullish + // isPVMCBullish + // isPVLCBullish + // isPVHCBullish + + // // + // isPVSCLLBullish + // isPVMCLLBullish + // isPVLCLLBullish + // isPVHCLLBullish + + // // + // isPVSCSwitchedToBullish + // isPVMCSwitchedToBullish + // isPVLCSwitchedToBullish + // isPVHCSwitchedToBullish + + // + result = + // + scorePassed && + mConditions.lMarketConditions.isCurrentMidLineOverLastMidLine + // + ; + + // + return result; + + + +///////////////////////////////////////////// + + + // + isPriceCrossedOverLastLowOfHMarket + // + // // + // (bullishScore > bearishScore && + // MathAbs(bullishScore - bearishScore) > threshold) + // // + // && + // // + // ((isPriceCrossedOverLastMidLineOfHMarket || + // isPriceCrossedOverCurrentMidLineOfHMarket) && + // mConditions.hMarketConditions.isCurrentMidLineOverLastMidLine) + // // + + + + // + double entry = GetEntry(mConditions.symbol); + XOHCL cHBar = hMarket.GetBar(0); + XOHCL pHBar = hMarket.GetBar(1); + double lastHBarMid = pHBar.GetMid(); + double currentHBarMid = cHBar.GetMid(); + bool isPriceCrossedOverLastMidLineOfHMarket = + // + (mConditions.bars[1].high < lastHBarMid || + mConditions.bars[1].open < lastHBarMid) + // + && + // + (mConditions.bars[0].low > lastHBarMid || + mConditions.bars[0].close > lastHBarMid) + // + ; + bool isPriceCrossedOverCurrentMidLineOfHMarket = + // + (mConditions.bars[1].high < currentHBarMid || + mConditions.bars[1].open < currentHBarMid) + // + && + // + (mConditions.bars[0].low > currentHBarMid || + mConditions.bars[0].close > currentHBarMid) + // + ; + bool isPriceCrossedOverLastLowOfHMarket = + // + mConditions.bars[2].close < pHBar.low && + mConditions.bars[1].close > pHBar.low + // + ; + + // // + // isSenkouSpanAOverB + // isSenkouSpanAOverLast + // isFutureSenkouSpanAOverB + // isFutureSenkouSpanAOverLast + + // // + // isCloseOverKijunSen + + // // + // isTenkanSenOverKijunSen + // isTenkanSenCrossedOverKijunSen + + // // + // isFastOverSlow + // isFastOverVerifier + // isSlowOverVerifier + // isCloseOverFast + // isCloseOverSlow + // isCloseOverVerifier + + // // + // isTrendBullish + + // // + // isCHEInLong + // isCHEInStrongLong + + // // + // isRVILongStart + + // // + // isBullPowerOverLast + // isBullPowerOverZero + + // // + // isBearPoswerUnderLast + // isBearPoswerUnderZero + + // // + // isCCIPositive + // isCCIOverPositiveHundred + + // // + // isSTDDEVOverAVG + // isSTDDEVOverLast + + // // + // isMACDPositiove + // isMACDOverSignal + + // + // isDONAttachedMinLower + // isDONCrossedOverMaxLower + + // + // isPVFiboIncreased + // isPVNewPeakUnderLast + + // // + // isPVSCBullish + // isPVMCBullish + // isPVLCBullish + // isPVHCBullish + + // // + // isPVSCLLBullish + // isPVMCLLBullish + // isPVLCLLBullish + // isPVHCLLBullish + + // // + // isPVSCSwitchedToBullish + // isPVMCSwitchedToBullish + // isPVLCSwitchedToBullish + // isPVHCSwitchedToBullish diff --git a/Experts/x-test.x121ea.mq5 b/Experts/x-test.x121ea.mq5 index 8c1e8c44..cece0a9c 100644 --- a/Experts/x-test.x121ea.mq5 +++ b/Experts/x-test.x121ea.mq5 @@ -30,14 +30,14 @@ // // Inputs ... -long x121EAMagicNumber = 78692110; // Magic Number -int x121EASlippage = 10; // Slippgae -string x121EASymbols = "EURUSDb,USDCHFb"; // Symbols +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 = 15; // Max Allowed Positions +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) @@ -260,9 +260,32 @@ bool InitialEA() iDescriptor.inputs.cheInputs.showLongExit2Line = false; iDescriptor.inputs.cheInputs.showShortExit2Line = false; + // + // XPV ... + iDescriptor.inputs.pvInputs.showPeaksAndVales = true; + iDescriptor.inputs.pvInputs.showLevels = false; + iDescriptor.inputs.pvInputs.showConsolidations = false; + iDescriptor.inputs.pvInputs.showFibo1Levels = false; + iDescriptor.inputs.pvInputs.showFibo2Levels = false; + iDescriptor.inputs.pvInputs.showFibo3Levels = true; + iDescriptor.inputs.pvInputs.showFibo4Levels = false; + iDescriptor.inputs.pvInputs.showFibo5Levels = false; + + // + // XZG ... + iDescriptor.inputs.zgInputs.showZigZag = false; + iDescriptor.inputs.zgInputs.showPeaksAndVales = false; + + // + // XDON ... + iDescriptor.inputs.donInputs.showOpen = true; + iDescriptor.inputs.donInputs.showHigh = true; + iDescriptor.inputs.donInputs.showClose = true; + iDescriptor.inputs.donInputs.showLow = true; + // // XSTR ... - iDescriptor.inputs.strInputs.showTrends = false; + iDescriptor.inputs.strInputs.showTrends = true; iDescriptor.inputs.strInputs.fillTrends = false; // @@ -294,7 +317,7 @@ bool InitialEA() // Hind Market ... iDescriptor.inputs.hMarketPeriod = NULL; iDescriptor.inputs.hMarketMethod = X_PERIOD_AUTO; - iDescriptor.inputs.hMarketInputs.drawLabels = true; + iDescriptor.inputs.hMarketInputs.drawLabels = false; iDescriptor.inputs.hMarketInputs.drawCBar = true; iDescriptor.inputs.hMarketInputs.drawPBar = true; iDescriptor.inputs.hMarketInputs.drawCBarMid = true; diff --git a/Helpers/x-saherelm.xzg.helper.mq5 b/Helpers/x-saherelm.xzg.helper.mq5 index 977135ad..a51158d2 100644 --- a/Helpers/x-saherelm.xzg.helper.mq5 +++ b/Helpers/x-saherelm.xzg.helper.mq5 @@ -301,7 +301,7 @@ public: } // - double GetPeaksAndValues( + double GetPeaksAndVales( int barIndex // Bar Index ) { @@ -327,7 +327,7 @@ public: // // Copy Required Items ... - int CopyPeaksAndValues( + int CopyPeaksAndVales( int start, // Start int count, // Number of Items for read double &buffer[], // Dest Buffer