/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Helper Parser Class Library // ---------------------------------------------------- // Name: XCXFIMAHelperParser // Description: provides all Indicator // Helper Parse requirements ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://www.saherelm.ir" #property version "1.00" #property strict // // Imports ... #include "../../Helpers/x-saherelm.xfima.helper.mq5" // // Definitions ... // // Implementation ... class XCXFIMAHelperParser : XCBase { // // Public ... public: // string symbol; ENUM_TIMEFRAMES period; // // Constructor ... XCXFIMAHelperParser(XCXFIMAHelper *_helper) { // helper = _helper; symbol = _helper.GetSymbol(); period = _helper.GetPeriod(); } // // Deconstructor ... ~XCXFIMAHelperParser() { ZeroMemory(helper); } // // Tools ... /** * Validate ... * * @return ( bool ) */ bool IsValid() { // bool result = false; // result = helper != NULL && helper.IsValid() && IsXValid(symbol) && IsXValid(period); // return result; } /** * Normalize Bar Index ... * * @param barIndex: int, Provided Bar Index ... * * @return ( int ) */ int NormalizeBarIndex(int barIndex = 0) { // int result = -1; // if (!IsValid()) { return result; } // result = helper.NormalizeBarIndex(barIndex); // return result; } // // Parsers ... // // XSAR ... /** * Check SAR is Bullish or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsSARBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetSARState(barIndex); result = state >= 1; // return result; } /** * Check SAR is Bearish or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsSARBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetSARState(barIndex); result = state <= -1; // return result; } /** * Check SAR is Switched to Bullish or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsSARSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // int pBarIndex = barIndex + 1; // bool isBullish = IsSARBullish(barIndex); bool isPBullish = IsSARBullish(pBarIndex); // result = isBullish && !isPBullish; // return result; } /** * Check SAR is Switched to Bearish or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsSARSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // int pBarIndex = barIndex + 1; // bool isBearish = IsSARBearish(barIndex); bool isPBearish = IsSARBearish(pBarIndex); // result = isBearish && !isPBearish; // return result; } /** * Count Bullish SAR(s) ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBullishSARs( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsSARBullish(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count Bearish SAR(s) ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBearishSARs( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsSARBearish(idx); if (has) { result++; } if (!has) { break; } } // return result; } // // XMA ... /** * Check Fast Ma Over Slow or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastOverSlow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iFast = helper.GetMAFast(barIndex); double iSlow = helper.GetMASlow(barIndex); // result = iFast > iSlow; // return result; } /** * Check Fast Ma Under Slow or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastUnderSlow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iFast = helper.GetMAFast(barIndex); double iSlow = helper.GetMASlow(barIndex); // result = iFast < iSlow; // return result; } /** * Check Fast Ma Over Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iFast = helper.GetMAFast(barIndex); double pFast = helper.GetMAFast(barIndex + 1); // result = iFast > pFast; // return result; } /** * Check Slow Ma Over Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMASlowOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iSlow = helper.GetMASlow(barIndex); double pSlow = helper.GetMASlow(barIndex + 1); // result = iSlow > pSlow; // return result; } /** * Check Fast Ma Under Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iFast = helper.GetMAFast(barIndex); double pFast = helper.GetMAFast(barIndex + 1); // result = iFast < pFast; // return result; } /** * Check Slow Ma Under Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMASlowUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iSlow = helper.GetMASlow(barIndex); double pSlow = helper.GetMASlow(barIndex + 1); // result = iSlow < pSlow; // return result; } /** * Check MA Fast is Crossed Over Slow or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastCrossedOverSlow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastOverSlow = IsMAFastOverSlow(barIndex); bool isPFastOverSlow = IsMAFastOverSlow(barIndex + 1); // result = isFastOverSlow && !isPFastOverSlow; // return result; } /** * Check MA Fast is Crossed Under Slow or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastCrossedUnderSlow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastUnderSlow = IsMAFastUnderSlow(barIndex); bool isPFastUnderSlow = IsMAFastUnderSlow(barIndex + 1); // result = isFastUnderSlow && !isPFastUnderSlow; // return result; } /** * Check MA Fast is Crossed Over Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastCrossedOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastOverLast = IsMAFastOverLast(barIndex); bool isPFastOverLast = IsMAFastOverLast(barIndex + 1); // result = isFastOverLast && !isPFastOverLast; // return result; } /** * Check MA Fast is Crossed Under Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMAFastCrossedUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastUnderLast = IsMAFastUnderLast(barIndex); bool isPFastUnderLast = IsMAFastUnderLast(barIndex + 1); // result = isFastUnderLast && !isPFastUnderLast; // return result; } /** * Check MA Slow is Crossed Over Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMASlowCrossedOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isSlowOverLast = IsMASlowOverLast(barIndex); bool isPSlowOverLast = IsMASlowOverLast(barIndex + 1); // result = isSlowOverLast && !isPSlowOverLast; // return result; } /** * Check MA Slow is Crossed Under Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMASlowCrossedUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isSlowUnderLast = IsMASlowUnderLast(barIndex); bool isPSlowUnderLast = IsMASlowUnderLast(barIndex + 1); // result = isSlowUnderLast && !isPSlowUnderLast; // return result; } /** * Check MA Fast and Slow Crossed Over Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMACrossedOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastCrossedOverLast = IsMAFastCrossedOverLast(barIndex); bool isSlowCrossedOverLast = IsMASlowCrossedOverLast(barIndex); // result = isFastCrossedOverLast && isSlowCrossedOverLast; // return result; } /** * Check MA Fast and Slow Crossed Under Last or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsMACrossedUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool isFastCrossedUnderLast = IsMAFastCrossedUnderLast(barIndex); bool isSlowCrossedUnderLast = IsMASlowCrossedUnderLast(barIndex); // result = isFastCrossedUnderLast && isSlowCrossedUnderLast; // return result; } /** * Count MA Fast Over Slows ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMAFastOverSlows( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMAFastOverSlow(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count MA Fast Under Slows ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMAFastUnderSlows( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMAFastUnderSlow(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count MA Fast Over Lasts ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMAFastOverLasts( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMAFastOverLast(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count MA Fast Under Lasts ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMAFastUnderLasts( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMAFastUnderLast(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count MA Slow Over Lasts ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMASlowOverLasts( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMASlowOverLast(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count MA Slow Under Lasts ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountMASlowUnderLasts( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsMASlowUnderLast(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count Over MA Fast Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountOverMAFastBars( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // // DO ... XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetMAFast(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice > iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Under MA Fast Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountUnderMAFastBars( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // // DO ... XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetMAFast(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice < iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Over MA Slow Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountOverMASlowBars( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // // DO ... XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetMASlow(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice > iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Under MA Slow Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountUnderMASlowBars( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // // DO ... XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetMASlow(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice < iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } // // XHK ... /** * Check HK is Bullish or not ... * * @param barIndex: int, Specified BarIndex ... * * @return ( bool ) */ bool IsHKBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iO = helper.GetHKOpen(barIndex); double iC = helper.GetHKClose(barIndex); // result = NotEmptyZero(iO) && NotEmptyZero(iC) && iC > iO; // return result; } /** * Check HK is Bearish or not ... * * @param barIndex: int, Specified BarIndex ... * * @return ( bool ) */ bool IsHKBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... double iO = helper.GetHKOpen(barIndex); double iC = helper.GetHKClose(barIndex); // result = NotEmptyZero(iO) && NotEmptyZero(iC) && iC < iO; // return result; } /** * Check HK is Switched to Bullish or not ... * * @param barIndex: int, Specified BarIndex ... * * @return ( bool ) */ bool IsHKSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool is = IsHKBullish(barIndex); bool isP = IsHKBullish(barIndex + 1); // result = is && !isP; // return result; } /** * Check HK is Switched to Bearish or not ... * * @param barIndex: int, Specified BarIndex ... * * @return ( bool ) */ bool IsHKSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... bool is = IsHKBearish(barIndex); bool isP = IsHKBearish(barIndex + 1); // result = is && !isP; // return result; } /** * Count Bullish HK(s) ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBullishHKs( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsHKBullish(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count Bearish HK(s) ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBearishHKs( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // // DO ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsHKBearish(idx); if (has) { result++; } if (!has) { break; } } // return result; } /** * Count Over HK Band Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountOverHKBandLower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetHKBandLower(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice > iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Under HK Band Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountUnderHKBandLower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetHKBandLower(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice < iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Over HK Band Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountOverHKBandUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetHKBandUpper(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice > iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } /** * Count Under HK Band Bars ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountUnderHKBandUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!has) { return result; } // XOHCL iBar; int idx = barIndex; double iValue = EMPTY_VALUE; double iPrice = EMPTY_VALUE; while (idx < barIndex + loopback) { // idx++; iBar.Clean(); has = iBar.Init(symbol, period, idx); if (!has) { break; } // iValue = helper.GetHKBandUpper(idx); iPrice = iBar.GetPrice(priceType); // has = iPrice < iValue; if (has) { result++; } if (!has) { break; } } // // Cleanup ... iBar.Clean(); // return result; } // // XPV ... /** * Check Peak Same as Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsPeakSame(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double iC = helper.GetPeak(barIndex); double iP = helper.GetPeak(barIndex + 1); // result = iC == iP && NotEmptyZero(iC); // return result; } /** * Check Vale Same as Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsValeSame(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double iC = helper.GetVale(barIndex); double iP = helper.GetVale(barIndex + 1); // result = iC == iP && NotEmptyZero(iC); // return result; } /** * Count Same Peaks ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountSamePeaks( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // double iPeak = EMPTY_VALUE; double peak = helper.GetPeak(barIndex); int idx = barIndex; while (idx < barIndex + loopback) { // idx++; iPeak = helper.GetPeak(idx); has = peak == iPeak; if (has) { result++; } if (!has) { break; } } // return result; } /** * Count Same Vales ... * * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountSameVales( int barIndex = 0, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // double iVale = EMPTY_VALUE; double vale = helper.GetVale(barIndex); int idx = barIndex; while (idx < barIndex + loopback) { // idx++; iVale = helper.GetVale(idx); has = vale == iVale; if (has) { result++; } if (!has) { break; } } // return result; } /** * Check Peak Happens over Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsPeakOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Reading Values ... // double iPeak = helper.GetPeak(barIndex); double pPeak = helper.GetPeak(barIndex + 1); // result = NotEmptyZero(iPeak) && iPeak > pPeak; // return result; } /** * Check Vale Happens over Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsValeOverLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Reading Values ... // double iVale = helper.GetVale(barIndex); double pVale = helper.GetVale(barIndex + 1); // result = NotEmptyZero(iVale) && iVale > pVale; // return result; } /** * Check Peak Happens under Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsPeakUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Reading Values ... // double iPeak = helper.GetPeak(barIndex); double pPeak = helper.GetPeak(barIndex + 1); // result = NotEmptyZero(iPeak) && iPeak < pPeak; // return result; } /** * Check Vale Happens under Last ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsValeUnderLast(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Reading Values ... // double iVale = helper.GetVale(barIndex); double pVale = helper.GetVale(barIndex + 1); // result = NotEmptyZero(iVale) && iVale < pVale; // return result; } /** * Detect Last Peak Change ... * * @param index: int, reference to hold change index ... * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( bool ) */ bool FindLastPeakOverLast( int &index, int barIndex = 0, int loopback = 500 // ) { // bool result = false; // // Prepare ... index = -1; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Loop ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; result = IsPeakOverLast(idx); if (result) { // index = idx; break; } } // result = IsValidIndex(index); // return result; } /** * Detect Last Peak Change ... * * @param index: int, reference to hold change index ... * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( bool ) */ bool FindLastPeakUnderLast( int &index, int barIndex = 0, int loopback = 500 // ) { // bool result = false; // // Prepare ... index = -1; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Loop ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; result = IsPeakUnderLast(idx); if (result) { // index = idx; break; } } // result = IsValidIndex(index); // return result; } /** * Detect Last Vale Change ... * * @param index: int, reference to hold change index ... * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( bool ) */ bool FindLastValeOverLast( int &index, int barIndex = 0, int loopback = 500 // ) { // bool result = false; // // Prepare ... index = -1; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Loop ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; result = IsValeOverLast(idx); if (result) { // index = idx; break; } } // result = IsValidIndex(index); // return result; } /** * Detect Last Vale Change ... * * @param index: int, reference to hold change index ... * @param barIndex: int, Specified Bar Index ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( bool ) */ bool FindLastValeUnderLast( int &index, int barIndex = 0, int loopback = 500 // ) { // bool result = false; // // Prepare ... index = -1; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Loop ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; result = IsValeUnderLast(idx); if (result) { // index = idx; break; } } // result = IsValidIndex(index); // return result; } // // XZG ... /** * Check ZigZag has Value and Read it ... * * @param value: double, reference to holds value ... * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool HasZG( double &value, int barIndex = 0 // ) { // bool result = false; // // Prepare ... value = EMPTY_VALUE; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // value = helper.GetZigZag(barIndex); // result = NotEmptyZero(value); // return result; } /** * Check ZG is Low or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsZGLow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... // // Reading Value ... double iValue; result = HasZG(iValue, barIndex); if (!result) { return result; } // // Reading Value ... XOHCL iBar; result = iBar.Init(symbol, period, barIndex); result = result && iBar.low == iValue; // // Cleanup ... iBar.Clean(); // return result; } /** * Check ZG is High or not ... * * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ bool IsZGHigh(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // // Do ... // // Reading Value ... double iValue; result = HasZG(iValue, barIndex); if (!result) { return result; } // // Reading Value ... XOHCL iBar; result = iBar.Init(symbol, period, barIndex); result = result && iBar.high == iValue; // // Cleanup ... iBar.Clean(); // return result; } // // Boundary Tools ... // ============================= // Boundary Includes: // MA Band ... // PB Band ... // HK Band ... // ATR Band ... /** * Reading Boundary Values ... * * @param maBandUpper: double, reference to holds MA Band Upper value ... * @param maBandLower: double, reference to holds MA Band Lower value ... * @param pbBandUpper: double, reference to holds PB Band Upper value ... * @param pbBandLower: double, reference to holds PB Band Lower value ... * @param hkBandUpper: double, reference to holds HK Band Upper value ... * @param hkBandLower: double, reference to holds HK Band Lower value ... * @param atrBandUpper: double, reference to holds ATR Band Upper value ... * @param atrBandLower: double, reference to holds ATR Band Lower value ... * @param barIndex: int, Specified Bar Index ... */ void GetBoundaryValues( double &maBandUpper, double &maBandLower, double &pbBandUpper, double &pbBandLower, double &hkBandUpper, double &hkBandLower, double &atrBandUpper, double &atrBandLower, int barIndex = 0 // ) { // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Prepare ... maBandUpper = EMPTY_VALUE; maBandLower = EMPTY_VALUE; pbBandUpper = EMPTY_VALUE; pbBandLower = EMPTY_VALUE; hkBandUpper = EMPTY_VALUE; hkBandLower = EMPTY_VALUE; atrBandUpper = EMPTY_VALUE; atrBandLower = EMPTY_VALUE; // // Validate ... bool has = IsValid(); if (!has) { return; } // maBandUpper = helper.GetMABandUpper(barIndex); maBandLower = helper.GetMABandLower(barIndex); pbBandUpper = helper.GetPBBandUpper(barIndex); pbBandLower = helper.GetPBBandLower(barIndex); hkBandUpper = helper.GetHKBandUpper(barIndex); hkBandLower = helper.GetHKBandLower(barIndex); atrBandUpper = helper.GetATRBandUpper(barIndex); atrBandLower = helper.GetATRBandLower(barIndex); } /** * Read Boundary Values and Fill as an Array ... * * @param values: double, collection reference to fill results ... * @param barIndex: int, Specified Bar Index ... */ void GetBoundaryValuesArray( double &values[], int barIndex = 0 // ) { // // Prepare ... XClean(values); // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return; } // // Reading Boundary Values ... // double maBandUpper = EMPTY_VALUE; double maBandLower = EMPTY_VALUE; double pbBandUpper = EMPTY_VALUE; double pbBandLower = EMPTY_VALUE; double hkBandUpper = EMPTY_VALUE; double hkBandLower = EMPTY_VALUE; double atrBandUpper = EMPTY_VALUE; double atrBandLower = EMPTY_VALUE; // GetBoundaryValues( maBandUpper, maBandLower, pbBandUpper, pbBandLower, hkBandUpper, hkBandLower, atrBandUpper, atrBandLower, barIndex // ); // // Validate ... has = NotEmptyZero(maBandUpper) && NotEmptyZero(maBandLower) && NotEmptyZero(pbBandUpper) && NotEmptyZero(pbBandLower) && NotEmptyZero(hkBandUpper) && NotEmptyZero(hkBandLower) && NotEmptyZero(atrBandUpper) && NotEmptyZero(atrBandLower); if (!has) { return; } // Add(maBandUpper, values); Add(maBandLower, values); Add(pbBandUpper, values); Add(pbBandLower, values); Add(hkBandUpper, values); Add(hkBandLower, values); Add(atrBandUpper, values); Add(atrBandLower, values); } /** * Read Boundary Min Value ... * * @param barIndex: int, Specified Bar Index ... * * @return ( double ) */ double GetBoundaryMin(int barIndex = 0) { // double result = EMPTY_VALUE; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // double values[]; GetBoundaryValuesArray(values, barIndex); result = GetMin(values); // return result; } /** * Read Boundary Max Value ... * * @param barIndex: int, Specified BAr Index ... * * @return ( double ) */ double GetBoundaryMax(int barIndex = 0) { // double result = EMPTY_VALUE; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid(); if (!has) { return result; } // double values[]; GetBoundaryValuesArray(values, barIndex); result = GetMax(values); // return result; } // // Bars and Boundary ... /** * Check Bar's Price is Over Boundary Max or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarOverBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; double price = EMPTY_VALUE; double value = GetBoundaryMax(barIndex); result = bar.Init(symbol, period, barIndex); if (result) { price = bar.GetPrice(priceType); } result = bar.IsValid() && NotEmptyZero(price) && NotEmptyZero(value) && price > value; // // Cleanup ... bar.Clean(); // return result; } /** * Check Bar's Price is Over Boundary Min or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarOverBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; double price = EMPTY_VALUE; double value = GetBoundaryMin(barIndex); result = bar.Init(symbol, period, barIndex); if (result) { price = bar.GetPrice(priceType); } result = bar.IsValid() && NotEmptyZero(price) && NotEmptyZero(value) && price > value; // // Cleanup ... bar.Clean(); // return result; } /** * Check Bar's Price is Under Boundary Max or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarUnderBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; double price = EMPTY_VALUE; double value = GetBoundaryMax(barIndex); result = bar.Init(symbol, period, barIndex); if (result) { price = bar.GetPrice(priceType); } result = bar.IsValid() && NotEmptyZero(price) && NotEmptyZero(value) && price < value; // // Cleanup ... bar.Clean(); // return result; } /** * Check Bar's Price is Under Boundary Min or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarUnderBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; double price = EMPTY_VALUE; double value = GetBoundaryMin(barIndex); result = bar.Init(symbol, period, barIndex); if (result) { price = bar.GetPrice(priceType); } result = bar.IsValid() && NotEmptyZero(price) && NotEmptyZero(value) && price < value; // // Cleanup ... bar.Clean(); // return result; } /** * Check Bar's Price is Crossed Over Boundary Max or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarCrossedOverBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // bool isC = IsBarOverBoundaryMax(barIndex, priceType); bool isP = IsBarOverBoundaryMax(barIndex + 1, priceType); // result = isC && !isP; // return result; } /** * Check Bar's Price is Crossed Over Boundary Min or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarCrossedOverBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // bool isC = IsBarOverBoundaryMin(barIndex, priceType); bool isP = IsBarOverBoundaryMin(barIndex + 1, priceType); // result = isC && !isP; // return result; } /** * Check Bar's Price is Crossed Under Boundary Max or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarCrossedUnderBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // bool isC = IsBarUnderBoundaryMax(barIndex, priceType); bool isP = IsBarUnderBoundaryMax(barIndex + 1, priceType); // result = isC && !isP; // return result; } /** * Check Bar's Price is Crossed Under Boundary Min or not ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * * @return ( bool ) */ bool IsBarCrossedUnderBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // bool isC = IsBarUnderBoundaryMin(barIndex, priceType); bool isP = IsBarUnderBoundaryMin(barIndex + 1, priceType); // result = isC && !isP; // return result; } /** * Count Over Boundary Max Bar's Prices ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBarsOverBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!result) { return result; } // // Do ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsBarOverBoundaryMax(idx); if (!has) { break; } result++; } // return result; } /** * Count Over Boundary Min Bar's Prices ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBarsOverBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!result) { return result; } // // Do ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsBarOverBoundaryMin(idx); if (!has) { break; } result++; } // return result; } /** * Count Under Boundary Max Bar's Prices ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBarsUnderBoundaryMax( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_HIGH, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!result) { return result; } // // Do ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsBarUnderBoundaryMax(idx); if (!has) { break; } result++; } // return result; } /** * Count Under Boundary Min Bar's Prices ... * * @param barIndex: int, Specified Bar Index ... * @param priceType: ENUM_X_PRICE, Specified Price Type ... * @param loopback: int, Max Allowed Loopback Length ... * * @return ( int ) */ int CountBarsUnderBoundaryMin( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_LOW, int loopback = 500 // ) { // int result = 0; // // Normalize ... loopback = NormalizeInt(loopback, 50); barIndex = NormalizeBarIndex(barIndex); // // Validate ... bool has = IsValid() && IsXValid(priceType); if (!result) { return result; } // // Do ... int idx = barIndex; while (idx < barIndex + loopback) { // idx++; has = IsBarUnderBoundaryMin(idx); if (!has) { break; } result++; } // return result; } // // Protected ... protected: // // // Private ... private: // XCXFIMAHelper *helper; // }; //