Refreshing Custom Indicator

 

Hello,

I have searched and searched and can find nothing that helps me! 

My problem is I have coded a custom indicator and the values of it change when you refresh the chart (right click and click 'refresh'). Once it has been refreshed once per bar, the values remain as correct.

I call on this indicator via iCustom in an EA and I am concerned it will only work correctly if I can refresh the indicator values all the time. However I cannot find a way to refresh the window in code.

I have tried the ChartRedraw(0) function and it does not work. I have also tried using ChartRedraw(1) incase the subwindow is chartID(1).

Does anyone know how to effectively refresh the indicator window?

Thanks in advance!

Will

 
Also, the custom indicator seems to disappear from the chart/calculate incorrect values once it is left for a while. I have no idea why, has anyone else experienced this?
 
w_kitching:
Also, the custom indicator seems to disappear from the chart/calculate incorrect values once it is left for a while. I have no idea why, has anyone else experienced this?

your indicator has coding problems

 
ChartSetSymbolPeriod(0, _Symbol, _Period);
 

Thanks for all your comments!

Just to wrap this up if anyone else later has a similar issue..

The indicator cut out every now and then because of a zero divide error when calling a different symbols prices.

The solution was simply to put an if statement before the divide to check that the value is not zero!

Also the ChartSetSymbolPeriod works a treat to automatically refresh the chart.

Thank you for your help!

 
Good Morning!

I have the same problem. How did you implement the graph update to work?
Placing the function "ChartSetSymbolPeriod" my MetaTrader was crashed.

Thank you.