Indicators: The "New bar" event handler for the indicators

 

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.

Author: Константин

 

Thank for your custom indicator but when i use this, i just alert once and stop debuging! Please help me! 

If i use OnTick instead (and remove OnInit and OnCaculate functions) like this article https://www.mql5.com/en/articles/159 it run good but the indicator not display in navigator windows. And it not run when i add OnInit and OnCaculate functions. If i add  OnInit and OnCaculate functions, the indicator is display in navigator windows?

Thank

Reason: