AFL for horizontal breakout (Intraday Trading)
I had explained this setup earlier. This is the AFL for it. Breakout from intraday range. Signals are given for breakout after 1pm and between 2pm (most effective breakout's between this time frame). This afl plots the Hi-lo Range as well as fibonacci levels for the (hi - lo) range. You will have to change the initial timing setting as market open at 9 now. Special thanks to Vinodkiyer for contributing in this afl. This is just a starting point of intra-day trade pattern. You can add your own tools to it to filter bad trades.
//AFL FOR HORIZONTAL RANGE PATTERN (INTRADAY SETUP)
isRth = TimeNum() >= 094500 & TimeNum() <= 095459;
isdRth = TimeNum() >= 095500 & TimeNum() <= 130000;
aRthL = IIf(isRth, L, 1000000);
aRthH = IIf(isdRth, H, Null);
aRthLd = IIf(isdRth, L, 1000000);
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
Bars = BarsSince(TimeNum() >= 094500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
Range = DayH - DayL; //For Fibonacci Retracements
isdc = TimeNum()>=152800 & TimeNum() <=153000;
adc = IIf(isdc, C, Null);
DayC = TimeFrameCompress( adc, inDaily, compressHigh );
DayC = TimeFrameExpand( DayC, inDaily, expandFirst );
/****************************************************************************************************************************************************************/
// Buy_Short_Sell_Cover Criteria
Buy = C > DayH & TimeNum() >=130000 & TimeNum() <= 140000 ;
Sell = TimeNum() >=152500;;
Short = C < DayL AND TimeNum() >=130000 & TimeNum() <= 140000 ;
Cover = TimeNum() >=152500;
/***************************************************************************************************************************************************************/
// Plotting
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Plot(DayHline,"RH",colorOrange,styleLine);
Plot(DayLline,"RL",colorOrange,styleLine);
Plot(Range*1.272 + DayL,"UT 1", colorBlue, styleDashed);
Plot(Range*1.618 + DayL,"UT 2", colorBlue, styleDashed);
Plot(Range*0.618 + DayL,"R1",colorDarkRed,styleDashed);
Plot(Range*0.500 + DayL,"R2",colorDarkRed,styleDashed);
Plot(Range*0.381 + DayL,"R3",colorDarkRed,styleDashed);
Plot(DayH - Range*1.272,"DT 1",colorRed,styleDashed);
Plot(DayH - Range*1.618,"DT 2",colorRed,styleDashed);
BuyArrow = Buy * shapeUpArrow;
SellArrow = Short * shapeDownArrow;
PlotShapes(BuyArrow ,colorGreen, 0,L,Offset=-15);
PlotShapes(SellArrow, colorRed, 0, H,Offset=-15);
_SECTION_END();
Buy =ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short = ExRem (Short,Cover);
/**************************************************************************************************************************************************************/
//Exploration
Filter = Buy OR Short;
AddColumn( Close, "Close", 1.2 );
AddColumn( Buy, "Buy Price", 1.2 );
AddColumn( Short, "Short Price", 1.2 );
AddColumn( DayH, "Day's High", 1.2 );
AddColumn( DayL, "Day's Low", 1.2 );
AddColumn( Volume, "Volume", 1.1 );
AddColumn(MA(Volume, 35), "Average Volume", 1.1);
AddColumn( DayC, "Day Close", 1.2 );
AddColumn(DayH - DayL, "Range", 1.2);
AddColumn(C*0.005,"Volatility",1.2);
/**************************************************************************************************************************************************************/
//Alerts
AlertIf( Buy, "SOUND C:\\Windows\\Media\\tada.wav", "Buy",2);
AlertIf( Short, "SOUND C:\\Windows\\Media\\notify.wav", "Short", 2 );
/**************************************************************************************************************************************************************/