Volume Breakout Trading Strategy: Amibroker AFL

In this post, we are going to discuss a volume breakout trading strategy which scans for stocks which breaks out of a price range with high volumes. This is a very simple strategy with no fancy indicators, however the profitability is quite impressive. This works on majority of liquid and high beta stocks that we have tested. We have a coded an AFL for this strategy and back-tested it on Banknifty futures traded at NSE. The compounded annual return is around 23% for the last 11 years backtest period.

Read our article on AFL tutorial here.

Volume Breakout Trading Strategy – AFL Overview

Parameter Value
Preferred Time-frame
Daily
Indicators Used EMA
Buy Condition
  • Volume is greater than or equal to 1.5 times of previous candle’s volume.
  • Close is greater than 20 period simple moving average.
  • Volume is greater than 50 period simple moving average of volume.
Short Condition
  • Volume is greater than or equal to 1.5 times of previous candle’s volume.
  • Close is less than 20 period simple moving average.
  • Volume is greater than 50 period simple moving average of volume.
Sell Condition
  • Same as Short
  • Stop Loss Hit
  • Target met
Cover Condition
  • Same as Buy
  • Stop Loss Hit
  • Target met
Stop Loss 3%
Targets 30%
Position Size 120 Quantities
Initial Equity 200000
Brokerage 100 per order
Margin 10%

Volume Breakout Trading Strategy – AFL Code

//------------------------------------------------------
//
//  Formula Name:    Volume Breakout Trading System
//  Author/Uploader: Trading Tuitions
//  E-mail:          support@tradingtuitions.com
//  Website:         www.tradingtuitions.com
//------------------------------------------------------

_SECTION_BEGIN("Volume Breakout Trading System");

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));

//Initial Parameters

SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",100);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize(120,spsShares);
SetOption( "AllowPositionShrinking", False );
BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;

//Buy-Sell Logic

range=High-Low;

VolLookback=Param("VolLookback",50,10,100,10);
MALookback=Param("MALookback",20,10,100,10);

Buy = Volume>=Ref(Volume,-1)*1.5 AND Close>MA(Close,MALookback) AND Volume>MA(Volume,VolLookback) ;
Short =Volume>=Ref(Volume,-1)*1.5 AND Close<MA(Close,MALookback) AND Volume>MA(Volume,VolLookback);
Cover = Buy; 
Sell=Short;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

printf("\nBuy : " + Buy );  
printf("\nSell : " + Sell );  
printf("\nShort : " + Short );  
printf("\nCover : " + Cover );  
printf("\nVolume : " + Volume );  	

StopLoss=Param("SL",3,1,10,1);
Target=Param("Target",30,5,40,5);
ApplyStop(Type=0,Mode=1,Amount=StopLoss);
ApplyStop(Type=1,Mode=1,Amount=Target);


Plot( Close, "Price", colorWhite, styleCandle );
Plot(MA(Close,MALookback),"",colorYellow);


/* Plot Buy and Sell Signal Arrows */
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(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, 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);


_SECTION_END();

AFL Screenshot

Volume Breakout Trading Strategy

Volume Breakout Trading Strategy – Backtest Report

Parameter Value
BankNifty
Initial Capital 200000
Final Capital 1973764.04
Scrip Name NSE Banknifty
Backtest Period 25-Aug-2005 to 17-June-2016
Timeframe Daily
Net Profit % 886.88%
Annual Return % 23.09%
Number of Trades 78
Winning Trade % 37.18%
Average holding Period 19.28 periods
Max consecutive losses 10
Max system % drawdown -34.03%
Max Trade % drawdown -75.56%

Clearly, drawdown is on a higher side. It could be overcome with proper Risk Management strategies. Download the detailed backtest report here.

Equity Curve

Volume Breakout Trading Strategy Equity Curve

Profit Table

This volume breakout trading strategy has been profitable on all the years except 2015 and 2012.

Volume Breakout Trading Strategy Profit Table.PNG

Additional Amibroker settings for backtesting

Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 40 and margin requirement of 10% for NSE Banknifty:

Banknifty Symbol Information

Disclaimer:

All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *