The "New bar" event handler for the indicators:
This indicator will allow you to perform the recalculation of the indicator's data only when the new bar on the chart has appeared.
The idea of this approach is described in the "New Bar" Event Handler
article. The example of its use in the Expert Advisors is presented in
the article. Here you will find the solution for the indicators. Idea is
the same: it will allow to perform recalculations only when the new bar
has appeared. It's a convenient alternative to the direct use of the OnCalculate() function.
Here is the simple indicator, it prints a line when the new bar has appeared.