custom indicator plots vs passed parameters.

 

Hi all, noob here:) been playing with ea's and indicators and started on custom indicators. for troubleshooting purposes i have the ea print the parameters it receives from the custom indicator at the start of each bar. now i am trying to find out why the values the custom indicator passes are nothing like the values plotted by the indicator. googling for it brought out the possibility of multiple recalculations of the null bar, but that would just output the same wrong value to the ea and the chart? some general pointers would be greatly appreciated. re the custom indicator, i am just trying to add a couple of outputs to the ibands indicator, in a separate window.

thanks in advance,

Joe

 

It is probably because your custom indicator does reposition while bar 0 is forming therfore the value it passes at the start of the bar is not the same as the value of the custom indicator at the end of the bar.

To test this, at the start of each bar, make your custom indicator pass the value of bar 1 to the EA and then see if the results match the indicator.

 
  1. The value of Close[0] changes each tick. So does the value of the indicator for bar zero.
  2. a multi currency/multi time frame indicator you can't get values for bar zero using the tester, values will be way off.
 

Bar[0] is the bar that is currently being formed. The values of Low[0], Close[0] and High[0] are therefore changing during that bar. Close[0] is Bid at any moment in time.

See picture under Bar ...

https://book.mql4.com/appendix/glossary

 
dabbler:

Bar[0] is the bar that is currently being formed. The values of Low[0], Close[0] and High[0] are therefore changing during that bar. Close[0] is Bid at any moment in time.

See picture under Bar ...

https://book.mql4.com/appendix/glossary

Thanks for the suggestions all, appreciate the help.

The question was not about the dynamic change of indicator values with each tick. The question was about discrepancies between indicator values passed to an ea and indicator values plotted on the chart. For example, the value indicator[2] passed to the ea would print out a value of 3, while the plotted value on the chart would be 4! It took a while to identify the problem: The indicator was sloppy in that it recalculated the values of the last 4 bars every time there was a new bar identified. The result was that the plotted values on the chart were the recalculated ones, while the values passed to the ea were obviously fixed. for sure the IndicatorCounted() function is *not* a straightforward thing to play with...

thanks again,

Joe

Reason: