Indicators: isNewBar

 

isNewBar:

The function allows checking whether a new bar has appeared on the specified timeframe.

For the indicators and Expert Advisors it's very often necessary the information whether a new bar has appeared on the specified timeframe. Here is an example, how it can be done.

After the first call of the isNewBar() function, the current bar is not assumed as a new bar. The function saves its time, it's the current bars, the next bar will be new. The code is commented, it's easy to understand, I hope it will be useful.

Author: Prival

 

What are peoples thoughts on the best way to use an IsNewBar() type approach, during back-testing?


making decisions based on tick count is one, but using IsNewBar() based on time or Bars() just doesn't back test well at all...

Reason: