# R RSI Calculation (TTR package)

I'm using the default RSI calculation in the TTR package as follows:

result = RSI(data,14).

The function also allows the user to specify the averaging method:

result = RSI(data,14,"SMA"), result = RSI(data,14, "EMA") etc.

However, I cannot work out what averaging method is being used in the default version. I have compared the results from all the different averaging methods (SMA, EMA) and none of them match the default. Any ideas?

The answer is that the default uses the Wilder EMA, which does act slightly different from a standard EMA.

i.e. Default = RSI(data,14,"EMA",wilder = TRUE)

• Can the user set the default to "EMA" and to not use wilder, without adjust the function code ? I get a discrepancy between 2 system that has the same OHLC-data source. the discrepancy is in the RSI result and I suspect it might have to do with that one system uses the TTR (thus wilder setting) and the other system does not use TTR (wilder). Jul 16 '19 at 13:44
• I noticed that I get different results, adding the wilder flag, with or without [maType="EMA". That seems a bug, since not typing [maType="EMA] should give the "EMA" as default. Jul 16 '19 at 14:05

The TTR RSI code uses EMA by default. Code below:

https://github.com/joshuaulrich/TTR/blob/master/R/RSI.R

# Default Welles Wilder EMA
if(missing(maType)) {
maType <- 'EMA'
maArgs\$wilder <- TRUE
}