/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Helper Class Library // ---------------------------------------------- // Name: XSCXLHHelper // Description: provides all Indicator // Helper 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 "../Classes/x-saherelm.xhelper.class.mq5" // // Definitions ... // enum ENUM_XLH_BUFFERS { XLH_HH_LINE = 0, XLH_LL_LINE = 1, XLH_SIGNAL_LINE = 2, }; // // Input Models ... struct XLHInputs { // // Props ... int length; // Length ENUM_SERIESMODE hhMode; // Highest High Calculation Method ENUM_SERIESMODE llMode; // Lowest Low Calculation Method // // Constructor(s) ... XLHInputs() { // Clean(); } // // Tools ... // // Clean ... void Clean() { // length = 0; hhMode = MODE_HIGH; llMode = MODE_LOW; } // // Default ... void Default() { // length = 14; hhMode = MODE_HIGH; llMode = MODE_LOW; } // // Validate ... bool IsValid() { // bool result = false; // result = // length >= 2 // ; // return result; } // // Retrieve MAx Length ... int Max() { // int result = 0; // result = MathMax(result, length); // return result; } }; // // Class ... class XSCXLHHelper : public XSCBaseHelper { // // Public ... public: // // Props ... // // Constructors ... XSCXLHHelper() : XSCBaseHelper(_Symbol, _Period) { } // // Deconstructor ... ~XSCXLHHelper() {} // // Tools ... bool Init( string symbol, // Trading Symbol ENUM_TIMEFRAMES period, // Trading Period XLHInputs &inputs // Inputs ) { // bool result = false; // mSymbol = symbol; mPeriod = period; // result = inputs.IsValid(); if (!result) { return result; } // mInputs = inputs; // ArraySetAsSeries(hhBuffer, true); ArraySetAsSeries(llBuffer, true); ArraySetAsSeries(signalBuffer, true); // mHandler = iCustom( mSymbol, mPeriod, "x-saherelm.xlh", // // Inputs ... mInputs.length, // Length mInputs.hhMode, // Highest High Calculation Method mInputs.llMode // Lowest Low Calculation Method // ); result = mHandler != INVALID_HANDLE; if (!result) { return result; } // return result; } // // Inputs ... // XLHInputs GetInputs() { return mInputs; } // bool SetInputs( XLHInputs &inputs // Configs ) { // return Init( mSymbol, mPeriod, inputs // ); } // // Buffers ... // double GetHH( int barIndex // Bar Index ) { // if (barIndex < 0) { barIndex = 0; } // Calculate(); // int count = ArraySize(hhBuffer); if (barIndex >= count) { barIndex = count - 1; } // return hhBuffer[barIndex]; } // // Copy Required Items ... int CopyHH( int start, // Start int count, // Number of Items for read double &buffer[], // Dest Buffer bool forceClean = true // Force To Clean buffer ) { // // Update Calculations ... Calculate(); // // Copy Items ... return Copy( start, count, hhBuffer, buffer, forceClean // ); } // double GetLL( int barIndex // Bar Index ) { // if (barIndex < 0) { barIndex = 0; } // Calculate(); // int count = ArraySize(llBuffer); if (barIndex >= count) { barIndex = count - 1; } // return llBuffer[barIndex]; } // // Copy Required Items ... int CopyLL( int start, // Start int count, // Number of Items for read double &buffer[], // Dest Buffer bool forceClean = true // Force To Clean buffer ) { // // Update Calculations ... Calculate(); // // Copy Items ... return Copy( start, count, llBuffer, buffer, forceClean // ); } // double GetSignal( int barIndex // Bar Index ) { // if (barIndex < 0) { barIndex = 0; } // Calculate(); // int count = ArraySize(signalBuffer); if (barIndex >= count) { barIndex = count - 1; } // return signalBuffer[barIndex]; } // // Copy Required Items ... int CopySignal( int start, // Start int count, // Number of Items for read double &buffer[], // Dest Buffer bool forceClean = true // Force To Clean buffer ) { // // Update Calculations ... Calculate(); // // Copy Items ... return Copy( start, count, signalBuffer, buffer, forceClean // ); } // // Protected ... protected: // // Private ... private: // // Props ... XLHInputs mInputs; // Inputs ... // // Buffers ... double hhBuffer[]; double llBuffer[]; double signalBuffer[]; // // Tools ... // // Calculate Values Until Now ... void Calculate() { // int totalBars = CountBars(); // // HH ... CopyBuffer( mHandler, XLH_HH_LINE, 0, totalBars, hhBuffer // ); // // LL ... CopyBuffer( mHandler, XLH_LL_LINE, 0, totalBars, llBuffer // ); // // Signal ... CopyBuffer( mHandler, XLH_SIGNAL_LINE, 0, totalBars, signalBuffer // ); } }; // // Tools ...