I was implementing an RSI indicator when I found that there are two different versions frequently attributed to J. Welles Wilder. The version described on Stochcharts.com seems to be the original Wilder version. By comparing the output from my implementation of this indicator I found that this is the version used by MetaStock. However, QuoteTracker seems to use a different version as its chart did not match my implantation or that in MetaStock. Searching around a bit more I found another definition of RSI on Wikipedia which is calculated using EMAs. I implemented this version and found it appeared to match QT for the first n periods but after that the results started to differ. Iâve compared my EMA class against QuoteTracker and found that it uses the same method to set the initial value, so the EMA is not the cause of the discrepancy and I canât see any other issues. Iâm therefore wondering if QT has not only implemented a variation of RSI that isnât the true Wilder version but has also implemented it wrongly. Iâd be very grateful if someone could confirm whether itâs me or QT thatâs getting it wrong. Hereâs my output for a 5 period RSI using the EMA version defined on Wikipedia: Hereâs a 5 period RSI in QuoteTracker for the same data: As you can see QT seems to match my output for the first 5 periods but the results differ after that. It dips to nearly 50 at 09:35 while my results say 72.6. Itâs also dead on 70 at 09:36 and 09:37 while my results say 78.1. So is QuoteTracker getting its RSI calculation wrong or is it me? Is it maybe using a third method that I havenât seen? Thanks for any advice you can offer on this issue.
I feel like a right Mr Confused now. I simply couldn't see anything wrong with my code but I'd completely overlooked something blindingly obvious. :eek: I'm a fool and should put chained up in the village square so people can throw rotten fruit at me for my stupidity. Sorry for any confusion.
It was something stupid. Iâd initialised the EMA value to -1.0 which is why the value was coming out lower than in QuoteTracker for the first few periods. I have no idea at all why Iâd set it to -1.0 and have even less idea why it took me so long to notice. The RSI calculation is such a simple piece of code that Iâd convinced myself it couldnât be wrong so wasnât really looking hard enough and I didnât look at the initiliser list. Like I say, Iâm a fool The figures above (which are wrong) are for the version of RSI described on Wikipedia (using EMAs), which is the version used in QuoteTracker. I also implemented the original version of RSI, which is used in MetaStock and StockCharts.com but for my purposes Iâve found the QuoteTracker version is the better of the two (or the better of the three if you also count the Cutler version). Having made a fool of myself already Iâm in no position to criticise, but I do feel it would be useful if QuoteTracker changed the name of RSI to something like RSI Using EMA to show itâs not the original version, since the behaviour is quite different from Wilderâs original RSI (it moves much faster than the Wilder version and doesnât trend back to the centre when the price goes flat).