I am new to AmiBroker platform, and trying to code my preferred tools that I use in TradingView. One of those tools is "Filtered Connors RSI". It's an accurate indicator, particularly for trending market condition. I am trying to code it in AFL in AmiBroker. The following is the AmiBroker AFL code for Filtered CRSI -
_SECTION_BEGIN("Filtered Connors RSI");
ma_length = 4;
c_length = 3;
ud_length = 2;
roc_length = 100;
// Heikin - Ashi Technique
HaClose = (O + H + L + C) / 4;
//HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
//HaHigh = Max( H, Max( HaClose, HaOpen ) );
//HaLow = Min( L, Min(HaClose, HaOpen) );
function crsi(input, len, ud_len, roc_len) {
upDays = BarsSince(HaClose <= Ref(HaClose,-1));
downDays = BarsSince(HaClose >= Ref(HaClose,-1));
updown = IIf(upDays > 0, upDays, IIf(downDays > 0, -downDays, 0));
rsi1 = RSI(input, len);
updownrsi = RSI(updown, ud_len);
percrank = PercentRank( ROC( input,1), roc_len);
return (rsi1 + updownrsi + percrank)/3;
}
rsi_open = crsi( Open, c_length, ud_length, roc_length);
rsi_high = crsi( High, c_length, ud_length, roc_length);
rsi_low = crsi( Low, c_length, ud_length, roc_length);
rsi_close = crsi( Close, c_length, ud_length, roc_length);
function sHaClose()
{
return (O + H + L + C) / 4;
}
source = sHaClose(rsi_open, rsi_high, rsi_low, rsi_close);
fcrsi = TEMA(source, ma_length);
PlotGrid(70, colorGreen, pattern=10, width=2, label=True);
PlotGrid(50, colorBrown, pattern=9, width=2, label=True);
PlotGrid(30, colorRed, pattern=10, width=2, label=True);
Plot(fcrsi, "Filtered Connors RSI", colorBlue, styleLine|styleThick, width=2);
_SECTION_END();
It's giving
ERROR 16: Too many arguments".
Please help to fix this error.
The RSI function only accepts one parameter for length. Use the RSIa function instead RSIa(input, len);