/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Helper Class Library // ---------------------------------------------- // Name: XSCXCHLHHelper // 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_XCHLH_BUFFERS { // // LC ... XCHLH_LC_HH_LINE = 0, XCHLH_LC_LL_LINE = 1, // // MC ... XCHLH_MC_HH_LINE = 2, XCHLH_MC_LL_LINE = 3, // // SC ... XCHLH_SC_HH_LINE = 4, XCHLH_SC_LL_LINE = 5, // // Hot State ... XCHLH_HOT_STATE_LINE = 6 }; // // Input Models ... struct XXCHLHInputs { // // Props ... // // Hot Areas ... bool drawHotAreas; // Draw Hot Areas Symbol uchar hotHHArrowCode; // Hot HH Arrow Code color hotHHArrowColor; // Hot HH Arrow Color uchar hotLLArrowCode; // Hot LL Arrow Code color hotLLArrowColor; // Hot LL Arrow Color // // Long Cycle ... // LC Market ... int lcLength; // Length double lcThresholdInPips; // Threshold In Pips ENUM_SERIESMODE lcHHMode; // Highest High Calculation Method ENUM_SERIESMODE lcLLMode; // Lowest Low Calculation Method // // LC Style ... int lcDrawWidth; // Draw Width ENUM_DRAW_TYPE lcDrawType; // Draw Type ENUM_LINE_STYLE lcDrawStyle; // Draw Style color lcHHColor; // Highest High Color color lcLLColor; // Lowest Low Color // LC Drawings ... bool lcDrawHH; // Draw Highest High bool lcDrawLL; // Draw Lowest Low // // Medium Cycle ... // MC Market ... int mcLength; // Length double mcThresholdInPips; // Threshold In Pips ENUM_SERIESMODE mcHHMode; // Highest High Calculation Method ENUM_SERIESMODE mcLLMode; // Lowest Low Calculation Method // MC Style ... int mcDrawWidth; // Draw Width ENUM_DRAW_TYPE mcDrawType; // Draw Type ENUM_LINE_STYLE mcDrawStyle; // Draw Style color mcHHColor; // Highest High Color color mcLLColor; // Lowest Low Color // MC Drawings ... bool mcDrawHH; // Draw Highest High bool mcDrawLL; // Draw Lowest Low // // Short Cycle ... // SC Market ... int scLength; // Length double scThresholdInPips; // Threshold In Pips ENUM_SERIESMODE scHHMode; // Highest High Calculation Method ENUM_SERIESMODE scLLMode; // Lowest Low Calculation Method // SC Style ... int scDrawWidth; // Draw Width ENUM_DRAW_TYPE scDrawType; // Draw Type ENUM_LINE_STYLE scDrawStyle; // Draw Style color scHHColor; // Highest High Color color scLLColor; // Lowest Low Color // SC Drawings ... bool scDrawHH; // Draw Highest High bool scDrawLL; // Draw Lowest Low // // Constructor(s) ... XXCHLHInputs() { // Clean(); } // // Tools ... // // Clean ... void Clean() { // // Hot Areas ... drawHotAreas = false; hotHHArrowCode = 234; hotHHArrowColor = CLR_NONE; hotLLArrowCode = 233; hotLLArrowColor = CLR_NONE; // // Long Cycle ... // LC Market ... lcLength = 0; lcThresholdInPips = 0; lcHHMode = MODE_HIGH; lcLLMode = MODE_LOW; // // LC Style ... lcDrawWidth = 1; lcDrawType = DRAW_NONE; lcDrawStyle = STYLE_DOT; lcHHColor = CLR_NONE; lcLLColor = CLR_NONE; // LC Drawings ... lcDrawHH = false; lcDrawLL = false; // // Medium Cycle ... // MC Market ... mcLength = 0; mcThresholdInPips = 0; mcHHMode = MODE_HIGH; mcLLMode = MODE_LOW; // MC Style ... mcDrawWidth = 1; mcDrawType = DRAW_NONE; mcDrawStyle = STYLE_DOT; mcHHColor = CLR_NONE; mcLLColor = CLR_NONE; // MC Drawings ... mcDrawHH = false; mcDrawLL = false; // // Short Cycle ... // SC Market ... scLength = 0; scThresholdInPips = 0; scHHMode = MODE_HIGH; scLLMode = MODE_LOW; // SC Style ... scDrawWidth = 1; scDrawType = DRAW_NONE; scDrawStyle = STYLE_DOT; scHHColor = CLR_NONE; scLLColor = CLR_NONE; // SC Drawings ... scDrawHH = false; scDrawLL = false; } // // Default ... void Default() { // // Hot Areas ... drawHotAreas = false; hotHHArrowCode = 234; hotHHArrowColor = CLR_NONE; hotLLArrowCode = 233; hotLLArrowColor = CLR_NONE; // // Long Cycle ... // LC Market ... lcLength = 28; lcThresholdInPips = 0.3; lcHHMode = MODE_HIGH; lcLLMode = MODE_LOW; // // LC Style ... lcDrawWidth = 1; lcDrawType = DRAW_LINE; lcDrawStyle = STYLE_DOT; lcHHColor = clrAqua; lcLLColor = clrFuchsia; // LC Drawings ... lcDrawHH = true; lcDrawLL = true; // // Medium Cycle ... // MC Market ... mcLength = 14; mcThresholdInPips = 0.3; mcHHMode = MODE_HIGH; mcLLMode = MODE_LOW; // MC Style ... mcDrawWidth = 1; mcDrawType = DRAW_LINE; mcDrawStyle = STYLE_DOT; mcHHColor = clrLime; mcLLColor = clrRed; // MC Drawings ... mcDrawHH = true; mcDrawLL = true; // // Short Cycle ... // SC Market ... scLength = 7; scThresholdInPips = 0.3; scHHMode = MODE_HIGH; scLLMode = MODE_LOW; // SC Style ... scDrawWidth = 1; scDrawType = DRAW_LINE; scDrawStyle = STYLE_DOT; scHHColor = clrLightBlue; scLLColor = clrLightSalmon; // SC Drawings ... scDrawHH = true; scDrawLL = true; } // // Validate ... bool IsValid() { // bool result = false; // result = // // LC ... (lcLength >= 4 && lcLength > mcLength && lcLength > scLength) // && // // MC ... (mcLength >= 4 && mcLength > scLength && mcLength < lcLength) // && // // SC ... (scLength >= 4 && scLength < mcLength && scLength < lcLength) // ; // return result; } // // Retrieve MAx Length ... int Max() { // int result = 0; // result = MathMax(lcLength, mcLength); result = MathMax(result, scLength); // return result; } }; // // Class ... class XSCXCHLHHelper : public XSCBaseHelper { // // Public ... public: // // Props ... // // Constructors ... XSCXCHLHHelper() : XSCBaseHelper(_Symbol, _Period) { } // // Deconstructor ... ~XSCXCHLHHelper() {} // // Tools ... bool Init( string symbol, // Trading Symbol ENUM_TIMEFRAMES period, // Trading Period XXCHLHInputs &inputs // Inputs ) { // bool result = false; // mSymbol = symbol; mPeriod = period; // result = inputs.IsValid(); if (!result) { return result; } // mInputs = inputs; // ArraySetAsSeries(scHHBuffer, true); ArraySetAsSeries(scLLBuffer, true); ArraySetAsSeries(mcHHBuffer, true); ArraySetAsSeries(mcLLBuffer, true); ArraySetAsSeries(lcHHBuffer, true); ArraySetAsSeries(lcLLBuffer, true); ArraySetAsSeries(hotStateBuffer, true); // mHandler = iCustom( mSymbol, mPeriod, "x-saherelm.xchlh", // // Inputs ... // // Hot Areas ... "", // mInputs.drawHotAreas, // Draw Hot Areas Symbol mInputs.hotHHArrowCode, // Hot HH Arrow Code mInputs.hotHHArrowColor, // Hot HH Arrow Color mInputs.hotLLArrowCode, // Hot LL Arrow Code mInputs.hotLLArrowColor, // Hot LL Arrow Color // // Long Cycle ... "", // LC Market ... "", // mInputs.lcLength, // Length mInputs.lcThresholdInPips, // Threshold In Pips mInputs.lcHHMode, // Highest High Calculation Method mInputs.lcLLMode, // Lowest Low Calculation Method // // LC Style ... "", // mInputs.lcDrawWidth, // Draw Width mInputs.lcDrawType, // Draw Type mInputs.lcDrawStyle, // Draw Style mInputs.lcHHColor, // Highest High Color mInputs.lcLLColor, // Lowest Low Color // // LC Drawings ... "", mInputs.lcDrawHH, // Draw Highest High mInputs.lcDrawLL, // Draw Lowest Low // // Medium Cycle ... "", // MC Market ... "", // mInputs.mcLength, // Length mInputs.mcThresholdInPips, // Threshold In Pips mInputs.mcHHMode, // Highest High Calculation Method mInputs.mcLLMode, // Lowest Low Calculation Method // // MC Style ... "", // mInputs.mcDrawWidth, // Draw Width mInputs.mcDrawType, // Draw Type mInputs.mcDrawStyle, // Draw Style mInputs.mcHHColor, // Highest High Color mInputs.mcLLColor, // Lowest Low Color // // MC Drawings ... "", mInputs.mcDrawHH, // Draw Highest High mInputs.mcDrawLL, // Draw Lowest Low // // Short Cycle ... "", // SC Market ... "", // mInputs.scLength, // Length mInputs.scThresholdInPips, // Threshold In Pips mInputs.scHHMode, // Highest High Calculation Method mInputs.scLLMode, // Lowest Low Calculation Method // // SC Style ... "", // mInputs.scDrawWidth, // Draw Width mInputs.scDrawType, // Draw Type mInputs.scDrawStyle, // Draw Style mInputs.scHHColor, // Highest High Color mInputs.scLLColor, // Lowest Low Color // // SC Drawings ... "", mInputs.scDrawHH, // Draw Highest High mInputs.scDrawLL // Draw Lowest Low // ); result = mHandler != INVALID_HANDLE; if (!result) { return result; } // return result; } // // Inputs ... // XXCHLHInputs GetInputs() { return mInputs; } // bool SetInputs( XXCHLHInputs &inputs // Configs ) { // return Init( mSymbol, mPeriod, inputs // ); } // // Buffers ... // // // double GetMain( // int barIndex // Bar Index // ) // { // // // if (barIndex < 0) // { // barIndex = 0; // } // // // Calculate(); // // // int count = ArraySize(mainBuffer); // if (barIndex >= count) // { // barIndex = count - 1; // } // // // return mainBuffer[barIndex]; // } // // // // Copy Required Long Exits 2 ... // int CopyLongExit2( // 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, // longExit2Buffer, // buffer, // forceClean // // // ); // } // // Protected ... protected: // // Private ... private: // // Props ... XXCHLHInputs mInputs; // Inputs ... // // Buffers ... double scHHBuffer[]; double scLLBuffer[]; double mcHHBuffer[]; double mcLLBuffer[]; double lcHHBuffer[]; double lcLLBuffer[]; double hotStateBuffer[]; // // Tools ... // // Calculate Values Until Now ... void Calculate() { // int totalBars = CountBars(); // // Short Cycle ... // // HH ... CopyBuffer( mHandler, XCHLH_SC_HH_LINE, 0, totalBars, scHHBuffer // ); // // LL ... CopyBuffer( mHandler, XCHLH_SC_LL_LINE, 0, totalBars, scLLBuffer // ); // // Medium Cycle ... // // HH ... CopyBuffer( mHandler, XCHLH_MC_HH_LINE, 0, totalBars, mcHHBuffer // ); // // LL ... CopyBuffer( mHandler, XCHLH_MC_LL_LINE, 0, totalBars, mcLLBuffer // ); // // Long Cycle ... // // HH ... CopyBuffer( mHandler, XCHLH_LC_HH_LINE, 0, totalBars, lcHHBuffer // ); // // LL ... CopyBuffer( mHandler, XCHLH_LC_LL_LINE, 0, totalBars, lcLLBuffer // ); // // Hot State ... CopyBuffer( mHandler, XCHLH_HOT_STATE_LINE, 0, totalBars, hotStateBuffer // ); } } // // Tools ...