I coded up the NET version of Ehler's RSI from the latest TASC magazine. screenshot matches the pictures from the article as far as I can tell. Feedback is welcome. That Y variable is entirely unused, but I left it there because it was in all the examples.
// TASC December 2020 Noise Elimination Technology by John F. Ehlers
// afl coding by J Talikka
// based partially on code by Tomasz at http://www.amibroker.com/members/traders/05-2018.html
RSILength = Param( "RSILength", 14, 2, 50 );
NETLength = Param( "NETLength", 14, 2, 50 );
function EhlersRSI( Data, Period )
{
Diff = Data - Ref( Data, -1 );
Up = Max( Diff, 0 );
Dn = Max( -Diff, 0 );
CU = Sum( Up, RSILength );
CD = Sum( Dn, RSILength );
result = IIf( CU + CD != 0, ( CU - CD ) / ( CU + CD ), 0 );
return result;
}
function NET( Data, Period )
{
for( count = 1; count < Period + 1; count++ )
{
VarSet( "X" + count, Ref( Data, 1 - count ) );
VarSet( "Y" + count, -count );
}
Num = 0;
for( count = 2; count < Period + 1; count++ )
{
for( K = 1; K < count; K++ )
{
Num = Num - sign( VarGet( "X" + count ) - VarGet( "X" + K ) );
}
}
Denom = 0.5 * Period * ( Period - 1 );
result = Num / Denom;
return result;
}
Plot( EhlersRSI( C, RSILength ), "EhlersRSI" + _PARAM_VALUES(), colorRed, styleThick );
Plot( 0, "", colorBlack, styleLine );
Plot( NET( EhlersRSI( C, RSILength ), NETLength ), "NET" + _PARAM_VALUES(), colorBlue, styleThick );