iCustom in mql5 gives wrong values

 

Hi,

I cannot find the answer in earlier questions about this.

I've attached the source of the custom indicator and the EA.

I did test this on the m5 timeframe (but that doesn't matter)

When you compare the figures in the journal it's obvious that they don't match with the indicator.

And please don't say this is a rookie question, but give a clear answer WHY.

To verify I also programmed this in MT4 and there is NO PROBLEM at all.

Thanks for helping.

Bert

Files:
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

The indicator should always copy the incoming ticks into copybuffer, and it is done by copying rates_total - prev_calculation + 1.

if I understand correctly:

prev_calculated - 1 is the last calculated bar in the previous call
prev_calculated is the index where new calculations begin

rates_total - prev_calculated is how many bars have appeared since the last calculation

rates_total - prev_calculated + 1 is to copy bars that have appeared since the last calculation including the data on the current (forming) bar