Download MetaTrader 5

MTF MACD do not refresh automatically

To add comments, please log in or register
Elo
87
Elo  
Hi Guys,

I have faced with an issue - MTF MACD indicator (for H1 period) on M5 period chart do not refresh its values automatically when new bar has closed. It draw different values for every lower TF bar. The value of the high level bar has to be one and the same for all lower TF bars and has to be recalculated every time intil the High level bar has closed. I have marked in red rectangle the values which are after I pressed Refresh on the chart. Before that point the values were correct.

How this can be fixed within the indicator's code ?

Files:
whroeder1
15019
whroeder1  
  1.   if (Time[i]<TimeArray[y]) y++;
    This fails when there are missing bars in TimeFrame chart. Use while not if. This is why I recommend not using the ArrayCopySeries but iBarShift.
          y = iBarShift(NULL, timeframe, Time[i]);
    

  2. You want to repaint all TimeFrame bar zero values
    // for(i=0,y=0;i<limit;i++)
       for(i=0,y=0;i<limit || y == 0;i++)
Elo
87
Elo  
Thank you WHRoeder, now it is working fine.
To add comments, please log in or register