///////////////////////////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 XATRSLHLP Indicator Helper for Signal Providers // -------------------------------------------------------------------------- // // 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 // // START Includes ... // // // Includes ... #include "../../Libraries/x-saherelm.alert.lib.mq5" #include "../../Libraries/x-saherelm.models.lib.mq5" #include "../../Libraries/x-saherelm.common.lib.mq5" // // END Includes ... // // // START Constants/Enums ... // // // XPeaksAndVales Exported Buffers ... enum ENUM_X_XATRSL_BUFFERS { // X_ATRSL_UP_LINE = 0, X_ATRSL_DOWN_LINE = 1, X_ATRSL_SAR_LINE = 2, X_ATRSL_RMA_LINE = 3, X_ATRSL_WMA_LINE = 4, X_ATRSL_MA1_LINE = 5, X_ATRSL_SMA_LINE = 6, X_ATRSL_EMA_LINE = 7, X_ATRSL_ATR_LINE = 8, }; // // END Constants/Enums ... // // // START Definitions ... // // double atrslUpBuffer[]; double atrslDownBuffer[]; double atrslSarBuffer[]; // int atrslHandler = INVALID_HANDLE; // // END Definitions ... // // // START Handler Functions ... // // bool XATRSLHLPOnInit() { // bool result = false; // ArraySetAsSeries(atrslUpBuffer, true); ArraySetAsSeries(atrslSarBuffer, true); ArraySetAsSeries(atrslDownBuffer, true); // // Initial Handler ... atrslHandler = iCustom( _Symbol, _Period, "x-saherelm.x121.xatrsl", // // Inputs ... // // MARKET ... "", 14, 0.02, 0.2, PRICE_HIGH, PRICE_LOW, // // PRESENTATION ... "", false, false, true // ); result = atrslHandler != INVALID_HANDLE; // return result; } // void XATRSLHLPOnDeInit() { // // Release Indicators ... IndicatorRelease(atrslHandler); } // void XATRSLHLPReadBuffers() { // // UP ... CopyBuffer( atrslHandler, X_ATRSL_UP_LINE, 0, 10, atrslUpBuffer); // // DOWN ... CopyBuffer( atrslHandler, X_ATRSL_DOWN_LINE, 0, 10, atrslDownBuffer); // // SAR ... CopyBuffer( atrslHandler, X_ATRSL_SAR_LINE, 0, 10, atrslSarBuffer); } // // END Handler Functions ... // // // START Helper Functions ... // // // Calculate Change Rate For Specific Bar ... double XATRSLHLPGetChangeRate( int bar_index // Bar Index ... ) { // double result = 0; // if (!XATRSLHLPIsValidArraySize(bar_index)) { return result; } // result = MathAbs(atrslUpBuffer[bar_index] - atrslDownBuffer[bar_index]); // return result; } // // Calculate Change Rate For Specific Lenght ... double XATRSLHLPGetRangeChangeRate( int bar_index, // Bar Index ... int length = 5 // Loopback Length ... ) { // double result = 0; // int size = bar_index + length; if (!XATRSLHLPIsValidArraySize(size)) { return result; } // double summary = 0; for (int i = bar_index; i < size; i++) { summary += MathAbs(atrslUpBuffer[i] - atrslDownBuffer[i]); } // result = summary / size; // return result; } // // Check Array Size ... bool XATRSLHLPIsValidArraySize(int bar_index) { // bool result = false; // int rCount = ArraySize(atrslUpBuffer); result = rCount > bar_index + 1; // return result; } // // END Helper Functions ... //