//+------------------------------------------------------------------+ //| HHLLindicators.mq4 //| Copyright 2023, Aurel Ispas //| http://www.yourwebsite.com //+------------------------------------------------------------------+ #property copyright "AurelIspas" #property link "http://www.ok.ro" #property indicator_chart_window #property indicator_buffers 5 // Define colors as numeric values #property indicator_color1 16777215 // White #property indicator_color2 65535 // Aqua #property indicator_color3 65535 // Aqua #property indicator_color4 16744448 // Orange #property indicator_color5 16744448 // Orange // Input parameters input int CountBars = 4000; input int bandlen = 48; // Buffers double highline[]; double lowline[]; double highline2[]; double lowline2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { // Indicator buffers IndicatorBuffers(4); SetIndexBuffer(0, highline); SetIndexBuffer(1, lowline); SetIndexBuffer(2, highline2); SetIndexBuffer(3, lowline2); // Indicator colors and styles SetIndexStyle(0, DRAW_LINE); SetIndexStyle(1, DRAW_LINE); SetIndexStyle(2, DRAW_LINE); SetIndexStyle(3, DRAW_LINE); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator calculation function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int limit = MathMin(rates_total - bandlen - 1, CountBars); if (limit < 1) limit = 1; ArraySetAsSeries(highline, true); ArraySetAsSeries(lowline, true); ArraySetAsSeries(highline2, true); ArraySetAsSeries(lowline2, true); for (int shift = limit; shift >= 0; shift--) { double H1, L1; double H2, L2; H1 = iHigh(Symbol(), 0, iHighest(Symbol(), 0, PRICE_HIGH, bandlen, shift + 1)); L1 = iLow(Symbol(), 0, iLowest(Symbol(), 0, PRICE_LOW, bandlen, shift + 1)); highline[shift] = H1; lowline[shift] = L1; H2 = high[shift + 1]; L2 = low[shift + 1]; for (int k = 1; k < bandlen; k++) { double HV = high[shift + k + 1]; double LV = low[shift + k + 1]; if (HV > H2) H2 = HV; if (LV < L2) L2 = LV; } highline2[shift] = H2; lowline2[shift] = L2; } return(rates_total); } //+------------------------------------------------------------------+