I need some coding help please. I am wanting to take the original ToS RSI code and adjust the variables to add two plots in the same indicator. However the "slow length" keeps plotting differently than if I stack two RSI indicators together. I also want a line plotted at 50 and when simply adding two standard RSI codes with a plot at 50 the plot does not plot at 50 due to it changing to a percentage based scale which would be the easy solution. Here is the code I have for the two RSI (Fast & Slow) and an image of the difference. The white 2px line in Slowlength 28 length line from my script and the cyan 2px line is the RSI 28 length from the standard ToS script. I've checked this for any errors for two days over and over and can not figure out why this won't plot correctly. Any suggestion would be appreciated, thanks in advance!
Code:
declare lower;
input Slowlength = 28;
input SlowAverageType = AverageType.SIMPLE;
input Fastlength = 5;
input FastAverageType = AverageType.SIMPLE;
input price = close;
def NetChgAvgSlow = MovingAverage(SlowAverageType, price - price[1], Slowlength);
def TotChgAvgSlow = MovingAverage(SlowAverageType, AbsValue(price - price[1]), Slowlength);
def ChgRatioSlow = if TotChgAvgSlow != 0 then NetChgAvgSlow / TotChgAvgSlow else 0;
plot RSISlow = 50 * (ChgRatioSlow + 1);
RSISlow.SetDefaultColor(CreateColor(255, 255, 255));
RSISlow.SetLineWeight (2);
def NetChgAvgFast = MovingAverage(FastAverageType, price - price[1], Fastlength);
def TotChgAvgFast = MovingAverage(FastAverageType, AbsValue(price - price[1]), Fastlength);
def ChgRatioFast = if TotChgAvgFast != 0 then NetChgAvgFast / TotChgAvgFast else 0;
plot RSIFast = 50 * (ChgRatioFast + 1);
RSIFast.SetDefaultColor(CreateColor(125, 125, 125));
plot Line = 50;
Line.SetDefaultColor(CreateColor(255, 0, 0));