I'm trying to code the below logic from ThinkorSwim in Ninja trader. It calculates the change of RSI from current bar to previous bar,
c1 means current bar, c1[1] means previous bar, n is RSI period length
def c1 = close(period= myTrendperiod);
def NetChgAvg1 = ExpAverage(c1 - c1[1], n);
def TotChgAvg1 = ExpAverage(AbsValue(c1 - c1[1]), n);
def ChgRatio1 = if TotChgAvg1 != 0
then NetChgAvg1 / TotChgAvg1
else 0;
rec RSI1 = 50 * (ChgRatio1 + 1);
However, I do not see the same result in Ninja.
Wondering if the calculations got to be different for getting the same result. The reason is that in TradeStation I had to use the below formula for RSI
netChange in TS = (X-Xn)/n for getting the same result.
Appreciate any feedback
Comment