The following script uses a timer and works well in normal charts to comment current candle closing price every 1 second on chart. However, on offline chart, it only loads the closing price once and does not update it every second. Here is the code:
void OnTimer()
{
int m=TimeSeconds(TimeLocal());
double CloseValue = Close[0]; //Current Candle Close Value
string CloseValueString = DoubleToString(CloseValue,5); //Current price
Comment(
"Current value :",CloseValueString,"\n",
"Candle time :",m
);
}
Solved by adding the Refreshrates() function which updates data for the offline chart at the end of my function:
void OnTimer()
{
int m=TimeSeconds(TimeLocal());
double CloseValue = Close[0]; //Current Candle Close Value
string CloseValueString = DoubleToString(CloseValue,5); //Current price
Comment(
"Current value :",CloseValueString,"\n",
"Candle time :",m
);
RefreshRates();
}