Before getting into the strategy just wanna tell you that amibroker supports two in built functions gapup() and gapdown() to identify gap up and gap down openings.
GapUp() – this inbuilt function Returns ‘1’ or ‘true’ on the day a security opens gap up. Rest of the days it returns Zero.
GapDown() – this inbuilt function Returns ‘1’ or ‘true’ on the day a security opens gap down. Rest of the days it returns Zero.
Based on this two functions one can easily create a Simple Gapup and Gapdown Strategies.
Strategy Rules
Strategy is very simple. when the market open with gap up and at the same time ,it crossed the previous day high then it should be considered as strong buy. When the market open with gap down and while opening if it crosses yesterday low then it should be considered as strong short.
1)Target % parameter Control is given to the user. so user can set the target as required. Default value is 1%
2)Stop loss logic in the AFL code is not added however you can set the stop loss nearly 0.3% in the bactesting settings as shown below. 0.3% if Static stoploss is the minimum risk
3)Tested the strategy with different stocks and its success ratio in between 50 to 60 %
4)On an average you will get the signal 2-4 times in month .
5)Exploration is also added to scan the stocks which meet above requirement
Preferred Timeframe : 5min charts.
One can experiment with high beta stock.The beauty of the system is stop loss is only 0.3 % which is very less .
Download Amibroker AFL Code
_SECTION_BEGIN("Gap buy Sell");
target = Param("Target %",1,0.1,10,0.1);
NewDay = Day()!= Ref(Day(), -1);
EndDay = (Day()!= Ref(Day(), 1));
on_off_Gap = ParamToggle("Gap ","Off|On",1);
DayH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); // low
DayC = TimeFrameGetPrice("C", inDaily, -1); // close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
GpDown=IIf(GapDown(),True,False);
GpUp=IIf(GapUp(),True,False);
PlotShapes(IIf(GpDown AND NewDay , shapeStar, shapeNone),colorRed, 0,H, Offset=-45);
PlotShapes(IIf(GpUp AND NewDay, shapeStar, shapeNone),colorGreen, 0,H, Offset=-45);
Sell1=Cover1=False;
DayOpenClose=ValueWhen(NewDay,C,1);
DayOpenHigh=ValueWhen(NewDay,H,1);
DayOpenLow=ValueWhen(NewDay,L,1);
Buy1=IIf(Cross(H,DayH) AND GpUp AND NewDay,True,False);
Short1=IIf(Cross(L,DayL) AND GpDown AND NewDay,True,False);
Buy1=ExRem(Buy1,Short1 OR EndDay);
Short1=ExRem(Short1,Buy1 OR EndDay);
Buyflag2=Shortflag2=False;
TempGapBuy=Buy1;
TempGapShort=Short1;
TempGapBuy=ExRem(TempGapBuy,EndDay);
TempGapShort=ExRem(TempGapShort,EndDay);
SetPositionSize(100,spsShares);
Buy=TempGapBuy;
Short=TempGapShort;
BuyPrice=ValueWhen(Buy,C);
ShortPrice=ValueWhen(Short,C);
Buyflag=Flip(Buy,endday);
Shortflag=Flip(Short,endday);
Sell=IIf(Buyflag AND H>BuyPrice* (1+target/100) OR EndDay,True,False);
Cover=IIf(Shortflag AND L<ShortPrice*(1-target/100) OR EndDay,True,False);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
_SECTION_BEGIN("Price1");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Filter=Buy OR Short ;
AddColumn(Buy ,"Short",1,colorBlack,IIf(GpUp,colorGreen, colorRed)) ;
AddColumn(Short,"Cover",1,colorBlack,IIf(GpUp,colorGreen, colorRed)) ;
AddColumn(IIf(Buy,BuyPrice,ShortPrice),"SignalPrice",1,colorBlack,IIf(GpUp,colorGreen, colorRed)) ;
AddColumn(IIf(Buy,BuyPrice* (1+target/100),ShortPrice* (1-target/100)),"TargetPrice",1,colorBlack,IIf(GpUp,colorGreen, colorRed)) ;
AddColumn(TimeNum(),"Signal Time",1,colorBlack,IIf(GpUp,colorGreen, colorRed)) ;
AddColumn(IIf((Buyflag AND H>BuyPrice* (1+target/100)) OR (shortflag AND L<(ShortPrice* (1-target/100))),True,False),"Target Achived",1,colorBlack,IIf(GpUp,colorGreen, colorRed));
sir
i am bapu jadhav i like it to amibrokar softwaer i parchase use your softwaer how can i you parchase softwaeer
Hi,
As of now we are not providing Amibroker License. We resell only datafeed. For Amibroker License you can directly refer amibroker.com website.
For Datafeed Pricing refer
http://www.marketcalls.in/services/globaldatafeeds
Hi Dinesh,
Can we have an EOD Gap Up & Gap Down analysis, since in our office we do not get access to stock market sites and also we cannot install Amibroker software in our official computers.
Can you please do the needful.
Thanks in Advance
Rajesh R
Rajesh
My Gap Strategy study is useful for intraday not for EOD basis.
hello raj.
i want amibroker license , what will be the cost,
thanks
You can refer amibroker.com website for Amibroker License as of now the Indian Resellers stopped providing amibroker license.
Where do we enter and exit, and is it intraday?
Have u tried this on higher timeframe?
Thank you
As I clearly mentioned,at day open when the Gap up /Down happens and at the same time the price should crosses yesterdays high /low. at that time we need to take position .
As per my analysis higher time frame is not suitable for the strategy
so basically,
let market open with gap up
watch out for price to cross yesterday’s high
enter in long trade
and
book profit at user defined target in intraday itself?
In less time high returns, sounds cool.
Hi,
your afl is scanning stocks which opened gap up above previous days range and its giving buy signals.I think following two are better strategies compared to what you have done:-
1. security open gap up above previous day range, initiate sell when it goes below previous days high.
2. Security opens gap up with in previous days range, initiate buy when it crossed above previous days high.
vice versa for gap down.
I also need a help.I need scanner for rsi double top(Mr Rajan vyas might have requested). If you can design it , then it will be very helpful.
Thanks
HI,
Mr.Dinesh
I want your amibroker Gap up Gap down study strategy for intraday.
Please contact me
Regards/Shubhangi sawant
9821779554
i want your gap study intraday strategy
Plz Sir Help Me
I want minimum 1% or more gap up and gap down and Open=Low and open=High amibroker AFL plz sir help me….
Hello Mr. Rajendran, I need the opposite of this afl. I need when price open gap down and also below the previous day low and make first 15 mints candle high,When price cross first 15 mints high then buy sl. day low.vice versa for sell.can you make change this afl for me.thank you
hi, I am not able to backtest, not showing any trades
Try now!