Read Buffer from iCustom - only 3 of 5 work?

 

Hello!

I wrote an Indicator which works just fine. It has 5 Buffers in total, which are all working fine (i checked in the data-window when applied to a chart and they contain values where they should).

Now i created an EA wich reads this indicators buffers. I can read the first 3 Buffers (SetIndexBuffer0 to 2) but if i try to read the values of buffer 4 and 5 (SetIndexBuffer3 and 4) it returns 0 at any time. There are no obvious differences in the definition of the buffers.


i also already tried to change the order of the buffers , but nothing changed (i was able to retrive data from the last buffer, but the other 2 still returned 0)


i checked this by backtesting the EA and let it print the value of the needed buffers on every tick --> always 0


does anyone have an idea where to look for the mistake?


thank you very much,

AxT

 
My guess is that you load a wrong version of your indicator into the EA, check path names. And iCustom is slow. Consider moving the indicator logic to a class that can be #included in the EA.
 

Thanks for your reply.

I made a change in the indicator to change the values and the EA saw the changes. So the "version" of the indicator should be correct

i didn't want to include the indicator into the EA and thought it would be better to let the EA do the money management and the indicator the trade signal. This would result in clearer scripts, wouldn't it? Or is there a more elegant way to include the lodic of the indicator into the EA?

 

I noticed that calls to iCustom slow down the backtest significantly. So this is why I moved my indicator logic into a class that I could call from both the indicator and the EA. The indicator class has an OnTick that receives tick and time values and it has some public members like MainCurrent, SignalCurrent, MainPrevious, IsUpCross etc that can be read out.

Regarding the other issue I think you need to show the indicator and the lines of code from your EA which fetch the values.

 
DrAxT: does anyone have an idea where to look for the mistake?
Do you really expect an answer? There are no mind-readers here. We can't see your indicator, nor your iCustom code.
You should encapsulate your iCustom calls to make your code self-documenting.
          Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum
Reason: