Topic: FirstBar in indicators

In some indicators iFirstBar=4 (in mqh file) and iFirstBar = 3 (in css file).
Is this correct?

Re: FirstBar in indicators

No, they have to be equal. Post the indi names, which have that discrepancy.

3 (edited by Finmod123 2020-04-01 10:36:32)

Re: FirstBar in indicators


why in indicator "Pin Bar M" you use:  int iFirstBar = 3;
but "for" cycle begins with 1?

  for (int iBar = 1; iBar < Bars; iBar++)

I can't find now indicators with different iFirstBar in mqh and css (maybe all was fixed earlier).

Post's attachments

Pin Bar M.cs 6.48 kb, 2 downloads since 2020-04-01 

You don't have the permssions to download the attachments of this post.

Re: FirstBar in indicators

I think 3 is the absolute minimum, better to have at least 3.

And calculation defines whether it is suitable to start main calc from the firstbar value or before. The idea is to have reasonable indi stats on the chart.

Re: FirstBar in indicators

The iFirstBar (or firstBar) initial value depends on the indicator. For some indicators it is a fixed value, however, for others, it may depend on the period, shift or another indicator parameter.

It is safe to use iFirstBar = 3 as a minimum because it guarantees that there will be enough bars to calculate the indicator's logical condition.

For example, in MA the iFristBar = period + shift + usePreviousBar + 2.