Relative Strength Index (RSI) [ChartSchool]
That isn't the definition. Look at the MT4 code
diff=close[i]-close[i-1]; ExtPosBuffer[i]=(ExtPosBuffer[i-1]*(InpRSIPeriod-1)+(diff>0.0?diff:0.0))/InpRSIPeriod; ExtNegBuffer[i]=(ExtNegBuffer[i-1]*(InpRSIPeriod-1)+(diff<0.0?-diff:0.0))/InpRSIPeriod; if(ExtNegBuffer[i]!=0.0) ExtRSIBuffer[i]=100.0-100.0/(1+ExtPosBuffer[i]/ExtNegBuffer[i]);
Hi, am programming in C# and wants to use my code to backtest RSI settings that I then wish to program in MQL.
DOES THE CALCULATION LOOK CORRECT BELOW? I'm using SMA-method for the calculation.
In the example below I will have a setting of RSI 5
1) Calculate ChangeUp and ChangeDown for each bar by looking at current bar closeprice vs diff of previous bar closeprice.
2) For current bar RSI I add up all ChangeDown(and same for ChangeUp) for the last 4 bars + current (yes, I won't know RSI until current bar closes) / N bars. This gives me an AverageUp and AverageDown for the current bar.
3) Calculate RS by taking AverageUp/AverageDown.
Then RSI for the CURRENT bar is = (100 - (100 / (1 + RS)));
ANY COMMENTS ON MY CALCULATIONS CORRECTNESS?
Please stop double posting! You already had open thread on this subject at: https://www.mql5.com/en/forum/214849
On that thread, we had already given answers! You should have continued your comments there.

That isn't the definition. It's not a SMA. The ChangeUp is a (exponential) moving average.
Relative Strength Index (RSI) [ChartSchool]
That isn't the definition. Look at the MT4 code
Thanks Whroeder1, the coin dropped now I think. Really appreciate your help.
So I've been using this calculation and choose the SMA-calculation of AverageUp and AverageDown whereas the MT4 indicator uses an EMA-calculation of AverageUp and AverageDown.
Thanks
Please stop double posting! You already had open thread on this subject at: https://www.mql5.com/en/forum/214849
On that thread, we had already given answers! You should have continued your comments there.
Your answers were not answers nor in this or the other thread.
Thanks Whroeder1, the coin dropped now I think. Really appreciate your help.
So I've been using this calculation and choose the SMA-calculation of AverageUp and AverageDown whereas the MT4 indicator uses an EMA-calculation of AverageUp and AverageDown.
Thanks
In that case you are using what is known as Cutler's RSI
See here for more information : https://en.wikipedia.org/wiki/Relative_strength_index
PS: original Welles Wilder RSI uses what is sometimes known as Wilders EMA (like bellow) not ema like in the version you are talking about :
EMA formula = price today * K + EMA yesterday * (1-K) where K = 2 / (N+1) Wilder EMA formula = price today * K + EMA yesterday (1-K) where K =1/N Where N = the number of periods.Even though they look different, Wilders EMA and SMMA are producing same results, so you can use SMMA too
In that case you are using what is known as Cutler's RSI
See here for more information : https://en.wikipedia.org/wiki/Relative_strength_index
PS: original Welles Wilder RSI uses what is sometimes known as Wilders EMA (like bellow) not ema like in the version you are talking about :
Be careful of this OP! I provided similar information to him (see below) on his other thread and I was insulted by him for it, with the following (which he has since removed):
Thank you mr. Nerd ... Wow, you know how to google ... did it ever struck that I also know how to google and asked a specific question which you didn't answer nor provided any clue on how to solve ... Crappy answer my friend, crappy answer indeed.
Forum on trading, automated trading systems and testing trading strategies
Fernando Carreiro, 2017.09.01 13:35
Have a look at WikiPedia's page on RSI (Relative Strength Indicator) which offers you a complete explanation of how it is calculated.
You can also consult the original source, which is the 1978 book by J. Welles Wilder, New Concepts in Technical Trading Systems, that has an example step-by-step breakdown on how it is calculated.
Forum on trading, automated trading systems and testing trading strategies
Johan Strandberg, 2017.09.08 14:28
You do know that RSI AveageUp and AverageDown can be calculated using SMA, EMA and Wilders Smooting right?
Just asking as your answer did not contain anything of value to my question that google had not already provided.....
Be careful of this OP! I provided similar information to him (see below) on his other thread and I was insulted by him for it, with the following (which he has since removed):
OK!
OK!
Forgive me for being rude but I just wasn't interested in a book to read, I was interested in somebody who had knowledge who could tell me if my code looks correctly based on the information I've already read and now posted.
Feel free to move on and help other people instead of me and also stop spamming my thread.
Kind Regards
In that case you are using what is known as Cutler's RSI
See here for more information : https://en.wikipedia.org/wiki/Relative_strength_index
PS: original Welles Wilder RSI uses what is sometimes known as Wilders EMA (like bellow) not ema like in the version you are talking about :
Thanks Mladen,
Interesting that they produce the same result (and that it's called Cutlers when using SMA). Would you know if my SMA-code looks correct? I think it's okey but would be great if I could get it confirmed.
I've followed macrooptions link and then I got unsure when looking at a regular RSI in MT4, in retrospect I now understand with the help of some previous answers that the MT4 RSI is calculated with a EMA which is why my own code based on SMA differs :)
- www.macroption.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, am programming in C# and wants to use my code to backtest RSI settings that I then wish to program in MQL.
DOES THE CALCULATION LOOK CORRECT BELOW? I'm using SMA-method for the calculation.
In the example below I will have a setting of RSI 5
1) Calculate ChangeUp and ChangeDown for each bar by looking at current bar closeprice vs diff of previous bar closeprice.
2) For current bar RSI I add up all ChangeDown(and same for ChangeUp) for the last 4 bars + current (yes, I won't know RSI until current bar closes) / N bars. This gives me an AverageUp and AverageDown for the current bar.
3) Calculate RS by taking AverageUp/AverageDown.
Then RSI for the CURRENT bar is = (100 - (100 / (1 + RS)));
ANY COMMENTS ON MY CALCULATIONS CORRECTNESS?