I want to move an old indicator to MQL 5 and therefor need iRSIOnArray equivalent. Searched, but couldn't find anything so far.
Would someone be so kind to point me to an implementation?
Lazy ? ;-)
Ok, I took this as sort of hint and it seems there's some git hub code that could be used.
For anyone interested here's the link: https://github.com/Shmuma/mt-tools/blob/master/mt5/IndicatorsOnArray.mqh
Ok, I took this as sort of hint and it seems there's some git hub code that could be used.
For anyone interested here's the link: https://github.com/Shmuma/mt-tools/blob/master/mt5/IndicatorsOnArray.mqh
:-D
I hope you don't have to use this implementation with a long period and a buffer as it will be very inefficient.
EDIT: And in my opinion this is a bug or at least leads to an not standard RSI :
if (neg > 1e-5) rsi = 100.0 - 100.0 / (1 + pos / neg);
:-D
I hope you don't have to use this implementation with a long period and a buffer as it will be very inefficient.
Will do so and post something here when I got my head around this.
Thank you.
---
And this looks like a bug, too, it should be nsum:
pos = psum / period;
neg = psum / period;
Will do so and post something here when I got my head around this.
Thank you.
---
And this looks like a bug, too, it should be nsum:
I want to move an old indicator to MQL 5 and therefor need iRSIOnArray equivalent. Searched, but couldn't find anything so far.
Would someone be so kind to point me to an implementation?
Indicator example:
CodeBase | 2019.01.02 14:31 | Vladimir Karputov | Indicators | MetaTrader 5

- www.mql5.com
Thanks Vladimir, I've put everything together into a neat iRSIOnArray look-alike for MT5. Should work like the original:
double iRSIOnArray_(double &array[],int total,int period,int shift) { if(total==0) total=ArraySize(array); int stop=total-shift; if(period<=1 || shift<0 || stop<=period) return 0; bool isSeries=ArrayGetAsSeries(array); if(isSeries) ArraySetAsSeries(array,false); int i; double SumP=0; double SumN=0; for(i=1; i<=period; i++) { double diff=array[i]-array[i-1]; if(diff>0) SumP+=diff; else SumN+=-diff; } double AvgP=SumP/period; double AvgN=SumN/period; for(; i<stop; i++) { double diff=array[i]-array[i-1]; AvgP=(AvgP*(period-1)+(diff>0?diff:0))/period; AvgN=(AvgN*(period-1)+(diff<0?-diff:0))/period; } double rsi; if(AvgN==0.0) { rsi=(AvgP==0.0 ? 50.0 : 100.0); } else { rsi=100.0-(100.0/(1.0+AvgP/AvgN)); } if(isSeries) ArraySetAsSeries(array,true); return rsi; }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to move an old indicator to MQL 5 and therefor need iRSIOnArray equivalent. Searched, but couldn't find anything so far.
Would someone be so kind to point me to an implementation?