Problem with iCustom?

 
I'm testing a EA that uses 2 indicators. The values of both are retrieved by iCustom statements. I'm experiencing cases where the values retrieved (printed to the journal by Print commands) do not match the values shown on the chart and the EA is making bad trades as a result. Is there something I can be coding incorrectly that would cause this?

The EA runs on H1 timeframe and the values are only obtained and printed once each hour.

Thank you,
Lou G
 
See "MQL4: Multiple Null Bar Re-Сount in Some Indicators" It may be give an answer for you.
 
See "MQL4: Multiple Null Bar Re-Сount in Some Indicators" It may be give an answer for you.


Thank you. I see that this may solve my problem.
 
As it turns out, the more practical solution for me is to create versions of my indicators that recalculate history completely on each use. Since the indicators are based on the most recent closed bar, the recalc is only needed once per hour and does not slow down testing enough to be prohibitive.

My primary reason for writing the EA is to verify profitability of the approach and fine tune calculations so this solution works best for me. I may not ever actually trade this EA in a live situation but, if I should do so, this recalculation done only once per real-time hour should not affect the EA's functionality.