I didn't look detailed at your script-code.
But a script is executed only once.
Why don't you create a duplicate of the indicator with an extra buffer for your function.
Then you can modify until the lines are one above the other and you can use the debugger to see where and why it differs.
But be aware sometimes the debugger button is greyed and isn't working (I don't know why, I have told the service - no answer so far).
In this case just save the indicator under a different name and its working again.
- Set your buffer to asSeries before filling it, so OnArray knows that zero is the last entry instead of the first.
- Don't duplicate code, just get the value from the indicator. Detailed explanation of iCustom - MQL4 forum
- Because there are no buffers (auto-sizing auto-initializing, series arrays) and no IndicatorCounted in scripts.
??
That's why I suggested an indicator-dublicate with an add. buffer (and not a script) what I did not mention explicetly is to paste his indi.-function in the dublicate-indicator and fill the add. buffer by his function results.
Not possible?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I got an indicator that is working fine, but I want to reproduce it to a script, and in the scripts I'm getting wrong values. It's a kind of a moving average.
In the indicator, ind_buffer0 will have the moving average values. Indicator code
Script code
For a given symbol, I'm getting 184.9759 value in the indicator, and ~182.14 in the script, which is way off from the close price. Can't find what I'm doing wrong.. Might have something to do with HISTORY, since if I change that value, the value I get also changes.