Code: Select all
Function: SRSI
// TASC JUL 2015
// SRSI
inputs:
iPrice( numericseries ),
Length( numericsimple ),{ this input assumed to be a constant >= 1 }
SMoothingLength( numericsimple ) ;
variables:
NetChgAvg( 0 ),
TotChgAvg( 0 ),
Change( 0 ),
SF( 1 / Length ), { smoothing factor }
ChgRatio( 0 ),
Price( 0 ) ;
Price = XAverage( iPrice, SMoothingLength ) ;
if CurrentBar = 1 then
begin
NetChgAvg = ( Price - Price[Length] ) / Length ;
TotChgAvg = Average( AbsValue( Price - Price[1] ), Length ) ;
end
else
begin
Change = Price - Price[1] ;
NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
TotChgAvg = TotChgAvg[1] + SF * ( AbsValue( Change ) - TotChgAvg[1] ) ;
end ;
if TotChgAvg <> 0 then
ChgRatio = NetChgAvg / TotChgAvg
else
ChgRatio = 0 ;
SRSI = 50 * ( ChgRatio + 1 ) ;
Code: Select all
Indicator: SRSI
// TASC JUL 2015
// SRSI
inputs:
iPrice( numericseries ),
Length( numericsimple ),{ this input assumed to be a constant >= 1 }
SMoothingLength( numericsimple ) ;
variables:
NetChgAvg( 0 ),
TotChgAvg( 0 ),
Change( 0 ),
SF( 1 / Length ), { smoothing factor }
ChgRatio( 0 ),
Price( 0 ) ;
Price = XAverage( iPrice, SMoothingLength ) ;
if CurrentBar = 1 then
begin
NetChgAvg = ( Price - Price[Length] ) / Length ;
TotChgAvg = Average( AbsValue( Price - Price[1] ), Length ) ;
end
else
begin
Change = Price - Price[1] ;
NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
TotChgAvg = TotChgAvg[1] + SF * ( AbsValue( Change ) - TotChgAvg[1] ) ;
end ;
if TotChgAvg <> 0 then
ChgRatio = NetChgAvg / TotChgAvg
else
ChgRatio = 0 ;
SRSI = 50 * ( ChgRatio + 1 ) ;