/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Helper Parser Class Library // ---------------------------------------------------- // Name: XCX121XKIHelperParser // 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.x121.xki.helper.mq5" // // Definitions ... enum ENUM_X121_XKI_SCORE { X121_XKI_SCORE_NONE = 0, X121_XKI_SCORE_MIN = 1, X121_XKI_SCORE_NORMAL = 2, X121_XKI_SCORE_MAX = 3, }; // // Implementation ... class XCX121XKIHelperParser : XCBase { // // Public ... public: // string symbol; ENUM_TIMEFRAMES period; // // Constructor ... XCX121XKIHelperParser(XCX121XKIHelper *_helper) { // helper = _helper; symbol = _helper.GetSymbol(); period = _helper.GetPeriod(); } // // Deconstructor ... ~XCX121XKIHelperParser() { 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 ... // Indicators Base Conditions ... // #region KI Fast ... bool IsKIFastBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKIFastState(barIndex); result = state >= 1; // return result; } bool IsKIFastBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKIFastState(barIndex); result = state <= -1; // return result; } bool IsKIFastSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKIFastBullish(barIndex) && !IsKIFastBullish(barIndex + 1); // return result; } bool IsKIFastSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKIFastBearish(barIndex) && !IsKIFastBearish(barIndex + 1); // return result; } bool IsKIFastOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsOver( helper.GetKIFast(barIndex), helper.GetKIFast(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKIFastUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsUnder( helper.GetKIFast(barIndex), helper.GetKIFast(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKIFastSameAsLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsSame( helper.GetKIFast(barIndex), helper.GetKIFast(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKIFastSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKIFastOverLast(barIndex, tolerance) && !IsKIFastOverLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } bool IsKIFastSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKIFastUnderLast(barIndex, tolerance) && !IsKIFastUnderLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } // #endregion // #region KI Slow ... bool IsKISlowBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKISlowState(barIndex); result = state >= 1; // return result; } bool IsKISlowBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKISlowState(barIndex); result = state <= -1; // return result; } bool IsKISlowSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKISlowBullish(barIndex) && !IsKISlowBullish(barIndex + 1); // return result; } bool IsKISlowSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKISlowBearish(barIndex) && !IsKISlowBearish(barIndex + 1); // return result; } bool IsKISlowOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsOver( helper.GetKISlow(barIndex), helper.GetKISlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISlowUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsUnder( helper.GetKISlow(barIndex), helper.GetKISlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISlowSameAsLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsSame( helper.GetKISlow(barIndex), helper.GetKISlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISlowSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKISlowOverLast(barIndex, tolerance) && !IsKISlowOverLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } bool IsKISlowSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKISlowUnderLast(barIndex, tolerance) && !IsKISlowUnderLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } // #endregion // #region KI Super Slow ... bool IsKISuperSlowBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKISuperSlowState(barIndex); result = state >= 1; // return result; } bool IsKISuperSlowBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double state = helper.GetKISuperSlowState(barIndex); result = state <= -1; // return result; } bool IsKISuperSlowSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKISuperSlowBullish(barIndex) && !IsKISuperSlowBullish(barIndex + 1); // return result; } bool IsKISuperSlowSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKISuperSlowBearish(barIndex) && !IsKISuperSlowBearish(barIndex + 1); // return result; } bool IsKISuperSlowOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsOver( helper.GetKISuperSlow(barIndex), helper.GetKISuperSlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISuperSlowUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsUnder( helper.GetKISuperSlow(barIndex), helper.GetKISuperSlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISuperSlowSameAsLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsSame( helper.GetKISuperSlow(barIndex), helper.GetKISuperSlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsKISuperSlowSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKISuperSlowOverLast(barIndex, tolerance) && !IsKISuperSlowOverLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } bool IsKISuperSlowSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKISuperSlowUnderLast(barIndex, tolerance) && !IsKISuperSlowUnderLast(barIndex + 1, tolerance); if (!result) { return result; } // return result; } // #endregion // #region KI Wave ... bool IsKIWaveBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetKIWaveState(barIndex) >= 1; // return result; } bool IsKIWaveBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetKIWaveState(barIndex) <= -1; // return result; } bool IsKIWaveSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKIWaveBullish(barIndex) && !IsKIWaveBullish(barIndex + 1); // return result; } bool IsKIWaveSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsKIWaveBearish(barIndex) && !IsKIWaveBearish(barIndex + 1); // return result; } bool IsKIWaveOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && helper.GetKIWave(barIndex) > helper.GetKIWave(barIndex + 1); // return result; } bool IsKIWaveUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && helper.GetKIWave(barIndex) < helper.GetKIWave(barIndex + 1); // return result; } bool IsKIWaveSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKIWaveOverLast(barIndex) && !IsKIWaveOverLast(barIndex + 1); // return result; } bool IsKIWaveSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsKIWaveUnderLast(barIndex) && !IsKIWaveUnderLast(barIndex + 1); // return result; } // #endregion // #region KI Band ... bool IsPriceOverKIUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price > helper.GetKIUpper(barIndex); bar.Clean(); // return result; } bool IsPriceUnderKIUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price < helper.GetKIUpper(barIndex); bar.Clean(); // return result; } bool IsPriceOverKILower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price > helper.GetKILower(barIndex); bar.Clean(); // return result; } bool IsPriceUnderKILower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price < helper.GetKILower(barIndex); bar.Clean(); // return result; } bool IsPriceInsideKIBands( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price < helper.GetKIUpper(barIndex) && price > helper.GetKILower(barIndex); bar.Clean(); // return result; } bool IsPriceSwitchedOverKIUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsPriceOverKIUpper(barIndex, priceType) && !IsPriceOverKIUpper(barIndex + 1, priceType); // return result; } bool IsPriceSwitchedUnderKIUpper( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsPriceUnderKIUpper(barIndex, priceType) && !IsPriceUnderKIUpper(barIndex + 1, priceType); // return result; } bool IsPriceSwitchedOverKILower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsPriceOverKILower(barIndex, priceType) && !IsPriceOverKILower(barIndex + 1, priceType); // return result; } bool IsPriceSwitchedUnderKILower( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsPriceUnderKILower(barIndex, priceType) && !IsPriceUnderKILower(barIndex + 1, priceType); // return result; } // #endregion // #region MA Fast/Slow/SuperSlow ... // #region MA Fast ... bool IsMAFastBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) > helper.GetMAFast(barIndex); // iBar.Clean(); // return result; } bool IsMAFastBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) < helper.GetMAFast(barIndex); // iBar.Clean(); // return result; } bool IsMAFastOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetMAFast(barIndex), helper.GetMAFast(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMAFastUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetMAFast(barIndex), helper.GetMAFast(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMAFastSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMAFastOverLast(barIndex, tolerance) && !IsMAFastOverLast(barIndex + 1, tolerance); // return result; } bool IsMAFastSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMAFastUnderLast(barIndex, tolerance) && !IsMAFastUnderLast(barIndex + 1, tolerance); // return result; } bool IsMAFastSwitchedToBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMAFastBullish(barIndex) && !IsMAFastBullish(barIndex + 1); // return result; } bool IsMAFastSwitchedToBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMAFastBearish(barIndex) && !IsMAFastBearish(barIndex + 1); // return result; } // #endregion // #region MA Slow ... bool IsMASlowBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) > helper.GetMASlow(barIndex); // iBar.Clean(); // return result; } bool IsMASlowBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) < helper.GetMASlow(barIndex); // iBar.Clean(); // return result; } bool IsMASlowOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetMASlow(barIndex), helper.GetMASlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMASlowUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetMASlow(barIndex), helper.GetMASlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMASlowSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASlowOverLast(barIndex, tolerance) && !IsMASlowOverLast(barIndex + 1, tolerance); // return result; } bool IsMASlowSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASlowUnderLast(barIndex, tolerance) && !IsMASlowUnderLast(barIndex + 1, tolerance); // return result; } bool IsMASlowSwitchedToBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASlowBullish(barIndex) && !IsMASlowBullish(barIndex + 1); // return result; } bool IsMASlowSwitchedToBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASlowBearish(barIndex) && !IsMASlowBearish(barIndex + 1); // return result; } // #endregion // #region MA Super Slow ... bool IsMASuperSlowBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) > helper.GetMASuperSlow(barIndex); // iBar.Clean(); // return result; } bool IsMASuperSlowBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... XOHCL iBar; result = IsValid() && iBar.Init(symbol, period, barIndex); if (!result) { return result; } // result = iBar.GetPrice(priceType) < helper.GetMASuperSlow(barIndex); // iBar.Clean(); // return result; } bool IsMASuperSlowOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetMASuperSlow(barIndex), helper.GetMASuperSlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMASuperSlowUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetMASuperSlow(barIndex), helper.GetMASuperSlow(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsMASuperSlowSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASuperSlowOverLast(barIndex, tolerance) && !IsMASuperSlowOverLast(barIndex + 1, tolerance); // return result; } bool IsMASuperSlowSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASuperSlowUnderLast(barIndex, tolerance) && !IsMASuperSlowUnderLast(barIndex + 1, tolerance); // return result; } bool IsMASuperSlowSwitchedToBullish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASuperSlowBullish(barIndex) && !IsMASuperSlowBullish(barIndex + 1); // return result; } bool IsMASuperSlowSwitchedToBearish( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsMASuperSlowBearish(barIndex) && !IsMASuperSlowBearish(barIndex + 1); // return result; } // #endregion bool IsMACrossoverBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetMAFast(barIndex) > helper.GetMASlow(barIndex); return result; } bool IsMACrossoverBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetMAFast(barIndex) < helper.GetMASlow(barIndex); return result; } bool IsMACrossoverSwitchedToBullish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsMACrossoverBullish(barIndex) && !IsMACrossoverBullish(barIndex + 1); return result; } bool IsMACrossoverSwitchedToBearish(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsMACrossoverBearish(barIndex) && !IsMACrossoverBearish(barIndex + 1); return result; } // #endregion // #region PV ... bool IsPeakSameAsLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsSame( helper.GetPeak(barIndex), helper.GetPeak(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsPeakOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetPeak(barIndex), helper.GetPeak(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsPeakUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetPeak(barIndex), helper.GetPeak(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsValeSameAsLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsSame( helper.GetVale(barIndex), helper.GetVale(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsValeOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetVale(barIndex), helper.GetVale(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsValeUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetVale(barIndex), helper.GetVale(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } // #endregion // #region ATR ... bool IsATRBreakoutUp( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price > helper.GetATRRawUpper(barIndex); bar.Clean(); // return result; } bool IsATRBreakoutDown( int barIndex = 0, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid() && IsXValid(priceType); if (!result) { return result; } // XOHCL bar; result = bar.Init(symbol, period, barIndex); if (!result) { return result; } // double price = bar.GetPrice(priceType); result = price < helper.GetATRRawLower(barIndex); bar.Clean(); // return result; } bool IsATROverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetATR(barIndex), helper.GetATR(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsATRUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetATR(barIndex), helper.GetATR(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsATRSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsATROverLast(barIndex, tolerance) && !IsATROverLast(barIndex + 1, tolerance); // return result; } bool IsATRSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsATRUnderLast(barIndex, tolerance) && !IsATRUnderLast(barIndex + 1, tolerance); // return result; } bool IsATRSmoothedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetATRSmoothed(barIndex), helper.GetATRSmoothed(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsATRSmoothedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetATRSmoothed(barIndex), helper.GetATRSmoothed(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsATRSmoothedSwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsATRSmoothedOverLast(barIndex, tolerance) && !IsATRSmoothedOverLast(barIndex + 1, tolerance); // return result; } bool IsATRSmoothedSwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsATRSmoothedUnderLast(barIndex, tolerance) && !IsATRSmoothedUnderLast(barIndex + 1, tolerance); // return result; } bool IsVolatilityHigh(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double atr = helper.GetATR(barIndex); double atrMa = helper.GetATRSmoothed(barIndex); result = atr > atrMa; // return result; } bool IsVolatilityLow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double atr = helper.GetATR(barIndex); double atrMa = helper.GetATRSmoothed(barIndex); result = atr < atrMa; // return result; } bool IsVolatilitySwitchdToHigh(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double atr = helper.GetATR(barIndex); double atrPrev = helper.GetATR(barIndex + 1); double atrMa = helper.GetATRSmoothed(barIndex); double atrMaPrev = helper.GetATRSmoothed(barIndex + 1); // result = atr > atrMa && atrPrev <= atrMaPrev; // return result; } bool IsVolatilitySwitchdToLow(int barIndex = 0) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // double atr = helper.GetATR(barIndex); double atrPrev = helper.GetATR(barIndex + 1); double atrMa = helper.GetATRSmoothed(barIndex); double atrMaPrev = helper.GetATRSmoothed(barIndex + 1); // result = atr < atrMa && atrPrev >= atrMaPrev; // return result; } // #endregion // #region RSI ... bool IsRSIBullish( int barIndex = 0, double threshold = 55, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) || helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance); // return result; } bool IsRSISwitchedToBullish( int barIndex = 0, double threshold = 55, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsRSIBullish(barIndex, threshold, tolerance) && !IsRSIBullish(barIndex + 1, threshold, tolerance); // return result; } bool IsRSIBearish( int barIndex = 0, double threshold = 45, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) || helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance); // return result; } bool IsRSISwitchedToBearish( int barIndex = 0, double threshold = 45, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = IsRSIBearish(barIndex, threshold, tolerance) && !IsRSIBearish(barIndex + 1, threshold, tolerance); // return result; } bool IsRSIRising(int barIndex = 0) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && helper.GetRSI(barIndex) > helper.GetRSISmoothed(barIndex); // return result; } bool IsRSISwitchedToRising(int barIndex = 0) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIRising(barIndex) && !IsRSIRising(barIndex + 1); // return result; } bool IsRSIFalling(int barIndex = 0) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && helper.GetRSI(barIndex) < helper.GetRSISmoothed(barIndex); // return result; } bool IsRSISwitchedToFalling(int barIndex = 0) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIFalling(barIndex) && !IsRSIFalling(barIndex + 1); // return result; } bool IsRSIOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsOver( helper.GetRSI(barIndex), helper.GetRSI(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsRSISwitchedOverLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIOverLast(barIndex, tolerance) && !IsRSIOverLast(barIndex + 1, tolerance); // return result; } bool IsRSIUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsUnder( helper.GetRSI(barIndex), helper.GetRSI(barIndex + 1), GetPoints(symbol) * tolerance // ); // return result; } bool IsRSISwitchedUnderLast( int barIndex = 0, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIUnderLast(barIndex, tolerance) && !IsRSIUnderLast(barIndex + 1, tolerance); // return result; } bool IsRSIOverbought( int barIndex = 0, double threshold = 70, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetRSI(barIndex) > threshold + (GetPoints(symbol) * tolerance) || helper.GetRSI(barIndex) > threshold - (GetPoints(symbol) * tolerance); // return result; } bool IsRSIOversold( int barIndex = 0, double threshold = 30, double tolerance = 2 // ) { // bool result = false; // // Normalize ... barIndex = NormalizeBarIndex(barIndex); // // Validate ... result = IsValid(); if (!result) { return result; } // result = helper.GetRSI(barIndex) < threshold + (GetPoints(symbol) * tolerance) || helper.GetRSI(barIndex) < threshold - (GetPoints(symbol) * tolerance); // return result; } bool IsRSISwitchedToOversold( int barIndex = 0, double threshold = 30, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIOversold(barIndex, threshold, tolerance) && !IsRSIOversold(barIndex + 1, threshold, tolerance); // return result; } bool IsRSISwitchedFromOversold( int barIndex = 0, double threshold = 30, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && !IsRSIOversold(barIndex, threshold, tolerance) && IsRSIOversold(barIndex + 1, threshold, tolerance); // return result; } bool IsRSISwitchedToOverbought( int barIndex = 0, double threshold = 70, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && IsRSIOverbought(barIndex, threshold, tolerance) && !IsRSIOverbought(barIndex + 1, threshold, tolerance); // return result; } bool IsRSISwitchedFromOverbought( int barIndex = 0, double threshold = 70, double tolerance = 2 // ) { // bool result = false; // barIndex = NormalizeBarIndex(barIndex); // result = IsValid() && !IsRSIOverbought(barIndex, threshold, tolerance) && IsRSIOverbought(barIndex + 1, threshold, tolerance); // return result; } // #endregion // #region Composite ... bool IsKIHasTrend( double &score, ENUM_X_DIRECTION &dir, int barIndex = 0, double requiredScore = 0, double tolerance = 2 // ) { // bool result = false; // score = 0; dir = X_DIRECTION_NONE; if (requiredScore < 0) { requiredScore = 0; } barIndex = NormalizeBarIndex(barIndex); result = IsValid(); if (!result) { return result; } // bool isBullish = IsKIFastBullish(barIndex) && IsKISlowBullish(barIndex); bool isBearish = IsKIFastBearish(barIndex) && IsKISlowBearish(barIndex); // // Scoring ... if (isBullish) { // if (IsKIFastSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_MAX; } // if (IsKISlowSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } // if (IsKIFastSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKIFastOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsKISlowSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISlowOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsKISuperSlowSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISuperSlowBullish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsKISuperSlowSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISuperSlowOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } else if (isBearish) { // if (IsKIFastSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_MAX; } // if (IsKISlowSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } // if (IsKIFastSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKIFastUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsKISlowSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISlowUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsKISuperSlowSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISuperSlowBearish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsKISuperSlowSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsKISuperSlowUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } // dir = isBullish ? X_DIRECTION_BULLISH : isBearish ? X_DIRECTION_BEARISH : X_DIRECTION_NONE; // result = HasDirection(dir) && score >= requiredScore; // return result; } bool IsMAHasTrend( double &score, ENUM_X_DIRECTION &dir, int barIndex = 0, double requiredScore = 0, double tolerance = 2 // ) { // bool result = false; // score = 0; dir = X_DIRECTION_NONE; if (requiredScore < 0) { requiredScore = 0; } barIndex = NormalizeBarIndex(barIndex); // result = IsValid(); if (!result) { return result; } // bool isBullish = IsMACrossoverBullish(barIndex); bool isBearish = IsMACrossoverBearish(barIndex); // if (isBullish) { // if (IsMACrossoverSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_MAX; } // if (IsMAFastSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_MAX; } else if (IsMAFastBullish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } // if (IsMAFastSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMAFastOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsMASlowSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASlowBullish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsMASlowSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASlowOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsMASuperSlowSwitchedToBullish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASuperSlowBullish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsMASuperSlowSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASuperSlowOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } else if (isBearish) { // if (IsMACrossoverSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_MAX; } // if (IsMAFastSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_MAX; } else if (IsMAFastBearish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } // if (IsMAFastSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMAFastUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsMASlowSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASlowBullish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsMASlowSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASlowUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsMASuperSlowSwitchedToBearish(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASuperSlowBearish(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsMASuperSlowSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsMASuperSlowUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } // dir = isBullish ? X_DIRECTION_BULLISH : isBearish ? X_DIRECTION_BEARISH : X_DIRECTION_NONE; // result = HasDirection(dir) && score >= requiredScore; // return result; } bool IsMomentumExists( double &score, ENUM_X_DIRECTION &dir, int barIndex = 0, double requiredScore = 0, double tolerance = 2, double bullishThreshold = 55, double bearishThreshold = 45, double overboughtThreshold = 70, double oversoldThreshold = 30 // ) { // bool result = false; // score = 0; dir = X_DIRECTION_NONE; if (requiredScore < 0) { requiredScore = 0; } barIndex = NormalizeBarIndex(barIndex); bullishThreshold = NormalizeXDouble(bullishThreshold, 0, 100); bearishThreshold = NormalizeXDouble(bearishThreshold, 0, 100); oversoldThreshold = NormalizeXDouble(oversoldThreshold, 0, 100); overboughtThreshold = NormalizeXDouble(overboughtThreshold, 0, 100); // result = IsValid(); if (!result) { return result; } // bool isBullish = IsRSIBullish(barIndex, bullishThreshold, tolerance); bool isBearish = IsRSIBearish(barIndex, bearishThreshold, tolerance); // if (isBullish) { // if (!IsRSIOverbought(barIndex, overboughtThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSIOversold(barIndex, oversoldThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedFromOversold(barIndex, oversoldThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedToBullish(barIndex, bullishThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedToRising(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsRSIRising(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsRSISwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsRSIOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } else if (isBearish) { // if (!IsRSIOversold(barIndex, oversoldThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSIOverbought(barIndex, overboughtThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedFromOverbought(barIndex, overboughtThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedToBearish(barIndex, bearishThreshold, tolerance)) { score += X121_XKI_SCORE_NORMAL; } // if (IsRSISwitchedToFalling(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsRSIFalling(barIndex)) { score += X121_XKI_SCORE_MIN; } // if (IsRSISwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsRSIUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } } // dir = isBullish ? X_DIRECTION_BULLISH : isBearish ? X_DIRECTION_BEARISH : X_DIRECTION_NONE; // result = HasDirection(dir) && score >= requiredScore; // return result; } bool IsVolatilityExists( double &score, ENUM_X_DIRECTION &dir, int barIndex = 0, double requiredScore = 0, double tolerance = 2, ENUM_X_PRICE priceType = X_PRICE_CLOSE // ) { // bool result = false; // score = 0; dir = X_DIRECTION_NONE; if (requiredScore < 0) { requiredScore = 0; } barIndex = NormalizeBarIndex(barIndex); // result = IsValid(); if (!result) { return result; } // bool isBullish = IsATROverLast(barIndex, tolerance) || IsATRSmoothedOverLast(barIndex, tolerance); bool isBearish = IsATRUnderLast(barIndex, tolerance) || IsATRSmoothedUnderLast(barIndex, tolerance); // if (isBullish) { // if (IsATRBreakoutDown(barIndex, priceType)) { score += X121_XKI_SCORE_NORMAL; } // if (!IsATRBreakoutUp(barIndex, priceType)) { score += X121_XKI_SCORE_MIN; } // if (IsATRSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsATROverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsATRSmoothedSwitchedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsATRSmoothedOverLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsVolatilitySwitchdToHigh(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsVolatilityHigh(barIndex)) { score += X121_XKI_SCORE_MIN; } } else if (isBearish) { // if (!IsATRBreakoutDown(barIndex, priceType)) { score += X121_XKI_SCORE_NORMAL; } // if (IsATRBreakoutUp(barIndex, priceType)) { score += X121_XKI_SCORE_MIN; } // if (IsATRSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsATRUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsATRSmoothedSwitchedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_NORMAL; } else if (IsATRSmoothedUnderLast(barIndex, tolerance)) { score += X121_XKI_SCORE_MIN; } // if (IsVolatilitySwitchdToLow(barIndex)) { score += X121_XKI_SCORE_NORMAL; } else if (IsVolatilityLow(barIndex)) { score += X121_XKI_SCORE_MIN; } } // dir = isBullish ? X_DIRECTION_BULLISH : isBearish ? X_DIRECTION_BEARISH : X_DIRECTION_NONE; // result = HasDirection(dir) && score >= requiredScore; // return result; } // #endregion // #region Signalling Conditions ... bool HasCompositeTrend( double &score, ENUM_X_DIRECTION &dir, int barIndex = 0, double requiredScore = 0, double tolerance = 2, ENUM_X_PRICE priceType = X_PRICE_CLOSE, double bullishThreshold = 55, double bearishThreshold = 45, double overboughtThreshold = 70, double oversoldThreshold = 30 // ) { // bool result = false; // score = 0; dir = X_DIRECTION_NONE; barIndex = NormalizeBarIndex(barIndex); // result = IsValid(); if (!result) { return result; } // bool hasKI, hasMa, hasMomentum, hasVolatility; double kiScore, maScore, momentumScore, volatilityScore; ENUM_X_DIRECTION kiDir, maDir, momentumDir, volatilityDdir; // hasKI = IsKIHasTrend( kiScore, kiDir, barIndex, 1, tolerance // ); hasMa = IsMAHasTrend( maScore, maDir, barIndex, 1, tolerance // ); hasVolatility = IsVolatilityExists( volatilityScore, volatilityDdir, barIndex, 1, tolerance, priceType // ); hasMomentum = IsMomentumExists( momentumScore, momentumDir, barIndex, 1, tolerance, bullishThreshold, bearishThreshold, overboughtThreshold, oversoldThreshold // ); // bool isBullish = hasKI && IsXBullish(kiDir) && hasMa && IsXBullish(maDir) && hasMomentum && IsXBullish(momentumDir) && hasVolatility && IsXBullish(volatilityDdir); // bool isBearish = hasKI && IsXBearish(kiDir) && hasMa && IsXBearish(maDir) && hasMomentum && IsXBullish(momentumDir) && hasVolatility && IsXBullish(volatilityDdir); // result = isBullish || isBearish; if (!result) { return result; } // // Summarizing Scores ... score = (kiScore + maScore + momentumScore + volatilityScore); result = result && score >= requiredScore; if (result) { // dir = isBullish ? X_DIRECTION_BULLISH : isBearish ? X_DIRECTION_BEARISH : X_DIRECTION_NONE; } // result = result && HasDirection(dir); // return result; } // #endregion // // Protected ... protected: // // // Private ... private: // XCX121XKIHelper *helper; // }; //