Although the indicator begins but does not update and informs zero values from the next bar after loading into the drawing.
I give the example attached indicator: normalized ATR.
The trouble is that when using the indicator in EA code gives zero information
Has anyone had this problem or seen in the attached code the error that I do not?
Thanks for the help
Your loop is only executed when prev_calculated is 0 (first call) :
for(int k=inicio; k<limite; k++) { maxATR= MaxMinAbs(ATRbuffer, true, k, intervReferenc); minATR= MaxMinAbs(ATRbuffer, false, k, intervReferenc); ATRbufferNorm[k]= normValor(ATRbuffer[k], maxATR, minATR, nivelMax, nivelMin); }
After that your value for inicio is always greater than that of limite, so the loop isn't executed.
Your loop is only executed when prev_calculated is 0 (first call) :
After that your value for inicio is always greater than that of limite, so the loop isn't executed.
Is it correct the next solution?
(intervReferenc= period to calculate a data from previous bars)
if(preCalculado==0) { inicio= 0; limite= rangoTotal-preCalculado-intervReferenc; if(maxBarras>0) limite= MathMin(limite, maxBarras); } else { inicio= rangoTotal-preCalculado; limite= rangoTotal-preCalculado+1; }
Is it correct the next solution?
(intervReferenc= period to calculate a data from previous bars)
You are using :
ArraySetAsSeries(ATRbuffer, true); ArraySetAsSeries(ATRbufferNorm, true);
So the current candle is 0 and old one is rates_total-1, so :
inicio= 0; if(preCalculado==0) { limite= rangoTotal-intervReferenc; if(maxBarras>0) limite= MathMin(limite, maxBarras); } else { limite= rangoTotal-preCalculado+1; }
Is it correct the next solution?
(intervReferenc= period to calculate a data from previous bars)
Is that better?...
int OnCalculate(const int rangoTotal, const int preCalculado, const int begin, const double& precio[]) { int inicio, limite, valoresCopiar; int barrasPosibles= BarsCalculated(puntATR); if(preCalculado==0) { inicio= 0; limite= MathMin(rangoTotal, barrasPosibles)-intervReferenc; if(maxBarras>0) limite= MathMin(limite, maxBarras); valoresCopiar= limite+intervReferenc; } else { inicio= rangoTotal-preCalculado; limite= rangoTotal-preCalculado+1; valoresCopiar= limite; } if(CopyBuffer(puntATR, 0, 0, valoresCopiar, ATRbuffer)<1) {
Is that better?...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Although the indicator begins but does not update and informs zero values from the next bar after loading into the drawing.
I give the example attached indicator: normalized ATR.
The trouble is that when using the indicator in EA code gives zero information
Has anyone had this problem or seen in the attached code the error that I do not?
Thanks for the help