So, if you have patience and are willing to help, thanks in advance. This will likely bore more experienced coders, so apologies for that.
The formula for RSI is pretty straightforward from a math standpoint.
RSI = 100 - (100/(1 + RS)
where RS = (Avg Up Closes for X periods) / (Avg Down Closes for X periods)
And then there is the script, repeated below.
Code: Select all
inputs:
PriceValue( numericseries ),
Len( numericsimple ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 1 / Len ),
var4( 0 ) ;
if CurrentBar = 1 then
begin
var0 = ( PriceValue - PriceValue[Len] ) / Len ;
var1 = Average( AbsValue( PriceValue - PriceValue[1] ), Len ) ;
end
else
begin
var2 = PriceValue - PriceValue[1] ;
var0 = var0[1] + var3 * ( var2 - var0[1] ) ;
var1 = var1[1] + var3 * ( AbsValue( var2 ) - var1[1] ) ;
end ;
if var1 <> 0 then
var4 = var0 / var1
else
var4 = 0 ;
RSI = 50 * ( var4 + 1 ) ;
I have many more questions, but perhaps we should start with that one, as it may clear up some of the other questions. Again, thanks in advance.