Modification of code for Breakout strategy

murthyavr

Well-Known Member
#1
This is one AFL for breakout strategy.

_SECTION_BEGIN("BreakOut");
breakoutime = 101500;
afterbreakout0 = Cross(TimeNum(),101500);
afterbreakout1 = TimeNum()>=101500;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
ORBHigh = ValueWhen(afterbreakout0,highestoftheday,1);
ORBLow = ValueWhen(afterbreakout0,lowestoftheday,1);
Buy= Cross(C,orbhigh) AND afterbreakout1;
Sell = Cross(orblow,C) AND afterbreakout1;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

Short=Cross(C,ORblow) AND afterbreakout1;
Cover=Cross(ORbhigh,C) AND afterbreakout1;

//Plot(C,"",colorYellow,styleCandle);
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", colorYellow, styleNoTitle | styleCandle | GetPriceStyle() );
PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);
Plot(afterbreakout0,"",colorBlue,styleHistogram|styleOwnScale);
Plot(ORBHigh,"",colorGreen,styleDots);
Plot(ORBLow,"",colorRed,styleDots);

//Additional code by Murthy
Filter= Buy OR Sell;
AddColumn( Close, "Close" );
AddColumn(IIf(Buy, 66, 83), "Signal", formatChar, colorYellow, IIf(Buy, colorGreen, colorRed));
AddColumn(orbhigh, "High" );
AddColumn(orblow, "Low" );




In exploration, Amibroker is giving the list of stocks which have crossed
the set Resistance/Support after 10.15 am.

However, I want the stocks which crossed the Res/Sup in the last two candles, or during the formation of current candle
and the time of crossing.


What modifications are to be done to the above code, in order to get
what I wanted?

Thanks
 

Similar threads