High and Low of Day Indicator

 
I would filter by day in MT5, can someone help me?

Thanks!


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2


double day_high = 0;
double day_low = 0;

double hi[];
double lo[];


int OnInit() {

    SetIndexBuffer(0, hi, INDICATOR_DATA);
    PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE);
    PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_SOLID);
    PlotIndexSetInteger(0,PLOT_LINE_WIDTH,1);
    PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrLime);
    PlotIndexSetString(0,PLOT_LABEL,"hi");
    
    SetIndexBuffer(1, lo, INDICATOR_DATA);
    PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_LINE);
    PlotIndexSetInteger(1,PLOT_LINE_STYLE,STYLE_SOLID);
    PlotIndexSetInteger(1,PLOT_LINE_WIDTH,2);
    PlotIndexSetInteger(1,PLOT_LINE_COLOR,clrRed);
    PlotIndexSetString(1,PLOT_LABEL,"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;
    if (prev_calculated == 0) {
        limit = 0;
    } else {
        limit = prev_calculated - 1;
    }

    for (int i = limit; i < rates_total && !IsStopped(); i++) {

        if (i == 0) {
            day_high = open[0];
            day_low = open[0];
        }
        
        if (high[i] > day_high) {
            day_high = high[i];
        }

        if (low[i] < day_low) {
            day_low = low[i];
        }

        hi[i] = day_high;
        lo[i] = day_low;
        
    }

    return (rates_total);
}


Reason: