MT5 new functions, help

 
I'm using the new mt5 functions to generate a history graph of highs and lows of the day, but it's not working.

Basically it's taking the highs and lows of the whole graphic, I'm wanting it to take day by day.

In mt4 I made a similar code and everything worked out, but in mt5 something is wrong.

Could someone give me a light?


iHigh, iLow, iBarShift, iLowest, iHighest

https://www.metaquotes.net/en/metatrader5/news/5101


#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2


#property indicator_label1  "high"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#property indicator_label2  "low"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1



double hi[];
double lo[];



int OnInit() {
      SetIndexBuffer(0,hi);
      SetIndexBuffer(1,lo);
    
    return (0);
}


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;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(hi, true);
   ArraySetAsSeries(lo, true);
   
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(hi, 0);
      ArrayInitialize(lo, 0);
      
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--) {
   
         datetime now = time[i];
         int tod = now % 86400;
         datetime midnight = now - tod;
         
         //Print(midnight);
         
      
        
        int shift = iBarShift(NULL,0,midnight,false);
        //Print(shift);

        int count = shift-i+1;
        
        //Print(count);
       

         hi[i]=iHigh(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_HIGH,shift,i));
         lo[i]=iLow(Symbol(),Period(),iLowest(Symbol(),Period(),MODE_LOW,shift,i));
         
         
        
    }

    return (rates_total);
}


MT4, ok!

Chart GBPUSD, M5, 2018.09.27 23:38 UTC, Pepperstone Group Limited, MetaTrader 4, Demo


MT5, strong

Chart DOLV18, M15, 2018.09.27 23:40 UTC, XP Investimentos CCTVM S/A, MetaTrader 5, Demo
MetaTrader 5 build 1860: MQL5 functions for operations with bars and Strategy Tester improvements
MetaTrader 5 build 1860: MQL5 functions for operations with bars and Strategy Tester improvements
  • 2018.06.15
  • MetaQuotes Software Corp.
  • www.metaquotes.net
The account opening dialog has been completely redesigned. Now, you may select a broker from the list and then choose the desired account type. This update has made the list of brokers more compact, since now it only displays company names instead of showing all available servers. Company logos are additionally shown in the list to make the...
 
Set the time[] array as series as well.