.

RSI Accurate Entry Exit Indicator - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

RSI Accurate Entry Exit Indicator

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
 ToolTip=StrFormat("Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
Plot(EMA(C, 266), "avr", colorBlack);

grid_day = IIf(Day()!=Ref(Day(),-1),1,0);  
Plot(grid_day,"",colorDarkGrey,styleHistogram|styleDashed|styleNoLabel|styleOwnScale);


_SECTION_BEGIN("RSI BUY SELL");
n=45;
per =9;
x = Cum(1);
s1=IIf(RSIa(L,n)>Min(RSIa(C,n),RSIa(O,n)),Min(RSIa(C,n),RSIa(O,n)),RSIa(L,n));
s11=IIf(RSIa(H,n)<Max(RSIa(C,n),RSIa(O,n)),Max(RSIa(C,n),RSIa(O,n)),RSIa(H,n));
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2  ));
aS = (endS-startS)/dtS;bS = endS;
trendlineS = aS * ( x  -endt ) + bS; 
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2  ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x  -endt1 ) + bR; 
Plot(ValueWhen( (S1==trendlineS ), L),"", colorGreen, styleDashed|styleNoRescale|styleThick);
Plot(ValueWhen((S11==trendlineR ), H),"", colorRed, styleDashed|styleNoRescale|styleThick);
Buy =  (S1==trendlineS );
Sell =  (S11==trendlineR ); 
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorRed, colorCustom12) );
dist = 0.9*ATR(10); 
for( i = 0; i < BarCount; i++ ) 
{ 
if( Buy[i] ) PlotText( "Rsi45 Buy " + L[ i ], i, L[ i ]-dist[i], colorCustom13); 
if( Sell[i] ) PlotText( "Rsi45 Sell " + H[ i ], i, H[ i ]+dist[i], colorCustom12); 
} 


_SECTION_END();
Previous Post Next Post