//+------------------------------------------------------------------+
//|                                                       hltest.mq4 |
//|                                                              RHT |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "RHT"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers  4
#property  indicator_color3  Green
#property  indicator_color4  Red
#property  indicator_width3  2
#property  indicator_width4  2


extern int myval = 24;

double upper[];
double lower [];
double hupper [];
double llower [];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
  //   int lowest  = iLowest(NULL,0,MODE_LOW,myval,1);
  //   int highest = iHighest(NULL,0,MODE_HIGH,myval,1);
     
     //---- drawing settings
 //  SetIndexStyle(0,DRAW_LINE);
 //  SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
//---- indicator buffers mapping
  // SetIndexBuffer(0,upper);
  // SetIndexBuffer(1,lower); 
   SetIndexBuffer(2,upper);
   SetIndexBuffer(3,lower);
   IndicatorShortName("test("+myval+")");
   SetIndexLabel(2,"hUpper");
   SetIndexLabel(3,"lLower");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration 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=rates_total-prev_calculated; 
//--- main loop 
 //  for(int i=0; i<limit; i++) 

   
   //---- calculate values
   for(int i=0; i<limit; i++) 
   for(int j=0; j<limit; i++){
      hupper[j]= myval - ( iHighest(NULL,0,MODE_HIGH,myval,1)/24);
      llower[j]= myval -( iLowest(NULL,0,MODE_LOW,myval,1)/24);}
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
