I'm trying to duplicate the RSI value in Amibroker as comparing them side by side seems to show some differences.
I came up with the following that I _think_ is what I want, but I can't get the rsi value to plot out.....
Any help greatly appreciated!
John
protectedoverridevoid OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double P = 0.0;
double N = 0.0;
double W = 0.0;
double S = 0.0;
double diff = 0.0;
double rsi_val = 0.0;
diff = Close[0] - Close[1];
if (diff > 0) {
W = diff;
}
if (diff < 0) {
S = -diff;
}
P = ((period -1) * P + W)/period;
N = ((period -1) * N + S)/period;
rsi_val = 100*P/(P+N);
Plot0.Set(rsi_val);
}
Comment