The TASC March 2019 issue includes "Sell Relative Strength Index" by Howard Wang. The EasyLanguage code follows and I'd like to know how to convert it.
TradeStation EasyLanguage (ELS) for SRSI
inputs:
Length( 20 ) ;
vars:
srsi(0) ,
srsin(0) ,
k(0) ;
srsin = 0 ;
For k = 0 to Length - 1
Begin
Value1 = absvalue(close[k] - open[k]) ;
Value2 = absvalue(high[k] - low[k]) ;
If value2 = 0 then value3 = 0
Else
Value3 = value1/value2 ;
srsin = srsin + value3 ;
End ;
srsi = srsin/length ;
plot1(0.38) ;
plot2(srsi) ;
plot3(-0.38) ;
plot4(0) ;
If srsi > 0 then Setplotcolor(2,green) ;
If srsi < 0 then Setplotcolor(2,red) ;
If srsi >= -0.05 and srsi <= 0.05 then
Setplotcolor(2,yellow) ;
Setplotcolor(1,darkred) ;
Setplotcolor(3,darkgreen) ;
Setplotcolor(4,yellow) ;
I have done two versions with and without looping. My straight up conversion follows and does not yield anything near what the article displays.
/* Fromulas\\Custom\\S&C\\Rel Str\\Sell Relative Strength Index Alt_1.afl
TASC Feb 2019 by Howard Wang
Use as: Indicator
TradeStation EsayLanguage */
// Inputs
Len = Param( "Length", 20, 1, 100, 1 );
// Vars
srsi = srsin = k = 0 ;
// for( k = 0; k < BarCount; k++ )
for( k = 0; k < Len - 1; k++ )
{
// BEGIN body of the loop
Value1 = abs( Close[ k ] - Open[ k ] ) ;
Value2 = abs( High[ k ] - Low[ k ] ) ;
if( Value2 == 0 )
Value3 = 0 ;
else
{
Value3 = Value1 / Value2 ;
}
srsin = srsin + Value3 ;
}
// END
srsi = srsin / Len ;
// Color = IIf( srsi > 0, colorGreen, IIf( srsi < 0, colorRed, srsi >= -0.05 AND srsi <= 0.05, colorYellow )) ;
Color = colorBrightGreen ;
Plot( 0.38, "", colorDarkRed , styleLine ); // Plot 1
Plot( srsi, "srsi", Color, styleLine ) ; // Plot 2
Plot( -0.38, "", colorDarkGreen, styleLine ); // Plot 3
Plot( 0.00, "", colorYellow, styleLine ) ; // Plot 4
Thank you for your time and consideration, John