From d70845c664be3b9f3a98d92f2aedac655750ac66 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 19 May 2024 13:55:02 +0330 Subject: [PATCH] complete conditions Calculation ... --- Classes/x-saherelm.x5.provider.class.mq5 | 1251 +++++++++++++++++++++- Documents/conditions.mq5 | 133 +++ Experts/x-test.x5ea.mq5 | 2 +- Libraries/x-saherelm.common.lib.mq5 | 356 ++++++ 4 files changed, 1736 insertions(+), 6 deletions(-) create mode 100644 Documents/conditions.mq5 diff --git a/Classes/x-saherelm.x5.provider.class.mq5 b/Classes/x-saherelm.x5.provider.class.mq5 index 252dc92e..c2ad0c5a 100644 --- a/Classes/x-saherelm.x5.provider.class.mq5 +++ b/Classes/x-saherelm.x5.provider.class.mq5 @@ -324,6 +324,173 @@ public: double chlhLcLLs[]; double chlhHotStates[]; + // + // Conditional Variables ... + + // + // XTM ... + bool isXTMPeak; + bool isXTMVale; + bool isXTMBullish; + bool isXTMBearish; + bool isXTMNeutural; + bool isXTMEndBullish; + bool isXTMEndBearish; + bool isXTMStartBullish; + bool isXTMStartBearish; + bool isXTMEndBullishByNeutural; + bool isXTMEndBearishByNeutural; + bool isXTMStartBullishAfterNeutural; + bool isXTMStartBearishAfterNeutural; + + // + // XAMA ... + bool isXAMAPeak; + bool isXAMAVale; + bool isXAMABullish; + bool isXAMABearish; + bool isXAMANeutural; + bool isXAMAEndBullish; + bool isXAMAEndBearish; + bool isXAMAStartBullish; + bool isXAMAStartBearish; + bool isXAMAEndBullishByNeutural; + bool isXAMAEndBearishByNeutural; + bool isXAMAStartBullishAfterNeutural; + bool isXAMAStartBearishAfterNeutural; + + // + // XLH ... + bool isXLHHHIncreased; + bool isXLHHHDecreased; + bool isXLHLLIncreased; + bool isXLHLLDecreased; + bool isXLHLowAttachedLL; + bool isXLHHighAttachedHH; + bool isXLHHHSameInLength; + bool isXLHLLSameInLength; + bool isXLHPriceOverSignal; + bool isXLHPriceUnderSignal; + bool isXLHPriceInSignalRange; + bool isXLHPriceCrossedOverSignal; + bool isXLHPriceCrossedUnderSignal; + + // + // XTD ... + bool isXTDSignalPeak; + bool isXTDSignalVale; + bool isXTDBullishPeak; + bool isXTDBullishVale; + bool isXTDBearishPeak; + bool isXTDBearishVale; + bool isXTDBullOverBear; + bool isXTDBullUnderBear; + bool isXTDSignalOverBear; + bool isXTDSignalUnderBear; + bool isXTDBullCrossedOverBear; + bool isXTDBullCrossedUnderBear; + bool isXTDSignalCrossedOverBear; + bool isXTDSignalCrossedUnderBear; + + // + // XFI ... + bool isXFIPeak; + bool isXFIVale; + bool isXFICrossedOverZero; + bool isXFIOverZero; + bool isXFICrossedUnderZero; + bool isXFIUnderZero; + + // + // XTS ... + bool isXTSAllSame; + bool isXTSCurrentMin; + bool isXTSCurrentMax; + bool isXTSCurrentOverFarest; + bool isXTSCurrentOverNearest; + bool isXTSCurrentOverMediest; + bool isXTSCurrentUnderFarest; + bool isXTSCurrentUnderNearest; + bool isXTSCurrentUnderMediest; + bool isXTSCurrentCrossedOverFarest; + bool isXTSCurrentCrossedOverNearest; + bool isXTSCurrentCrossedOverMediest; + bool isXTSCurrentCrossedUnderFarest; + bool isXTSCurrentCrossedUnderNearest; + bool isXTSCurrentCrossedUnderMediest; + + // + // XRSI ... + bool isXRSIPeak; + bool isXRSIVale; + bool isXRSICrossedOverLongExit; + bool isXRSICrossedOverLongEntry; + bool isXRSICrossedUnderShortExit; + bool isXRSICrossedUnderShortEntry; + + // + // XOBD ... + bool isXOBDSwingLow; + bool isXOBDSwingHigh; + + // + // XCHLH ... + // + bool isXCHLHSameHHs; + bool isXCHLHSameLLs; + // + bool isXCHLHSCMCHHSame; + bool isXCHLHSCMCLLSame; + // + bool isXCHLHSCLCHHSame; + bool isXCHLHSCLCLLSame; + // + bool isXCHLHMCLCHHSame; + bool isXCHLHMCLCLLSame; + // + bool isXCHLHMCOnTopOfLC; + bool isXCHLHMCInBottomOfLC; + + // + // XCHMA ... + // + bool isXCHMASCOverMax; + bool isXCHMASCOverMin; + bool isXCHMASCUnderMax; + bool isXCHMASCUnderMin; + // + bool isXCHMASCCrossedOverMax; + bool isXCHMASCCrossedUnderMax; + bool isXCHMASCCrossedOverMin; + bool isXCHMASCCrossedUnderMin; + // + bool isXCHMASCPeak; + bool isXCHMASCVale; + bool isXCHMASCTrendsUp; + bool isXCHMASCTrendsDown; + bool isXCHMASCFastOverSlow; + bool isXCHMASCFastUnderSlow; + bool isXCHMASCFastCrossedOverSlow; + bool isXCHMASCFastCrossedUnderSlow; + // + bool isXCHMAMCPeak; + bool isXCHMAMCVale; + bool isXCHMAMCTrendsUp; + bool isXCHMAMCTrendsDown; + bool isXCHMAMCFastOverSlow; + bool isXCHMAMCFastUnderSlow; + bool isXCHMAMCFastCrossedOverSlow; + bool isXCHMAMCFastCrossedUnderSlow; + // + bool isXCHMALCPeak; + bool isXCHMALCVale; + bool isXCHMALCTrendsUp; + bool isXCHMALCTrendsDown; + bool isXCHMALCFastOverSlow; + bool isXCHMALCFastUnderSlow; + bool isXCHMALCFastCrossedOverSlow; + bool isXCHMALCFastCrossedUnderSlow; + // // @@ -360,6 +527,163 @@ public: Clean(chlhLcHHs); Clean(chlhLcLLs); Clean(chlhHotStates); + + // + ArraySetAsSeries(tsCurrents, true); + ArraySetAsSeries(tsNearests, true); + ArraySetAsSeries(tsMediests, true); + ArraySetAsSeries(tsFarests, true); + ArraySetAsSeries(fis, true); + ArraySetAsSeries(tdBullishs, true); + ArraySetAsSeries(tdBearishs, true); + ArraySetAsSeries(tdSignals, true); + ArraySetAsSeries(lhHhs, true); + ArraySetAsSeries(lhLls, true); + ArraySetAsSeries(lhSignals, true); + ArraySetAsSeries(tms, true); + ArraySetAsSeries(amas, true); + ArraySetAsSeries(obds, true); + ArraySetAsSeries(rsis, true); + ArraySetAsSeries(chmaScFasts, true); + ArraySetAsSeries(chmaScSlows, true); + ArraySetAsSeries(chmaMcFasts, true); + ArraySetAsSeries(chmaMcSlows, true); + ArraySetAsSeries(chmaLcFasts, true); + ArraySetAsSeries(chmaLcSlows, true); + ArraySetAsSeries(chmaHotStates, true); + ArraySetAsSeries(chlhScHHs, true); + ArraySetAsSeries(chlhScLLs, true); + ArraySetAsSeries(chlhMcHHs, true); + ArraySetAsSeries(chlhMcLLs, true); + ArraySetAsSeries(chlhLcHHs, true); + ArraySetAsSeries(chlhLcLLs, true); + ArraySetAsSeries(chlhHotStates, true); + + // + isXTMPeak = false; + isXTMVale = false; + isXTMBullish = false; + isXTMBearish = false; + isXTMNeutural = false; + isXTMEndBullish = false; + isXTMEndBearish = false; + isXTMStartBullish = false; + isXTMStartBearish = false; + isXTMEndBullishByNeutural = false; + isXTMEndBearishByNeutural = false; + isXTMStartBullishAfterNeutural = false; + isXTMStartBearishAfterNeutural = false; + isXAMAPeak = false; + isXAMAVale = false; + isXAMABullish = false; + isXAMABearish = false; + isXAMANeutural = false; + isXAMAEndBullish = false; + isXAMAEndBearish = false; + isXAMAStartBullish = false; + isXAMAStartBearish = false; + isXAMAEndBullishByNeutural = false; + isXAMAEndBearishByNeutural = false; + isXAMAStartBullishAfterNeutural = false; + isXAMAStartBearishAfterNeutural = false; + isXLHHHIncreased = false; + isXLHHHDecreased = false; + isXLHLLIncreased = false; + isXLHLLDecreased = false; + isXLHLowAttachedLL = false; + isXLHHighAttachedHH = false; + isXLHHHSameInLength = false; + isXLHLLSameInLength = false; + isXLHPriceOverSignal = false; + isXLHPriceUnderSignal = false; + isXLHPriceInSignalRange = false; + isXLHPriceCrossedOverSignal = false; + isXLHPriceCrossedUnderSignal = false; + isXTDSignalPeak = false; + isXTDSignalVale = false; + isXTDBullishPeak = false; + isXTDBullishVale = false; + isXTDBearishPeak = false; + isXTDBearishVale = false; + isXTDBullOverBear = false; + isXTDBullUnderBear = false; + isXTDSignalOverBear = false; + isXTDSignalUnderBear = false; + isXTDBullCrossedOverBear = false; + isXTDBullCrossedUnderBear = false; + isXTDSignalCrossedOverBear = false; + isXTDSignalCrossedUnderBear = false; + isXFIPeak = false; + isXFIVale = false; + isXFICrossedOverZero = false; + isXFIOverZero = false; + isXFICrossedUnderZero = false; + isXFIUnderZero = false; + isXTSAllSame = false; + isXTSCurrentMin = false; + isXTSCurrentMax = false; + isXTSCurrentOverFarest = false; + isXTSCurrentOverNearest = false; + isXTSCurrentOverMediest = false; + isXTSCurrentUnderFarest = false; + isXTSCurrentUnderNearest = false; + isXTSCurrentUnderMediest = false; + isXTSCurrentCrossedOverFarest = false; + isXTSCurrentCrossedOverNearest = false; + isXTSCurrentCrossedOverMediest = false; + isXTSCurrentCrossedUnderFarest = false; + isXTSCurrentCrossedUnderNearest = false; + isXTSCurrentCrossedUnderMediest = false; + isXRSIPeak = false; + isXRSIVale = false; + isXRSICrossedOverLongExit = false; + isXRSICrossedOverLongEntry = false; + isXRSICrossedUnderShortExit = false; + isXRSICrossedUnderShortEntry = false; + isXOBDSwingLow = false; + isXOBDSwingHigh = false; + isXCHLHSameHHs = false; + isXCHLHSameLLs = false; + isXCHLHSCMCHHSame = false; + isXCHLHSCMCLLSame = false; + isXCHLHSCLCHHSame = false; + isXCHLHSCLCLLSame = false; + isXCHLHMCLCHHSame = false; + isXCHLHMCLCLLSame = false; + isXCHLHMCOnTopOfLC = false; + isXCHLHMCInBottomOfLC = false; + isXCHMASCOverMax = false; + isXCHMASCOverMin = false; + isXCHMASCUnderMax = false; + isXCHMASCUnderMin = false; + isXCHMASCCrossedOverMax = false; + isXCHMASCCrossedUnderMax = false; + isXCHMASCCrossedOverMin = false; + isXCHMASCCrossedUnderMin = false; + isXCHMASCPeak = false; + isXCHMASCVale = false; + isXCHMASCTrendsUp = false; + isXCHMASCTrendsDown = false; + isXCHMASCFastOverSlow = false; + isXCHMASCFastUnderSlow = false; + isXCHMASCFastCrossedOverSlow = false; + isXCHMASCFastCrossedUnderSlow = false; + isXCHMAMCPeak = false; + isXCHMAMCVale = false; + isXCHMAMCTrendsUp = false; + isXCHMAMCTrendsDown = false; + isXCHMAMCFastOverSlow = false; + isXCHMAMCFastUnderSlow = false; + isXCHMAMCFastCrossedOverSlow = false; + isXCHMAMCFastCrossedUnderSlow = false; + isXCHMALCPeak = false; + isXCHMALCVale = false; + isXCHMALCTrendsUp = false; + isXCHMALCTrendsDown = false; + isXCHMALCFastOverSlow = false; + isXCHMALCFastUnderSlow = false; + isXCHMALCFastCrossedOverSlow = false; + isXCHMALCFastCrossedUnderSlow = false; } // @@ -434,7 +758,7 @@ public: chlhHelper = new XSCXCHLHHelper(); // - mNumberOfItems = 5; + mNumberOfItems = 15; } // @@ -909,6 +1233,16 @@ public: barIndex, mNumberOfItems, mConditions.chlhHotStates); + + // + // Filling Bars ... + mCycle.GetBars( + mConditions.bars, + 0, + mNumberOfItems); + + // + CalculateConditions(mConditions); } // @@ -933,10 +1267,10 @@ public: GetMarketConditions(mConditions, barIndex); // - if (result) - { - Print(GetToken() + ", " + GetTag() + ", Salam"); - } + // if (result) + // { + // Print(GetToken() + ", " + GetTag() + ", Salam"); + // } // return result; @@ -957,4 +1291,911 @@ private: // // Tools ... + + // + // Calculate Conditions ... + void CalculateConditions(X5MarketConditions &mConditions) + { + // + CalculateTMConditions(mConditions); + CalculateAMAConditions(mConditions); + CalculateFIConditions(mConditions); + CalculateOBDConditions(mConditions); + CalculateRSIConditions(mConditions); + CalculateCHLHConditions(mConditions); + CalculateLHConditions(mConditions); + CalculateTDConditions(mConditions); + CalculateTSConditions(mConditions); + CalculateCHMAConditions(mConditions); + } + + // + // XTM .. + void CalculateTMConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXTMPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.tms); + + // + mConditions.isXTMVale = IsDecreasing( + mFrom, + mIndex, + mConditions.tms); + + // + mConditions.isXTMBullish = mConditions.bars[mIndex].low > mConditions.tms[mIndex]; + bool isXTMBullishPrev = mConditions.bars[mPrevIndex].low > mConditions.tms[mPrevIndex]; + + // + mConditions.isXTMBearish = mConditions.bars[mIndex].high < mConditions.tms[mIndex]; + bool isXTMBearishPrev = mConditions.bars[mPrevIndex].high < mConditions.tms[mPrevIndex]; + + // + mConditions.isXTMNeutural = !mConditions.isXTMBullish && !mConditions.isXTMBearish; + bool isXTMNeuturalPrev = !isXTMBullishPrev && !isXTMBearishPrev; + + // + mConditions.isXTMEndBullish = + // + !mConditions.isXTMBullish && + isXTMBullishPrev + // + ; + + // + mConditions.isXTMEndBearish = + // + !mConditions.isXTMBearish && + isXTMBearishPrev + // + ; + + // + mConditions.isXTMStartBullish = + // + mConditions.isXTMBullish && + !isXTMBullishPrev + // + ; + + // + mConditions.isXTMStartBearish = + // + mConditions.isXTMBearish && + !isXTMBearishPrev + // + ; + + // + mConditions.isXTMEndBullishByNeutural = + // + mConditions.isXTMNeutural && + isXTMBullishPrev + // + ; + + // + mConditions.isXTMEndBearishByNeutural = + // + mConditions.isXTMNeutural && + isXTMBearishPrev + // + ; + + // + mConditions.isXTMStartBullishAfterNeutural = + // + mConditions.isXTMBullish && + isXTMNeuturalPrev + // + ; + + // + mConditions.isXTMStartBearishAfterNeutural = + // + mConditions.isXTMBearish && + isXTMNeuturalPrev + // + ; + } + + // + // XAMA .. + void CalculateAMAConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXAMAPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.amas); + + // + mConditions.isXAMAVale = IsDecreasing( + mFrom, + mIndex, + mConditions.amas); + + // + mConditions.isXAMABullish = mConditions.bars[mIndex].low > mConditions.amas[mIndex]; + bool isXAMABullishPrev = mConditions.bars[mPrevIndex].low > mConditions.amas[mPrevIndex]; + + // + mConditions.isXAMABearish = mConditions.bars[mIndex].high < mConditions.amas[mIndex]; + bool isXAMABearishPrev = mConditions.bars[mPrevIndex].high < mConditions.amas[mPrevIndex]; + + // + mConditions.isXAMANeutural = !mConditions.isXAMABullish && !mConditions.isXAMABearish; + bool isXAMANeuturalPrev = !isXAMABullishPrev && !isXAMABearishPrev; + + // + mConditions.isXAMAEndBullish = + // + !mConditions.isXAMABullish && + isXAMABullishPrev + // + ; + + // + mConditions.isXAMAEndBearish = + // + !mConditions.isXAMABearish && + isXAMABearishPrev + // + ; + + // + mConditions.isXAMAStartBullish = + // + mConditions.isXAMABullish && + !isXAMABullishPrev + // + ; + + // + mConditions.isXAMAStartBearish = + // + mConditions.isXAMABearish && + !isXAMABearishPrev + // + ; + + // + mConditions.isXAMAEndBullishByNeutural = + // + mConditions.isXAMANeutural && + isXAMABullishPrev + // + ; + + // + mConditions.isXAMAEndBearishByNeutural = + // + mConditions.isXAMANeutural && + isXAMABearishPrev + // + ; + + // + mConditions.isXAMAStartBullishAfterNeutural = + // + mConditions.isXAMABullish && + isXAMANeuturalPrev + // + ; + + // + mConditions.isXAMAStartBearishAfterNeutural = + // + mConditions.isXAMABearish && + isXAMANeuturalPrev + // + ; + } + + // + // XFI ... + void CalculateFIConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXFIPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.fis); + + // + mConditions.isXFIVale = IsDecreasing( + mFrom, + mIndex, + mConditions.fis); + + // + mConditions.isXFIOverZero = mConditions.fis[mIndex] > 0; + + // + mConditions.isXFICrossedOverZero = + // + mConditions.isXFIOverZero && + mConditions.fis[mPrevIndex] <= 0 + // + ; + + // + mConditions.isXFIUnderZero = mConditions.fis[mIndex] < 0; + + // + mConditions.isXFICrossedUnderZero = + // + mConditions.isXFIUnderZero && + mConditions.fis[mPrevIndex] >= 0 + // + ; + } + + // + // XOBD ... + void CalculateOBDConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXOBDSwingLow = mConditions.obds[mIndex] == X_SWING_LOW; + mConditions.isXOBDSwingHigh = mConditions.obds[mIndex] == X_SWING_HIGH; + } + + // + // XRSI ... + void CalculateRSIConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + double shortEntryValue = mInputs.rsiInputs.shortEntryValue; + double shortExitValue = mInputs.rsiInputs.shortExitValue; + double longEntryValue = mInputs.rsiInputs.longEntryValue; + double longExitValue = mInputs.rsiInputs.longExitValue; + + // + mConditions.isXRSIPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.rsis); + + // + mConditions.isXRSIVale = IsDecreasing( + mFrom, + mIndex, + mConditions.rsis); + + // + mConditions.isXRSICrossedOverLongExit = + // + mConditions.rsis[mIndex] > longExitValue && + mConditions.rsis[mPrevIndex] <= longExitValue; + // + ; + + // + mConditions.isXRSICrossedOverLongEntry = + // + mConditions.rsis[mIndex] > longEntryValue && + mConditions.rsis[mPrevIndex] <= longEntryValue; + // + ; + + // + mConditions.isXRSICrossedUnderShortExit = + // + mConditions.rsis[mIndex] < shortExitValue && + mConditions.rsis[mPrevIndex] >= shortExitValue; + // + ; + + // + mConditions.isXRSICrossedUnderShortEntry = + // + mConditions.rsis[mIndex] < shortEntryValue && + mConditions.rsis[mPrevIndex] >= shortEntryValue; + // + ; + } + + // + // XCHLH ... + void CalculateCHLHConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXCHLHSameHHs = + // + mConditions.chlhScHHs[mIndex] == mConditions.chlhMcHHs[mIndex] && + mConditions.chlhMcHHs[mIndex] == mConditions.chlhLcHHs[mIndex] + // + ; + + // + mConditions.isXCHLHSameLLs = + // + mConditions.chlhScLLs[mIndex] == mConditions.chlhMcLLs[mIndex] && + mConditions.chlhMcLLs[mIndex] == mConditions.chlhLcLLs[mIndex] + // + ; + + // + mConditions.isXCHLHSCMCHHSame = + // + mConditions.chlhScHHs[mIndex] == mConditions.chlhMcHHs[mIndex] + // + ; + + // + mConditions.isXCHLHSCMCLLSame = + // + mConditions.chlhScLLs[mIndex] == mConditions.chlhMcLLs[mIndex] + // + ; + + // + mConditions.isXCHLHSCLCHHSame = + // + mConditions.chlhScHHs[mIndex] == mConditions.chlhLcLLs[mIndex] + // + ; + + // + mConditions.isXCHLHSCLCLLSame = + // + mConditions.chlhScLLs[mIndex] == mConditions.chlhLcLLs[mIndex] + // + ; + + // + mConditions.isXCHLHMCLCHHSame = + // + mConditions.chlhMcHHs[mIndex] == mConditions.chlhLcHHs[mIndex] + // + ; + + // + mConditions.isXCHLHMCLCLLSame = + // + mConditions.chlhMcLLs[mIndex] == mConditions.chlhLcLLs[mIndex] + // + ; + + // // + // isXCHLHMCOnTopOfLC = + // // + // // + // ; + + // // + // isXCHLHMCInBottomOfLC = + // // + // // + // ; + } + + // + // XLH ... + void CalculateLHConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXLHHHIncreased = IsIncreasing( + mFrom, + mIndex, + mConditions.lhHhs); + + // + mConditions.isXLHHHDecreased = IsDecreasing( + mFrom, + mIndex, + mConditions.lhHhs); + + // + mConditions.isXLHLLIncreased = IsIncreasing( + mFrom, + mIndex, + mConditions.lhLls); + + // + mConditions.isXLHLLDecreased = IsDecreasing( + mFrom, + mIndex, + mConditions.lhLls); + + // + mConditions.isXLHLowAttachedLL = mConditions.bars[mIndex].low == mConditions.lhLls[mIndex]; + + // + mConditions.isXLHHighAttachedHH = mConditions.bars[mIndex].high == mConditions.lhHhs[mIndex]; + ; + + // + mConditions.isXLHHHSameInLength = IsSame(mConditions.lhHhs); + + // + mConditions.isXLHLLSameInLength = IsSame(mConditions.lhLls); + + // + mConditions.isXLHPriceOverSignal = mConditions.bars[mIndex].low > mConditions.lhSignals[mIndex]; + + // + mConditions.isXLHPriceUnderSignal = mConditions.bars[mIndex].high < mConditions.lhSignals[mIndex]; + + // + mConditions.isXLHPriceInSignalRange = !mConditions.isXLHPriceOverSignal && !mConditions.isXLHPriceUnderSignal; + + // + mConditions.isXLHPriceCrossedOverSignal = + // + mConditions.isXLHPriceOverSignal && + !(mConditions.bars[mPrevIndex].low > mConditions.lhSignals[mPrevIndex]) + // + ; + + // + mConditions.isXLHPriceCrossedUnderSignal = + // + mConditions.isXLHPriceUnderSignal && + !(mConditions.bars[mIndex].high < mConditions.lhSignals[mIndex]) + // + ; + } + + // + // XTD ... + void CalculateTDConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + mConditions.isXTDSignalPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.tdSignals); + + // + mConditions.isXTDSignalVale = IsDecreasing( + mFrom, + mIndex, + mConditions.tdSignals); + + // + mConditions.isXTDBullishPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.tdBullishs); + + // + mConditions.isXTDBullishVale = IsDecreasing( + mFrom, + mIndex, + mConditions.tdBullishs); + + // + mConditions.isXTDBearishPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.tdBearishs); + + // + mConditions.isXTDBearishVale = IsDecreasing( + mFrom, + mIndex, + mConditions.tdBearishs); + + // + mConditions.isXTDBullOverBear = mConditions.tdBullishs[mIndex] > mConditions.tdBearishs[mIndex]; + bool isXTDBullOverBearPrev = mConditions.tdBullishs[mPrevIndex] > mConditions.tdBearishs[mPrevIndex]; + + // + mConditions.isXTDBullUnderBear = mConditions.tdBullishs[mIndex] < mConditions.tdBearishs[mIndex]; + bool isXTDBullUnderBearPrev = mConditions.tdBullishs[mPrevIndex] < mConditions.tdBearishs[mPrevIndex]; + + // + mConditions.isXTDSignalOverBear = mConditions.tdSignals[mIndex] > mConditions.tdBearishs[mIndex]; + bool isXTDSignalOverBearPrev = mConditions.tdSignals[mPrevIndex] > mConditions.tdBearishs[mPrevIndex]; + + // + mConditions.isXTDSignalUnderBear = mConditions.tdSignals[mIndex] < mConditions.tdBearishs[mIndex]; + bool isXTDSignalUnderBearPrev = mConditions.tdSignals[mPrevIndex] < mConditions.tdBearishs[mPrevIndex]; + + // + mConditions.isXTDBullCrossedOverBear = + mConditions.isXTDBullOverBear && + !isXTDBullOverBearPrev; + + // + mConditions.isXTDBullCrossedUnderBear = + mConditions.isXTDBullUnderBear && + !isXTDBullUnderBearPrev; + + // + mConditions.isXTDSignalCrossedOverBear = + mConditions.isXTDSignalOverBear && + !isXTDSignalOverBearPrev; + + // + mConditions.isXTDSignalCrossedUnderBear = + mConditions.isXTDSignalUnderBear && + !isXTDSignalUnderBearPrev; + } + + // + // XTS ... + void CalculateTSConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + double current = mConditions.tsCurrents[mIndex]; + double currentPrev = mConditions.tsCurrents[mPrevIndex]; + + // + double nearest = mConditions.tsNearests[mIndex]; + double nearestPrev = mConditions.tsNearests[mPrevIndex]; + + // + double mediest = mConditions.tsMediests[mIndex]; + double mediestPrev = mConditions.tsMediests[mPrevIndex]; + + // + double farest = mConditions.tsFarests[mIndex]; + double farestPrev = mConditions.tsFarests[mPrevIndex]; + + // + double tsValues[] = {current, nearest, mediest, farest}; + double tsMax = GetMax(tsValues); + double tsMin = GetMin(tsValues); + + // + double tsPrevValues[] = {currentPrev, nearestPrev, mediestPrev, farestPrev}; + double tsPrevMax = GetMax(tsPrevValues); + double tsPrevMin = GetMin(tsPrevValues); + + // + mConditions.isXTSAllSame = + // + current == nearest && + nearest == mediest && + mediest == farest + // + ; + + // + mConditions.isXTSCurrentMin = current == tsMin; + mConditions.isXTSCurrentMax = current == tsMax; + + // + mConditions.isXTSCurrentOverFarest = current > farest; + bool isXTSCurrentOverFarestPrev = currentPrev > farestPrev; + + // + mConditions.isXTSCurrentOverNearest = current > nearest; + bool isXTSCurrentOverNearestPrev = currentPrev > nearestPrev; + + // + mConditions.isXTSCurrentOverMediest = current > mediest; + bool isXTSCurrentOverMediestPrev = currentPrev > mediestPrev; + + // + mConditions.isXTSCurrentUnderFarest = current < farest; + bool isXTSCurrentUnderFarestPrev = currentPrev < farestPrev; + + // + mConditions.isXTSCurrentUnderNearest = current < nearest; + bool isXTSCurrentUnderNearestPrev = currentPrev < nearestPrev; + + // + mConditions.isXTSCurrentUnderMediest = current < mediest; + bool isXTSCurrentUnderMediestPrev = currentPrev < mediestPrev; + + // + mConditions.isXTSCurrentCrossedOverFarest = + mConditions.isXTSCurrentOverFarest && + !isXTSCurrentOverFarestPrev; + + // + mConditions.isXTSCurrentCrossedOverNearest = + mConditions.isXTSCurrentOverNearest && + !isXTSCurrentOverNearestPrev; + + // + mConditions.isXTSCurrentCrossedOverMediest = + mConditions.isXTSCurrentOverMediest && + !isXTSCurrentOverMediestPrev; + + // + mConditions.isXTSCurrentCrossedUnderFarest = + mConditions.isXTSCurrentUnderFarest && + !isXTSCurrentUnderFarestPrev; + + // + mConditions.isXTSCurrentCrossedUnderNearest = + mConditions.isXTSCurrentUnderNearest && + !isXTSCurrentUnderNearestPrev; + + // + mConditions.isXTSCurrentCrossedUnderMediest = + mConditions.isXTSCurrentUnderMediest && + !isXTSCurrentUnderMediestPrev; + } + + // + // XCHMA ... + void CalculateCHMAConditions(X5MarketConditions &mConditions) + { + // + int mIndex = 0; + int mPrevIndex = mIndex + 1; + int mLength = 10; + int mFrom = mIndex + mLength; + + // + double scFast = mConditions.chmaScFasts[mIndex]; + double scSlow = mConditions.chmaScSlows[mIndex]; + double scFastPrev = mConditions.chmaScFasts[mPrevIndex]; + double scSlowPrev = mConditions.chmaScSlows[mPrevIndex]; + + // + double mcFast = mConditions.chmaMcFasts[mIndex]; + double mcSlow = mConditions.chmaMcSlows[mIndex]; + double mcFastPrev = mConditions.chmaMcFasts[mPrevIndex]; + double mcSlowPrev = mConditions.chmaMcSlows[mPrevIndex]; + + // + double lcFast = mConditions.chmaLcFasts[mIndex]; + double lcSlow = mConditions.chmaLcSlows[mIndex]; + double lcFastPrev = mConditions.chmaLcFasts[mPrevIndex]; + double lcSlowPrev = mConditions.chmaLcSlows[mPrevIndex]; + + // + double chmaValues[] = { + scFast, + scSlow, + mcFast, + mcSlow, + lcFast, + lcSlow}; + double chmaNonSCValues[] = { + mcFast, + mcSlow, + lcFast, + lcSlow}; + double chmaMin = GetMin(chmaValues); + double chmaMax = GetMax(chmaValues); + double chmaNonSCMin = GetMin(chmaNonSCValues); + double chmaNonSCMax = GetMax(chmaNonSCValues); + + // + double chmaValuesPrev[] = { + scFastPrev, + scSlowPrev, + mcFastPrev, + mcSlowPrev, + lcFastPrev, + lcSlowPrev}; + double chmaNonSCValuesPrev[] = { + mcFastPrev, + mcSlowPrev, + lcFastPrev, + lcSlowPrev}; + double chmaMinPrev = GetMin(chmaValuesPrev); + double chmaMaxPrev = GetMax(chmaValuesPrev); + double chmaNonSCMinPrev = GetMin(chmaNonSCValuesPrev); + double chmaNonSCMaxPrev = GetMax(chmaNonSCValuesPrev); + + // + mConditions.isXCHMASCOverMax = MathMin(scFast, scSlow) > chmaNonSCMax; + bool isXCHMASCOverMaxPrev = MathMin(scFastPrev, scSlowPrev) > chmaNonSCMaxPrev; + + // + mConditions.isXCHMASCOverMin = MathMin(scFast, scSlow) > chmaNonSCMin; + bool isXCHMASCOverMinPrev = MathMin(scFastPrev, scSlowPrev) > chmaNonSCMinPrev; + + // + mConditions.isXCHMASCUnderMax = MathMax(scFast, scSlow) < chmaNonSCMax; + bool isXCHMASCUnderMaxPrev = MathMax(scFastPrev, scSlowPrev) < chmaNonSCMaxPrev; + + // + mConditions.isXCHMASCUnderMin = MathMax(scFast, scSlow) < chmaNonSCMin; + bool isXCHMASCUnderMinPrev = MathMax(scFastPrev, scSlowPrev) < chmaNonSCMinPrev; + + // + mConditions.isXCHMASCCrossedOverMax = + mConditions.isXCHMASCOverMax && + !isXCHMASCOverMaxPrev; + + // + mConditions.isXCHMASCCrossedUnderMax = + mConditions.isXCHMASCUnderMax && + !isXCHMASCUnderMaxPrev; + + // + mConditions.isXCHMASCCrossedOverMin = + mConditions.isXCHMASCOverMin && + !isXCHMASCOverMinPrev; + + // + mConditions.isXCHMASCCrossedUnderMin = + mConditions.isXCHMASCUnderMin && + !isXCHMASCUnderMinPrev; + + // + // Short ... + + // + mConditions.isXCHMASCPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.chmaScFasts); + + // + mConditions.isXCHMASCVale = IsDecreasing( + mFrom, + mIndex, + mConditions.chmaScFasts); + + // + mConditions.isXCHMASCTrendsUp = IsTrendingUp( + mConditions.chmaScFasts, + mConditions.chmaScSlows); + + // + mConditions.isXCHMASCTrendsDown = IsTrendingDown( + mConditions.chmaScFasts, + mConditions.chmaScSlows); + + // + mConditions.isXCHMASCFastOverSlow = scFast > scSlow; + bool isXCHMASCFastOverSlowPrev = scFastPrev > scSlowPrev; + + // + mConditions.isXCHMASCFastUnderSlow = scFast < scSlow; + bool isXCHMASCFastUnderSlowPrev = scFastPrev < scSlowPrev; + + // + mConditions.isXCHMASCFastCrossedOverSlow = + mConditions.isXCHMASCFastOverSlow && + !isXCHMASCFastOverSlowPrev; + + // + mConditions.isXCHMASCFastCrossedUnderSlow = + mConditions.isXCHMASCFastUnderSlow && + !isXCHMASCFastUnderSlowPrev; + + // + // Medium ... + + // + mConditions.isXCHMAMCPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.chmaMcFasts); + + // + mConditions.isXCHMAMCVale = IsDecreasing( + mFrom, + mIndex, + mConditions.chmaMcFasts); + + // + mConditions.isXCHMAMCTrendsUp = IsTrendingUp( + mConditions.chmaMcFasts, + mConditions.chmaMcSlows); + + // + mConditions.isXCHMAMCTrendsDown = IsTrendingDown( + mConditions.chmaMcFasts, + mConditions.chmaMcSlows); + + // + mConditions.isXCHMAMCFastOverSlow = mcFast > mcSlow; + bool isXCHMAMCFastOverSlowPrev = mcFastPrev > mcSlowPrev; + + // + mConditions.isXCHMAMCFastUnderSlow = mcFast < mcSlow; + bool isXCHMAMCFastUnderSlowPrev = mcFastPrev < mcSlowPrev; + + // + mConditions.isXCHMAMCFastCrossedOverSlow = + mConditions.isXCHMAMCFastOverSlow && + !isXCHMAMCFastOverSlowPrev; + + // + mConditions.isXCHMAMCFastCrossedUnderSlow = + mConditions.isXCHMAMCFastUnderSlow && + !isXCHMAMCFastUnderSlowPrev; + + // + // Long ... + + // + mConditions.isXCHMALCPeak = IsIncreasing( + mFrom, + mIndex, + mConditions.chmaLcFasts); + + // + mConditions.isXCHMALCVale = IsDecreasing( + mFrom, + mIndex, + mConditions.chmaLcFasts); + + // + mConditions.isXCHMALCTrendsUp = IsTrendingUp( + mConditions.chmaLcFasts, + mConditions.chmaLcSlows); + + // + mConditions.isXCHMALCTrendsDown = IsTrendingDown( + mConditions.chmaMcFasts, + mConditions.chmaMcSlows); + + // + mConditions.isXCHMALCFastOverSlow = lcFast > lcSlow; + bool isXCHMALCFastOverSlowPrev = lcFastPrev > lcSlowPrev; + + // + mConditions.isXCHMALCFastUnderSlow = lcFast < lcSlow; + bool isXCHMALCFastUnderSlowPrev = lcFastPrev < lcSlowPrev; + + // + mConditions.isXCHMALCFastCrossedOverSlow = + mConditions.isXCHMALCFastOverSlow && + !isXCHMALCFastOverSlowPrev; + + // + mConditions.isXCHMALCFastCrossedUnderSlow = + mConditions.isXCHMALCFastUnderSlow && + !isXCHMALCFastUnderSlowPrev; + } }; diff --git a/Documents/conditions.mq5 b/Documents/conditions.mq5 new file mode 100644 index 00000000..978165a2 --- /dev/null +++ b/Documents/conditions.mq5 @@ -0,0 +1,133 @@ +isXTMPeak +isXTMVale +isXTMBullish +isXTMBearish +isXTMNeutural +isXTMEndBullish +isXTMEndBearish +isXTMStartBullish +isXTMStartBearish +isXTMEndBullishByNeutural +isXTMEndBearishByNeutural +isXTMStartBullishAfterNeutural +isXTMStartBearishAfterNeutural + +isXAMAPeak +isXAMAVale +isXAMABullish +isXAMABearish +isXAMANeutural +isXAMAEndBullish +isXAMAEndBearish +isXAMAStartBullish +isXAMAStartBearish +isXAMAEndBullishByNeutural +isXAMAEndBearishByNeutural +isXAMAStartBullishAfterNeutural +isXAMAStartBearishAfterNeutural + +isXLHHHIncreased +isXLHHHDecreased +isXLHLLIncreased +isXLHLLDecreased +isXLHLowAttachedLL +isXLHHighAttachedHH +isXLHHHSameInLength +isXLHLLSameInLength +isXLHPriceOverSignal +isXLHPriceUnderSignal +isXLHPriceInSignalRange +isXLHPriceCrossedOverSignal +isXLHPriceCrossedUnderSignal + +isXTDSignalPeak +isXTDSignalVale +isXTDBullishPeak +isXTDBullishVale +isXTDBearishPeak +isXTDBearishVale +isXTDBullOverBear +isXTDBullUnderBear +isXTDSignalOverBear +isXTDSignalUnderBear +isXTDBullCrossedOverBear +isXTDBullCrossedUnderBear +isXTDSignalCrossedOverBear +isXTDSignalCrossedUnderBear + +isXFIPeak +isXFIVale +isXFICrossedOverZero +isXFIOverZero +isXFICrossedUnderZero +isXFIUnderZero + +isXTSAllSame +isXTSCurrentMin +isXTSCurrentMax +isXTSCurrentOverFarest +isXTSCurrentOverNearest +isXTSCurrentOverMediest +isXTSCurrentUnderFarest +isXTSCurrentUnderNearest +isXTSCurrentUnderMediest +isXTSCurrentCrossedOverFarest +isXTSCurrentCrossedOverNearest +isXTSCurrentCrossedOverMediest +isXTSCurrentCrossedUnderFarest +isXTSCurrentCrossedUnderNearest +isXTSCurrentCrossedUnderMediest + +isXRSIPeak +isXRSIVale +isXRSICrossedOverLongExit +isXRSICrossedOverLongEntry +isXRSICrossedUnderShortExit +isXRSICrossedUnderShortEntry + +isXOBDSwingLow +isXOBDSwingHigh + +isXCHLHSameHHs +isXCHLHSameLLs +isXCHLHSCMCHHSame +isXCHLHSCMCLLSame +isXCHLHSCLCHHSame +isXCHLHSCLCLLSame +isXCHLHMCLCHHSame +isXCHLHMCLCLLSame +isXCHLHMCOnTopOfLC +isXCHLHMCInBottomOfLC + +isXCHMASCOverMax +isXCHMASCOverMin +isXCHMASCUnderMax +isXCHMASCUnderMin +isXCHMASCCrossedOverMax +isXCHMASCCrossedUnderMax +isXCHMASCCrossedOverMin +isXCHMASCCrossedUnderMin +isXCHMASCPeak +isXCHMASCVale +isXCHMASCTrendsUp +isXCHMASCTrendsDown +isXCHMASCFastOverSlow +isXCHMASCFastUnderSlow +isXCHMASCFastCrossedOverSlow +isXCHMASCFastCrossedUnderSlow +isXCHMAMCPeak +isXCHMAMCVale +isXCHMAMCTrendsUp +isXCHMAMCTrendsDown +isXCHMAMCFastOverSlow +isXCHMAMCFastUnderSlow +isXCHMAMCFastCrossedOverSlow +isXCHMAMCFastCrossedUnderSlow +isXCHMALCPeak +isXCHMALCVale +isXCHMALCTrendsUp +isXCHMALCTrendsDown +isXCHMALCFastOverSlow +isXCHMALCFastUnderSlow +isXCHMALCFastCrossedOverSlow +isXCHMALCFastCrossedUnderSlow \ No newline at end of file diff --git a/Experts/x-test.x5ea.mq5 b/Experts/x-test.x5ea.mq5 index 850d5552..de7019ed 100644 --- a/Experts/x-test.x5ea.mq5 +++ b/Experts/x-test.x5ea.mq5 @@ -140,7 +140,7 @@ void OnTick() // signal.Clean(); conditions.Clear(); - x5Provider.HasSignal(0, signal, conditions); + x5Provider.HasSignal(1, signal, conditions); } // diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index da1eb5c6..f660e5e4 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -2195,6 +2195,125 @@ struct XMarketCycle return result; } + // + // Extract Specific Range of Bars ... + // using Start Bar Index ... + int GetBars( + XOHCL &result[], // Hold Result + int from = 0, // Start Bar Index + int count = 1, // Number of Bars + bool forceClean = true // Clean Result Array + ) + { + // + int mResult = 0; + + // + if (from < 0) + { + from = 0; + } + + // + int total = Bars( + symbol, + period); + if (from > total - 2) + { + from = total - 2; + } + + // + if (count < 0) + { + count = 1; + } + + // + int start = from; + int end = start + count; + if (end > total - 1) + { + end = total - 1; + } + + // + if (forceClean) + { + Clean(result); + } + + // + int beforeSize = ArraySize(result); + + // + for (int i = start; i < end; i++) + { + // + XOHCL iBar; + bool isValid = iBar.Init( + symbol, + period, + i + // + ); + + // + if (isValid) + { + // + AddRef( + iBar, + result + // + ); + } + } + + // + int afterSize = ArraySize(result); + + // + mResult = afterSize - beforeSize; + + // + return mResult; + } + + // + // Extract Specific Range of Bars ... + // using Start Bar Time ... + int GetBars( + XOHCL &result[], // Hold Result + datetime from = NULL, // Start Bar Time + int count = 1, // Number of Bars + bool forceClean = true // Clean Result Array + ) + { + // + from = NormalizeTime(from); + + // + int barIndex = iBarShift( + symbol, + period, + from, + false + // + ); + + // + return GetBars( + result, + symbol, + period, + barIndex, + count, + forceClean + // + ); + } + // // Retrieve Bar Time ... datetime GetBarTime(int barIndex) @@ -3296,6 +3415,49 @@ MqlDateTime GetBarTimeStruct( // // Other Tools ... +// +template +bool IsSame( + T &buffer[], // Search Buffer + int count = 5 // Number of Searchs +) +{ + // + bool result = false; + + // + int bufferSize = ArraySize(buffer); + result = bufferSize > 0; + if (!result) { + return result; + } + + // + // Validate Count ... + result = count < bufferSize; + if (!result) { + return result; + } + + // + T iTem = buffer[0]; + for (int i = 0; i < count; i++) { + // + if (iTem != buffer[i]) { + result = false; + break; + } + + // + if (!result) { + result = true; + } + } + + // + return result; +} + // // Check first Cross Over second at index ... bool IsCrossedOver( @@ -3400,6 +3562,200 @@ bool IsUnder( return result; } +// +// Check if a Value Increasing in Loopback ... +bool IsIncreasing( + const int from, // Last Time Index + const int to, // Fisr Tima Index + const double &buffer[] // the Buffer which required to search +) +{ + // + bool result = false; + + // + // Validate Args ... + if ( + from <= to || + ArraySize(buffer) < from + 1) + { + return result; + } + + // + // Loop through Items ... + double toValue = buffer[to]; + double fromValue = buffer[from]; + result = toValue > fromValue; + for (int i = to + 1; i <= from - 1; i++) + { + // + double iValue = buffer[i]; + bool isPassed = toValue >= iValue; + + // + bool isIIncreasing = IsIncreasing( + from, + i, + buffer); + + // + // Check Result ... + result = result && isPassed && isIIncreasing; + if (!result) + { + break; + } + } + + // + return result; +} + +// +// Check if a Value Decreasing in Loopback ... +bool IsDecreasing( + const int from, // Last Time Index + const int to, // Fisr Tima Index + const double &buffer[] // the Buffer which required to search +) +{ + // + bool result = false; + + // + // Validate Args ... + if ( + from <= to || + ArraySize(buffer) < from + 1) + { + return result; + } + + // + // Loop through Items ... + double toValue = buffer[to]; + double fromValue = buffer[from]; + result = toValue < fromValue; + for (int i = to + 1; i <= from - 1; i++) + { + // + double iValue = buffer[i]; + bool isPassed = toValue <= iValue; + + // + bool isIDecreasing = IsDecreasing( + from, + i, + buffer); + + // + // Check Result ... + result = result && isPassed && isIDecreasing; + if (!result) + { + break; + } + } + + // + return result; +} + +// +bool IsTrendingUp( + const double &buffer1[], // First Buffer + const double &buffer2[] // Seccend Buffer +) { + // + bool result = false; + + // + int buffer1Count = ArraySize(buffer1); + int buffer2Count = ArraySize(buffer2); + if (buffer1Count <= 0 || buffer2Count <= 0) { + return result; + } + + // + int count = MathMin(buffer1Count, buffer2Count); + if (count <= 1) { + return result; + } + + // + int upCounts = 0; + int downCounts = 0; + double value = MathAbs(buffer1[0] - buffer2[0]); + for (int i = 1; i < count; i++) { + // + double iValue = MathAbs(buffer1[i] - buffer2[i]); + + // + if (value > iValue) { + upCounts++; + } + + // + if (value < iValue) { + downCounts++; + } + } + + // + result = upCounts > 1 && upCounts > downCounts; + + // + return result; +} + +// +bool IsTrendingDown( + const double &buffer1[], // First Buffer + const double &buffer2[] // Seccend Buffer +) { + // + bool result = false; + + // + int buffer1Count = ArraySize(buffer1); + int buffer2Count = ArraySize(buffer2); + if (buffer1Count <= 0 || buffer2Count <= 0) { + return result; + } + + // + int count = MathMin(buffer1Count, buffer2Count); + if (count <= 1) { + return result; + } + + // + int upCounts = 0; + int downCounts = 0; + double value = MathAbs(buffer1[0] - buffer2[0]); + for (int i = 1; i < count; i++) { + // + double iValue = MathAbs(buffer1[i] - buffer2[i]); + + // + if (value > iValue) { + upCounts++; + } + + // + if (value < iValue) { + downCounts++; + } + } + + // + result = downCounts > 1 && downCounts > upCounts; + + // + return result; +} + // // Calculate Slope of Specified Buffer at Specified Index ... double GetSlope(