39

AFL of the week: Donchian Channel Trend following System

Donchian Channel is a very powerful indicator to develop Trend following systems. It works extremely well in Trending markets both in Intraday and Daily timeframe. Donchian Channel is derived by calculating Highest High and Lowest Low for a pre-defined period. Any breakout of Donchian channel upper or lower band is considered as the starting of new trend. The Donchian channel is also useful for studying the volatility of price. If the price is stable Donchian channel will be relatively narrow. If the price fluctuates oftenly the Donchian channel will be wider.

Donchian channel was originally devised by Richard Dennis, and is the main idea behind the famous Turtle Trading System. The strategy that we are going to discuss here is based on the breakout of 5 Days Donchian Channel. The upper band of channel is formed by considering the Highest High value of last 5 days, while Lower band is formed by considering the Lowest Low of last 5 days. An additional middle band is formed by taking mean of upper and lower band. This middle band would be utilized to exit Long or Short positions. Additionally, Trailing stop loss has been introduced into the system for risk management. This stop loss is based on 25 Periods of Average True Range (ATR).

Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.

 Strategy Overview

Paramter Value
Preferred Timeframe Daily
Indicators Used 5 Period Donchian Channel
Buy Condition Current Candle High is greater than Donchian Channel upper band.
Short Condition Current Candle Low is less than Donchian Channel lower band.
Sell Condition Current Candle Low is lower than Donchian Channel middle band.
Cover Condition Current Candle High is greater than Donchian Channel middle band.
Stop Loss Trailing Stop Loss based on 25 period ATR
Targets No fixed target.
Position Size 150 (fixed)
Initial Equity 200000
Brokerage 100 per order
Margin 10%

Donchian Channel AFL Code

//------------------------------------------------------
//
//  Formula Name:    Donchian Channel trading System
//  Author/Uploader: Trading Tuitions
//  E-mail:          support@tradingtuitions.com
//  Website:         www.tradingtuitions.com
//------------------------------------------------------

_SECTION_BEGIN("Donchian Channel 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, SelectedValue( ROC( C, 1 ) ) ));

//Initial Parameters
SetTradeDelays( 0,0,0, 0 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",100);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize(150,spsShares);
SetOption( "AllowPositionShrinking", True );

Plot( Close, "Price", colorWhite, styleCandle );

pds=Param("DonchianPeriods",5,5,100,5);
DonchianUpper =HHV(Ref(H,-1),pds);
DonchianLower = LLV(Ref(L,-1),pds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;
 
printf("\nDonchianUpper : " + DonchianUpper );  
printf("\nDonchianLower : " + DonchianLower );  
printf("\nDonchianMiddle : " + DonchianMiddle );  

Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorGreen,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine);

ATRMultiplier=Param("ATRMultiplier",5,1,5,1);
ATRPeriods=Param("ATRPeriods",25,5,25,1);

Buy=Cross(High,DonchianUpper);
Short=Cross(DonchianLower,Low);
Sell=Cross(DonchianMiddle,Low);
Cover=Cross(High,DonchianMiddle);

BuyPrice=DonchianUpper;
SellPrice=DonchianMiddle;
ShortPrice=DonchianLower;
CoverPrice=DonchianMiddle;

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

ApplyStop(stopTypeTrailing, stopModePoint, ATRMultiplier*ATR(ATRPeriods), True, True );

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

/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-25);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-35);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-30);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=25);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=35);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-30);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGold, 0, L, Offset=-15);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorGold, 0,L, Offset=-15);


_SECTION_END();

AFL Screenshot

Donchian Channel

Backtest Report

 Paramter Value
  Nifty Bank Nifty
Initial Capital  200000  200000
Final Capital 2079916.00 5926967.00
Backtest Period 01-Jan-2004 to 20-Jun-2016 01-Jan-2004 to 20-Jun-2016
Net Profit % 939.96%  2863.48%
Annual Return % 20.66% 31.23%
Number of Trades 470 456
Winning Trade % 46.17% 48.03%
Average holding Period 5.40 periods 5.48 periods
Max consecutive losses 7 7
Max system % drawdown -17.15% -40.04%
Max Trade % drawdown -18.70% -14.52%

Download the detailed backtest report here.

Equity Curve

Nifty:

Donchian_EquityCurve_Nifty

Bank Nifty:

Donchian_EquityCurve_BankNifty

Also, check out the below profit table for BankNifty. This strategy has been performing consistently each year:

ProfitTable_BankNifty

Additional Amibroker settings for backtesting

Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 30 and margin requirement of 10% for Bank Nifty:

Symbol Info

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

Related Posts

39 Comments

  1. I have backtested the strategy with the banknifty and nifty , it gives excellent results with both with god sharpe ratio and ulcer index with an hourly chart . Thanks a lot for providing the excellent algo.

  2. Symbol Trade Date Price Ex. date Ex. Price % chg Profit % Profit Contracts Position value Cum. Profit # bars Profit/bar MAE MFE Scale In/Out
    ^NSEI Short 12/01/2010 5227.8 14/01/2010 5236.05 0.16% -1437.50 -0.92% 150 156833.99 -1437.50 3 -479.17 -1.39% 1.11% 0/0
    ^NSEI Short 21/01/2010 5201.4 02/02/2010 4900.85 -5.78% 44882.50 28.76% 150 156041.99 43445.00 8 5610.31 -0.36% 8.37% 0/0
    ^NSEI Short 05/02/2010 4766 10/02/2010 4812.27 0.97% -7141.25 -4.99% 150 142979.99 36303.75 4 -1785.31 -1.28% 1.90% 0/0
    ^NSEI Long 15/02/2010 4843.8 19/02/2010 4843.48 -0.01% -248.75 -0.17% 150 145313.99 36055.00 5 -49.75 -1.24% 1.77% 0/0
    ^NSEI Long 26/02/2010 4912.05 15/03/2010 5125.08 4.34% 31753.75 21.55% 150 147361.49 67808.75 11 2886.70 -1.09% 5.01% 0/0
    ^NSEI Long 16/03/2010 5158.1 23/03/2010 5197.83 0.77% 5758.75 3.72% 150 154743.00 73567.50 6 959.79 -0.63% 2.17% 0/0
    ^NSEI Long 26/03/2010 5269.95 30/03/2010 5258.3 -0.22% -1947.50 -1.23% 150 158098.50 71620.00 3 -649.17 -0.53% 1.13% 0/0
    ^NSEI Long 05/04/2010 5329.55 08/04/2010 5317.4 -0.23% -2022.50 -1.26% 150 159886.49 69597.50 4 -505.63 -0.72% 1.32% 0/0
    ^NSEI Short 15/04/2010 5290.25 22/04/2010 5267.02 -0.44% 3283.75 2.07% 150 158707.49 72881.25 6 547.29 -1.57% 2.45% 0/0
    ^NSEI Long 26/04/2010 5331.8 28/04/2010 5281.73 -0.94% -7711.25 -4.82% 150 159954.00 65170.00 3 -2570.42 -0.94% 0.20% 0/0
    ^NSEI Short 28/04/2010 5221.1 30/04/2010 5272.4 0.98% -7895.00 -5.04% 150 156633.00 57275.00 3 -2631.67 -1.67% 0.36% 0/0
    ^NSEI Short 04/05/2010 5202.45 10/05/2010 5131.65 -1.36% 10420.00 6.68% 150 156073.50 67695.00 5 2084.00 -0.92% 4.19% 0/0
    ^NSEI Long 13/05/2010 5206.7 14/05/2010 5098.65 -2.08% -16407.50 -10.50% 150 156200.99 51287.50 2 -8203.75 -2.08% 0.12% 0/0
    ^NSEI Short 17/05/2010 5026.6 18/05/2010 5089.48 1.25% -9631.25 -6.39% 150 150798.00 41656.25 2 -4815.63 -1.35% 1.20% 0/0
    ^NSEI Short 19/05/2010 4966.25 24/05/2010 4973.75 0.15% -1325.00 -0.89% 150 148987.50 40331.25 4 -331.25 -1.99% 2.50% 0/0
    ^NSEI Short 25/05/2010 4842.3 27/05/2010 4908 1.36% -10055.00 -6.92% 150 145268.99 30276.25 3 -3351.67 -2.15% 1.15% 0/0
    ^NSEI Long 28/05/2010 5029.55 07/06/2010 5054.47 0.50% 3538.75 2.35% 150 150886.49 33815.00 7 505.54 -1.36% 2.35% 0/0
    ^NSEI Long 14/06/2010 5139.05 24/06/2010 5286.65 2.87% 21940.00 14.23% 150 154171.49 55755.00 9 2437.78 -0.37% 4.43% 0/0
    ^NSEI Short 29/06/2010 5259.9 06/07/2010 5272.08 0.23% -2026.25 -1.28% 150 157797.00 53728.75 6 -337.71 -1.41% 0.95% 0/0
    ^NSEI Long 08/07/2010 5312.55 16/07/2010 5375.33 1.18% 9216.25 5.78% 150 159376.48 62945.00 7 1316.61 -1.33% 2.65% 0/0
    ^NSEI Short 20/07/2010 5357.85 02/08/2010 5407.73 0.93% -7681.25 -4.78% 150 160735.49 55263.75 10 -768.13 -2.23% 0.16% 0/0
    ^NSEI Long 03/08/2010 5450.95 10/08/2010 5459.35 0.15% 1060.00 0.65% 150 163528.51 56323.75 6 176.67 -0.45% 0.76% 0/0
    ^NSEI Short 11/08/2010 5428.4 13/08/2010 5432.38 0.07% -796.25 -0.49% 150 162851.99 55527.50 3 -265.42 -0.85% 1.03% 0/0
    ^NSEI Long 18/08/2010 5476.5 25/08/2010 5483.02 0.12% 778.75 0.47% 150 164294.99 56306.25 6 129.79 -1.10% 1.34% 0/0
    ^NSEI Short 27/08/2010 5452.55 01/09/2010 5427.52 -0.46% 3553.75 2.17% 150 163576.48 59860.00 4 888.44 -0.78% 1.90% 0/0
    ^NSEI Long 02/09/2010 5495.2 28/09/2010 6002.95 9.24% 75962.50 46.08% 150 164856.01 135822.50 18 4220.14 -0.42% 10.52% 0/0
    ^NSEI Long 01/10/2010 6073.5 08/10/2010 6126.85 0.88% 7802.50 4.28% 150 182204.99 143625.00 6 1300.42 -0.71% 2.47% 0/0
    ^NSEI Short 12/10/2010 6067 13/10/2010 6140.67 1.21% -11251.25 -6.18% 150 182010.00 132373.75 2 -5625.63 -1.28% 0.15% 0/0
    ^NSEI Long 13/10/2010 6223.4 15/10/2010 6171.03 -0.84% -8056.25 -4.32% 150 186701.99 124317.50 3 -2685.42 -2.15% 0.98% 0/0
    ^NSEI Short 15/10/2010 6057.95 22/10/2010 6083.67 0.42% -4058.75 -2.23% 150 181738.49 120258.75 6 -676.46 -2.35% 1.51% 0/0
    ^NSEI Long 25/10/2010 6127.05 27/10/2010 6059.02 -1.11% -10403.75 -5.66% 150 183811.49 109855.00 3 -3467.92 -1.11% 0.40% 0/0
    ^NSEI Short 28/10/2010 5984.9 01/11/2010 6084.75 1.67% -15177.50 -8.45% 150 179547.00 94677.50 3 -5059.17 -1.79% 0.80% 0/0
    ^NSEI Long 02/11/2010 6132.4 11/11/2010 6268.92 2.23% 20278.75 11.02% 150 183972.00 114956.25 8 2534.84 -0.62% 3.36% 0/0
    ^NSEI Short 11/11/2010 6199.35 22/11/2010 6004 -3.15% 29102.50 15.65% 150 185980.50 144058.75 8 3637.81 -1.57% 5.41% 0/0
    ^NSEI Short 23/11/2010 5863.95 24/11/2010 5950.58 1.48% -13193.75 -7.50% 150 175918.51 130865.00 2 -6596.88 -1.87% 0.67% 0/0
    ^NSEI Short 25/11/2010 5824.95 30/11/2010 5833.5 0.15% -1482.50 -0.85% 150 174748.50 129382.50 4 -370.63 -1.41% 2.31% 0/0
    ^NSEI Long 02/12/2010 5980.6 08/12/2010 5960 -0.34% -3290.00 -1.83% 150 179418.00 126092.50 5 -658.00 -0.68% 1.49% 0/0
    ^NSEI Short 09/12/2010 5878.6 13/12/2010 5895.3 0.28% -2705.00 -1.53% 150 176358.00 123387.50 3 -901.67 -0.83% 2.68% 0/0
    ^NSEI Long 16/12/2010 5953.95 24/12/2010 5962.02 0.14% 1011.25 0.57% 150 178618.51 124398.75 7 144.46 -1.66% 1.17% 0/0
    ^NSEI Long 27/12/2010 6023.8 28/12/2010 5993 -0.51% -4820.00 -2.67% 150 180713.98 119578.75 2 -2410.00 -0.54% 0.36% 0/0
    ^NSEI Long 29/12/2010 6045.75 05/01/2011 6091.95 0.76% 6730.00 3.71% 150 181372.50 126308.75 6 1121.67 -0.71% 2.24% 0/0
    ^NSEI Short 06/01/2011 6062.35 24/01/2011 5697.75 -6.01% 54490.00 29.96% 150 181870.50 180798.75 13 4191.54 -0.89% 7.23% 0/0
    ^NSEI Long 24/01/2011 5747.65 25/01/2011 5695.25 -0.91% -8060.00 -4.67% 150 172429.49 172738.75 2 -4030.00 -0.91% 0.27% 0/0
    ^NSEI Short 27/01/2011 5634.5 04/02/2011 5508.2 -2.24% 18745.00 11.09% 150 169035.00 191483.75 7 2677.86 -1.63% 4.13% 0/0
    ^NSEI Short 08/02/2011 5369.05 14/02/2011 5340.25 -0.54% 4120.00 2.56% 150 161071.49 195603.75 5 824.00 -1.18% 3.56% 0/0
    ^NSEI Long 14/02/2011 5440.35 21/02/2011 5469.75 0.54% 4210.00 2.58% 150 163210.49 199813.75 6 701.67 -1.84% 2.92% 0/0
    ^NSEI Short 24/02/2011 5413.1 28/02/2011 5379.5 -0.62% 4840.00 2.98% 150 162393.00 204653.75 3 1613.33 -0.19% 3.33% 0/0
    ^NSEI Long 01/03/2011 5519.45 07/03/2011 5458.4 -1.11% -9357.50 -5.65% 150 165583.50 195296.25 5 -1871.50 -2.64% 1.61% 0/0
    ^NSEI Short 15/03/2011 5411.55 23/03/2011 5441.65 0.56% -4715.00 -2.90% 150 162346.49 190581.25 7 -673.57 -2.28% 1.17% 0/0
    ^NSEI Long 24/03/2011 5510.05 08/04/2011 5877.42 6.67% 54906.25 33.22% 150 165301.48 245487.50 12 4575.52 -0.25% 7.88% 0/0
    ^NSEI Short 11/04/2011 5822 13/04/2011 5861.17 0.67% -6076.25 -3.48% 150 174660.00 239411.25 3 -2025.42 -0.67% 1.27% 0/0
    ^NSEI Short 18/04/2011 5735.55 20/04/2011 5808.42 1.27% -11131.25 -6.47% 150 172066.50 228280.00 3 -3710.42 -2.83% 0.74% 0/0
    ^NSEI Long 21/04/2011 5911.5 26/04/2011 5803.08 -1.83% -16463.75 -9.28% 150 177344.99 211816.25 3 -5487.92 -1.83% 0.02% 0/0
    ^NSEI Short 29/04/2011 5776.95 10/05/2011 5577.22 -3.46% 29758.75 17.17% 150 173308.50 241575.00 8 3719.84 -0.47% 5.77% 0/0
    ^NSEI Long 13/05/2011 5592.9 06/06/2011 5509.28 -1.50% -12743.75 -7.60% 150 167786.99 228831.25 16 -796.48 -4.72% 0.22% 0/0
    ^NSEI Short 10/06/2011 5479.85 14/06/2011 5503.53 0.43% -3751.25 -2.28% 150 164395.50 225080.00 3 -1250.42 -0.76% 0.78% 0/0
    ^NSEI Short 16/06/2011 5436.95 23/06/2011 5321.7 -2.12% 17087.50 10.48% 150 163108.50 242167.50 6 2847.92 -0.19% 4.43% 0/0
    ^NSEI Long 24/06/2011 5421.15 06/07/2011 5636.15 3.97% 32050.00 19.71% 150 162634.50 274217.50 9 3561.11 -1.43% 5.25% 0/0
    ^NSEI Long 07/07/2011 5705.8 26/07/2011 5616.63 -1.56% -13576.25 -7.93% 150 171173.99 260641.25 14 -969.73 -3.66% 0.61% 0/0
    ^NSEI Short 27/07/2011 5532.7 10/08/2011 5190.48 -6.19% 51133.75 30.81% 150 165981.01 311775.00 11 4648.52 -1.07% 10.60% 0/0
    ^NSEI Short 18/08/2011 5015.4 23/08/2011 4964.15 -1.02% 7487.50 4.98% 150 150461.99 319262.50 4 1871.88 -1.26% 4.37% 0/0
    ^NSEI Short 26/08/2011 4796.1 29/08/2011 4842.9 0.98% -7220.00 -5.02% 150 143883.00 312042.50 2 -3610.00 -1.58% 1.59% 0/0
    ^NSEI Long 30/08/2011 4965.8 06/09/2011 5020.63 1.10% 8023.75 5.39% 150 148973.99 320066.25 6 1337.29 -0.77% 2.98% 0/0
    ^NSEI Long 07/09/2011 5113.7 09/09/2011 5056.08 -1.13% -8843.75 -5.76% 150 153411.00 311222.50 3 -2947.92 -1.13% 1.09% 0/0
    ^NSEI Short 12/09/2011 4942.9 15/09/2011 5040.15 1.97% -14787.50 -9.97% 150 148286.99 296435.00 4 -3696.88 -2.42% 0.64% 0/0
    ^NSEI Long 20/09/2011 5143.6 22/09/2011 5059.85 -1.63% -12762.50 -8.27% 150 154308.00 283672.50 3 -4254.17 -2.11% 0.48% 0/0
    ^NSEI Short 22/09/2011 4967.45 27/09/2011 4963.63 -0.08% 373.75 0.25% 150 149023.50 284046.25 4 93.44 -1.86% 4.20% 0/0
    ^NSEI Short 04/10/2011 4823.9 07/10/2011 4876.92 1.10% -8153.75 -5.63% 150 144717.00 275892.50 4 -2038.44 -1.24% 1.98% 0/0
    ^NSEI Long 10/10/2011 4922.6 18/10/2011 5057.5 2.74% 20035.00 13.57% 150 147678.00 295927.50 7 2862.14 -0.82% 4.83% 0/0
    ^NSEI Long 25/10/2011 5148.05 01/11/2011 5242.63 1.84% 13986.25 9.06% 150 154441.50 309913.75 6 2331.04 -1.21% 4.89% 0/0
    ^NSEI Short 11/11/2011 5198.6 28/11/2011 4778.42 -8.08% 62826.25 40.28% 150 155958.00 372740.00 11 5711.48 -0.58% 10.73% 0/0
    ^NSEI Long 01/12/2011 4916.7 08/12/2011 5007.98 1.86% 13491.25 9.15% 150 147501.00 386231.25 6 2248.54 0.00% 3.71% 0/0
    ^NSEI Short 09/12/2011 4918.35 16/12/2011 4796.1 -2.49% 18137.50 12.29% 150 147550.50 404368.75 6 3022.92 -0.00% 4.97% 0/0
    ^NSEI Long 27/12/2011 4763.45 29/12/2011 4701.23 -1.31% -9533.75 -6.67% 150 142903.50 394835.00 3 -3177.92 -1.73% 0.78% 0/0
    ^NSEI Short 30/12/2011 4632.95 03/01/2012 4704.7 1.55% -10962.50 -7.89% 150 138988.50 383872.50 2 -5481.25 -1.55% 0.52% 0/0
    ^NSEI Long 06/01/2012 4782.85 30/01/2012 5119.17 7.03% 50248.75 35.02% 150 143485.50 434121.25 17 2955.81 -2.01% 9.08% 0/0
    ^NSEI Long 01/02/2012 5217 13/02/2012 5375.35 3.04% 23552.50 15.05% 150 156510.00 457673.75 9 2616.94 -1.11% 4.04% 0/0
    ^NSEI Long 14/02/2012 5427.75 22/02/2012 5499.73 1.33% 10596.25 6.51% 150 162832.49 468270.00 6 1766.04 -0.92% 3.57% 0/0
    ^NSEI Short 24/02/2012 5460.8 29/02/2012 5449.05 -0.22% 1562.50 0.95% 150 163823.99 469832.50 4 390.63 -1.11% 3.53% 0/0
    ^NSEI Short 05/03/2012 5268.15 06/03/2012 5362.25 1.79% -14315.00 -9.06% 150 158044.50 455517.50 2 -7157.50 -1.79% 0.05% 0/0
    ^NSEI Long 12/03/2012 5382.05 16/03/2012 5395.5 0.25% 1817.50 1.13% 150 161461.49 457335.00 5 363.50 -1.02% 2.18% 0/0
    ^NSEI Short 19/03/2012 5305 21/03/2012 5366.33 1.16% -9398.75 -5.91% 150 159150.00 447936.25 3 -3132.92 -1.16% 1.35% 0/0
    ^NSEI Short 22/03/2012 5233.25 30/03/2012 5223.98 -0.18% 1191.25 0.76% 150 156997.50 449127.50 7 170.18 -2.92% 1.86% 0/0
    ^NSEI Long 02/04/2012 5307.1 09/04/2012 5287.9 -0.36% -3080.00 -1.93% 150 159213.01 446047.50 5 -616.00 -0.53% 1.35% 0/0
    ^NSEI Short 10/04/2012 5228 12/04/2012 5264.6 0.70% -5690.00 -3.63% 150 156840.00 440357.50 3 -1896.67 -0.70% 0.71% 0/0
    ^NSEI Short 13/04/2012 5190.8 17/04/2012 5245.13 1.05% -8348.75 -5.36% 150 155723.99 432008.75 3 -2782.92 -2.23% 0.14% 0/0
    ^NSEI Long 18/04/2012 5306.75 20/04/2012 5262.98 -0.82% -6766.25 -4.25% 150 159202.50 425242.50 3 -2255.42 -0.82% 0.67% 0/0
    ^NSEI Short 24/04/2012 5187.15 30/04/2012 5232.42 0.87% -6991.25 -4.49% 150 155614.49 418251.25 5 -1398.25 -0.94% 0.63% 0/0
    ^NSEI Long 02/05/2012 5262.15 03/05/2012 5216.95 -0.86% -6980.00 -4.42% 150 157864.49 411271.25 2 -3490.00 -0.97% 0.33% 0/0
    ^NSEI Short 04/05/2012 5154.3 18/05/2012 4906.65 -4.80% 36947.50 23.89% 150 154629.00 448218.75 11 3358.86 -0.44% 6.94% 0/0
    ^NSEI Long 28/05/2012 4956.35 31/05/2012 4924.25 -0.65% -5015.00 -3.37% 150 148690.50 443203.75 4 -1253.75 -1.22% 1.29% 0/0
    ^NSEI Short 01/06/2012 4889.35 05/06/2012 4895.25 0.12% -1085.00 -0.74% 150 146680.50 442118.75 3 -361.67 -0.73% 2.43% 0/0
    ^NSEI Long 06/06/2012 4982.25 14/06/2012 5069.85 1.76% 12940.00 8.66% 150 149467.49 455058.75 7 1848.57 -1.93% 3.26% 0/0
    ^NSEI Long 15/06/2012 5144.9 09/07/2012 5298.5 2.99% 22840.00 14.80% 150 154347.00 477898.75 17 1343.53 -2.01% 3.67% 0/0
    ^NSEI Short 09/07/2012 5263.35 19/07/2012 5233.15 -0.57% 4330.00 2.74% 150 157900.51 482228.75 9 481.11 -1.62% 1.79% 0/0
    ^NSEI Short 23/07/2012 5164.2 27/07/2012 5135.55 -0.55% 4097.50 2.64% 150 154925.99 486326.25 5 819.50 -0.00% 2.55% 0/0
    ^NSEI Long 30/07/2012 5164.2 13/08/2012 5319.23 3.00% 23053.75 14.88% 150 154925.99 509380.00 11 2095.80 -0.67% 4.13% 0/0
    ^NSEI Long 14/08/2012 5377.6 17/08/2012 5342.38 -0.66% -5483.75 -3.40% 150 161328.00 503896.25 4 -1370.94 -0.91% 0.24% 0/0
    ^NSEI Long 21/08/2012 5399.95 24/08/2012 5395.15 -0.09% -920.00 -0.57% 150 161998.50 502976.25 4 -230.00 -0.58% 0.90% 0/0
    ^NSEI Short 27/08/2012 5366.3 07/09/2012 5309.2 -1.06% 8365.00 5.20% 150 160988.98 511341.25 9 929.44 -0.61% 2.81% 0/0
    ^NSEI Long 07/09/2012 5309.2 20/09/2012 5537.03 4.29% 33973.75 21.33% 150 159275.99 545315.00 10 3397.37 0.00% 6.46% 0/0
    ^NSEI Long (trail) 21/09/2012 5652.2 05/10/2012 5356.83 -5.23% -44505.65 -26.25% 150 169566.01 500809.35 11 -4045.97 -5.23% 2.88% 0/0
    ^NSEI Short (trail) 05/10/2012 5683.45 08/10/2012 5751.85 1.20% -10460.00 -6.13% 150 170503.51 490349.35 2 -5230.00 -2.32% 13.99% 0/0
    ^NSEI Short 26/10/2012 5658.05 02/11/2012 5682.55 0.43% -3875.00 -2.28% 150 169741.50 486474.35 6 -645.83 -0.71% 1.33% 0/0
    ^NSEI Long 02/11/2012 5698.3 09/11/2012 5728.4 0.53% 4315.00 2.52% 150 170948.99 490789.35 6 719.17 -0.33% 1.39% 0/0
    ^NSEI Short 09/11/2012 5679.5 21/11/2012 5607.65 -1.27% 10577.50 6.21% 150 170385.00 501366.85 9 1175.28 -1.27% 2.31% 0/0
    ^NSEI Long 26/11/2012 5643.35 10/12/2012 5894.38 4.45% 37453.75 22.12% 150 169300.51 538820.60 11 3404.89 -0.35% 5.43% 0/0
    ^NSEI Long 11/12/2012 5949.85 21/12/2012 5881.27 -1.15% -10486.25 -5.87% 150 178495.50 528334.35 9 -1165.14 -2.13% 0.26% 0/0
    ^NSEI Long 02/01/2013 5982 08/01/2013 5969.65 -0.21% -2052.50 -1.14% 150 179460.00 526281.85 5 -410.50 -0.21% 1.01% 0/0
    ^NSEI Short 09/01/2013 5964.4 13/02/2013 5935 -0.49% 4210.00 2.35% 150 178932.00 530491.85 26 161.92 -2.47% 1.43% 0/0
    ^NSEI Short 15/02/2013 5879.1 19/02/2013 5911.7 0.55% -5090.00 -2.89% 150 176372.99 525401.85 3 -1696.67 -0.55% 0.43% 0/0
    ^NSEI Long 20/02/2013 5969.5 21/02/2013 5912.45 -0.96% -8757.50 -4.89% 150 179085.00 516644.35 2 -4378.75 -1.00% 0.03% 0/0
    ^NSEI Short 21/02/2013 5853.9 28/02/2013 5834.88 -0.32% 2653.75 1.51% 150 175616.99 519298.10 6 442.29 -1.15% 1.80% 0/0
    ^NSEI Long 11/03/2013 5930.35 13/03/2013 5845.45 -1.43% -12935.00 -7.27% 150 177910.49 506363.10 3 -4311.67 -1.43% 0.69% 0/0
    ^NSEI Short 19/03/2013 5791.75 28/03/2013 5685.75 -1.83% 15700.00 9.04% 150 173752.50 522063.10 8 1962.50 -1.24% 3.07% 0/0
    ^NSEI Long 01/04/2013 5717.4 03/04/2013 5679.7 -0.66% -5855.00 -3.41% 150 171522.00 516208.10 3 -1951.67 -0.72% 0.65% 0/0
    ^NSEI Short 04/04/2013 5604.85 11/04/2013 5575.33 -0.53% 4228.75 2.51% 150 168145.50 520436.85 6 704.79 -1.21% 2.27% 0/0
    ^NSEI Long 16/04/2013 5610.6 03/05/2013 5939.78 5.87% 49176.25 29.22% 150 168318.00 569613.10 14 3512.59 -0.97% 7.28% 0/0
    ^NSEI Long 07/05/2013 6018.85 13/05/2013 6016.47 -0.04% -556.25 -0.31% 150 180565.50 569056.85 5 -111.25 -0.79% 1.42% 0/0
    ^NSEI Short 14/05/2013 5971.05 15/05/2013 6037.5 1.11% -10167.50 -5.68% 150 179131.49 558889.35 2 -5083.75 -1.11% 0.02% 0/0
    ^NSEI Long 15/05/2013 6104.95 22/05/2013 6112.42 0.12% 921.25 0.50% 150 183148.50 559810.60 6 153.54 -1.79% 2.04% 0/0
    ^NSEI Short 23/05/2013 6074.55 27/05/2013 6083.15 0.14% -1490.00 -0.82% 150 182236.49 558320.60 3 -496.67 -0.33% 2.27% 0/0
    ^NSEI Long 30/05/2013 6127.65 31/05/2013 6034.73 -1.52% -14138.75 -7.69% 150 183829.49 544181.85 2 -7069.37 -1.52% 0.08% 0/0
    ^NSEI Short 03/06/2013 5975.55 17/06/2013 5807.27 -2.82% 25041.25 13.97% 150 179266.50 569223.10 11 2276.48 -0.58% 4.89% 0/0
    ^NSEI Short 20/06/2013 5683.15 27/06/2013 5694.58 0.20% -1913.75 -1.12% 150 170494.50 567309.35 6 -318.96 -2.45% 2.05% 0/0
    ^NSEI Long 28/06/2013 5699.2 08/07/2013 5832.3 2.34% 19765.00 11.56% 150 170975.99 587074.35 7 2823.57 -0.30% 3.59% 0/0
    ^NSEI Long 11/07/2013 5900.3 16/07/2013 5920.45 0.34% 2822.50 1.59% 150 177008.99 589896.85 4 705.62 -1.42% 2.33% 0/0
    ^NSEI Long 18/07/2013 6037.9 24/07/2013 6010.17 -0.46% -4358.75 -2.41% 150 181136.99 585538.10 5 -871.75 -1.07% 0.92% 0/0
    ^NSEI Short 25/07/2013 5962.8 12/08/2013 5603.92 -6.02% 53631.25 29.98% 150 178883.99 639169.35 13 4125.48 -0.47% 7.98% 0/0
    ^NSEI Long 13/08/2013 5664.9 16/08/2013 5655.83 -0.16% -1561.25 -0.92% 150 169947.00 637608.10 4 -390.31 -1.52% 1.58% 0/0
    ^NSEI Short 16/08/2013 5557.1 26/08/2013 5454.45 -1.85% 15197.50 9.12% 150 166713.01 652805.60 7 2171.07 -2.87% 5.45% 0/0
    ^NSEI Long 26/08/2013 5504.1 27/08/2013 5391.38 -2.05% -17108.75 -10.36% 150 165122.99 635696.85 2 -8554.38 -2.05% 0.45% 0/0
    ^NSEI Short 28/08/2013 5254.05 29/08/2013 5323.78 1.33% -10658.75 -6.76% 150 157621.49 625038.10 2 -5329.37 -1.33% 2.57% 0/0
    ^NSEI Long 02/09/2013 5528.7 03/09/2013 5341.88 -3.38% -28223.75 -17.02% 150 165861.00 596814.35 2 -14111.87 -3.38% 0.83% 0/0
    ^NSEI Long 05/09/2013 5580.95 16/09/2013 5806.2 4.04% 33587.50 20.06% 150 167428.51 630401.85 8 4198.44 -0.51% 6.29% 0/0
    ^NSEI Long 19/09/2013 6040.15 20/09/2013 5970.33 -1.16% -10673.75 -5.89% 150 181204.49 619728.10 2 -5336.87 -1.16% 1.69% 0/0
    ^NSEI Short 25/09/2013 5840.2 03/10/2013 5809.3 -0.53% 4435.00 2.53% 150 175206.01 624163.10 6 739.17 -1.33% 2.38% 0/0
    ^NSEI Long 04/10/2013 5917.65 23/10/2013 6126.33 3.53% 31101.25 17.52% 150 177529.49 655264.35 13 2392.40 -1.55% 5.11% 0/0
    ^NSEI Long 24/10/2013 6220.1 25/10/2013 6161.67 -0.94% -8963.75 -4.80% 150 186603.00 646300.60 2 -4481.88 -1.24% 0.52% 0/0
    ^NSEI Short 28/10/2013 6116.6 29/10/2013 6173.28 0.93% -8701.25 -4.74% 150 183497.99 637599.35 2 -4350.62 -0.93% 0.37% 0/0
    ^NSEI Long 30/10/2013 6252.45 07/11/2013 6270.65 0.29% 2530.00 1.35% 150 187573.50 640129.35 6 421.67 -0.70% 1.28% 0/0
    ^NSEI Short 07/11/2013 6208.7 18/11/2013 6110.4 -1.58% 14545.00 7.81% 150 186261.00 654674.35 7 2077.86 -1.29% 3.81% 0/0
    ^NSEI Long 18/11/2013 6185.15 21/11/2013 6092.42 -1.50% -14108.75 -7.60% 150 185554.49 640565.60 4 -3527.19 -1.50% 0.44% 0/0
    ^NSEI Short 22/11/2013 5985.4 25/11/2013 6092.6 1.79% -16280.00 -9.07% 150 179561.99 624285.60 2 -8140.00 -1.79% 0.21% 0/0
    ^NSEI Long 29/11/2013 6123.5 11/12/2013 6282.58 2.60% 23661.25 12.88% 150 183704.99 647946.85 9 2629.03 -0.32% 4.76% 0/0
    ^NSEI Short 12/12/2013 6230.75 18/12/2013 6229.8 -0.02% -57.50 -0.03% 150 186922.50 647889.35 5 -11.50 -0.90% 1.62% 0/0
    ^NSEI Long 20/12/2013 6263.75 31/12/2013 6301.75 0.61% 5500.00 2.93% 150 187912.50 653389.35 7 785.71 -1.49% 1.28% 0/0
    ^NSEI Long 02/01/2014 6344.05 20/01/2014 6268.02 -1.20% -11603.75 -6.10% 150 190321.49 641785.60 13 -892.60 -3.22% 0.22% 0/0
    ^NSEI Long 22/01/2014 6346.5 24/01/2014 6299.48 -0.74% -7253.75 -3.81% 150 190394.99 634531.85 3 -2417.92 -0.93% 0.14% 0/0
    ^NSEI Short 27/01/2014 6188.55 06/02/2014 6015.58 -2.80% 25746.25 13.87% 150 185656.49 660278.10 9 2860.69 -0.00% 4.12% 0/0
    ^NSEI Long 10/02/2014 6079.95 13/02/2014 6036 -0.72% -6792.50 -3.72% 150 182398.50 653485.60 4 -1698.12 -0.72% 0.44% 0/0
    ^NSEI Short (trail) 14/02/2014 5991.1 05/03/2014 6328.45 5.63% -50802.50 -28.27% 150 179733.00 602683.10 13 -3907.88 -5.63% 0.11% 0/0
    ^NSEI Long 18/03/2014 6562.85 20/03/2014 6503.83 -0.90% -9053.75 -4.60% 150 196885.49 593629.35 3 -3017.92 -0.99% 0.18% 0/0
    ^NSEI Long 24/03/2014 6574.95 04/04/2014 6710.27 2.06% 20098.75 10.19% 150 197248.50 613728.10 10 2009.87 -0.98% 3.07% 0/0
    ^NSEI Long 09/04/2014 6776.75 15/04/2014 6734.72 -0.62% -6503.75 -3.20% 150 203302.50 607224.35 4 -1625.94 -1.06% 0.62% 0/0
    ^NSEI Long 21/04/2014 6819.05 28/04/2014 6777.13 -0.61% -6488.75 -3.17% 150 204571.49 600735.60 5 -1297.75 -0.68% 0.74% 0/0
    ^NSEI Short 07/05/2014 6656.8 09/05/2014 6691 0.51% -5330.00 -2.67% 150 199704.00 595405.60 3 -1776.67 -0.93% 0.27% 0/0
    ^NSEI Long 09/05/2014 6743.45 19/05/2014 7213.2 6.97% 70262.50 34.73% 150 202303.51 665668.10 7 10037.50 -1.35% 12.16% 0/0
    ^NSEI Long 26/05/2014 7381 13/06/2014 7598.85 2.95% 32477.50 14.67% 150 221429.99 698145.60 15 2165.17 -3.56% 4.32% 0/0
    ^NSEI Short 16/06/2014 7525.35 17/06/2014 7593.8 0.91% -10467.50 -4.64% 150 225760.49 687678.10 2 -5233.75 -0.91% 0.50% 0/0
    ^NSEI Short 23/06/2014 7487.55 24/06/2014 7552.3 0.86% -9912.50 -4.41% 150 224626.48 677765.60 2 -4956.25 -0.86% 0.61% 0/0
    ^NSEI Long 30/06/2014 7593.35 08/07/2014 7705.08 1.47% 16558.75 7.27% 150 227800.51 694324.35 7 2365.54 -0.81% 2.77% 0/0
    ^NSEI Short 08/07/2014 7618.15 10/07/2014 7680.25 0.82% -9515.00 -4.16% 150 228544.50 684809.35 3 -3171.67 -2.50% 0.87% 0/0
    ^NSEI Long 18/07/2014 7655.65 28/07/2014 7757.48 1.33% 15073.75 6.56% 150 229669.50 699883.10 7 2153.39 -0.79% 2.42% 0/0
    ^NSEI Short 01/08/2014 7707.6 05/08/2014 7696.9 -0.14% 1405.00 0.61% 150 231228.00 701288.10 3 468.33 -0.12% 1.48% 0/0
    ^NSEI Short 08/08/2014 7592.45 12/08/2014 7654.8 0.82% -9552.50 -4.19% 150 227773.50 691735.60 3 -3184.17 -1.27% 0.69% 0/0
    ^NSEI Long 13/08/2014 7740.95 26/08/2014 7912.1 2.21% 25472.50 10.97% 150 232228.51 717208.10 9 2830.28 -0.58% 2.94% 0/0
    ^NSEI Long 01/09/2014 7984 10/09/2014 8115.03 1.64% 19453.75 8.12% 150 239519.99 736661.85 8 2431.72 0.00% 2.46% 0/0
    ^NSEI Short 15/09/2014 8057.3 18/09/2014 8026.55 -0.38% 4412.50 1.83% 150 241718.99 741074.35 4 1103.13 -0.25% 1.64% 0/0
    ^NSEI Long 19/09/2014 8120.85 23/09/2014 8043.02 -0.96% -11873.75 -4.87% 150 243625.51 729200.60 3 -3957.92 -0.96% 0.49% 0/0
    ^NSEI Short 25/09/2014 7939.7 30/09/2014 8000.77 0.77% -9361.25 -3.93% 150 238191.01 719839.35 4 -2340.31 -1.00% 1.23% 0/0
    ^NSEI Short 08/10/2014 7841.8 09/10/2014 7923.33 1.04% -12428.75 -5.28% 150 235254.00 707410.60 2 -6214.37 -1.04% 0.33% 0/0
    ^NSEI Short 13/10/2014 7815.75 20/10/2014 7856.95 0.53% -6380.00 -2.72% 150 234472.50 701030.60 5 -1276.00 -1.44% 1.18% 0/0
    ^NSEI Long 21/10/2014 7928 13/11/2014 8352.65 5.36% 63497.50 26.70% 150 237840.00 764528.10 15 4233.17 -0.68% 6.14% 0/0
    ^NSEI Long 17/11/2014 8415.05 19/11/2014 8387.42 -0.33% -4344.50 -1.72% 150 252451.48 760183.60 3 -1448.17 -0.78% 0.47% 0/0
    ^NSEI Long 21/11/2014 8455.65 25/11/2014 8443.9 -0.14% -1962.50 -0.77% 150 253669.50 758221.10 3 -654.17 -0.67% 0.93% 0/0
    ^NSEI Long 28/11/2014 8535.35 02/12/2014 8526.22 -0.11% -1569.50 -0.61% 150 256060.47 756651.60 3 -523.17 -0.22% 1.03% 0/0
    ^NSEI Long (trail) 04/12/2014 8623 12/12/2014 8218.84 -4.69% -60824.00 -23.51% 150 258690.00 695827.60 7 -8689.14 -4.69% 0.05% 0/0
    ^NSEI Long 02/01/2015 8291 06/01/2015 8327.85 0.44% 5327.50 2.14% 150 248729.99 701155.10 3 1775.83 -0.03% 1.86% 0/0
    ^NSEI Short 06/01/2015 8214.7 09/01/2015 8255.53 0.50% -6324.50 -2.57% 150 246440.99 694830.60 4 -1581.12 -1.38% 1.82% 0/0
    ^NSEI Long 13/01/2015 8332.6 30/01/2015 8856.03 6.28% 78314.50 31.33% 150 249977.98 773145.10 13 6024.19 -1.15% 7.97% 0/0
    ^NSEI Short 02/02/2015 8775.1 12/02/2015 8654.47 -1.37% 17894.50 6.80% 150 263252.98 791039.60 9 1988.28 -0.75% 3.47% 0/0
    ^NSEI Long 13/02/2015 8732.55 23/02/2015 8821.55 1.02% 13150.00 5.02% 150 261976.48 804189.60 6 2191.67 -0.03% 2.07% 0/0
    ^NSEI Short 24/02/2015 8736.1 25/02/2015 8820.1 0.96% -12800.00 -4.88% 150 262082.98 791389.60 2 -6400.00 -0.96% 0.11% 0/0
    ^NSEI Short 26/02/2015 8726.75 27/02/2015 8784.7 0.66% -8892.50 -3.40% 150 261802.50 782497.10 2 -4446.25 -0.68% 0.66% 0/0
    ^NSEI Long 02/03/2015 8885.45 05/03/2015 8894.33 0.10% 1132.00 0.42% 150 266563.49 783629.10 4 283.00 0.00% 2.63% 0/0
    ^NSEI Short 10/03/2015 8740.45 13/03/2015 8817.45 0.88% -11750.00 -4.48% 150 262213.49 771879.10 4 -2937.50 -1.19% 0.72% 0/0
    ^NSEI Short 20/03/2015 8612 30/03/2015 8448.45 -1.90% 24332.50 9.42% 150 258359.99 796211.60 7 3476.07 -0.18% 3.98% 0/0
    ^NSEI Long 01/04/2015 8573.75 16/04/2015 8714.25 1.64% 20875.00 8.12% 150 257212.50 817086.60 8 2609.38 -1.27% 3.12% 0/0
    ^NSEI Short 17/04/2015 8645.65 04/05/2015 8279.03 -4.24% 54793.00 21.13% 150 259369.50 871879.60 11 4981.18 -0.63% 5.79% 0/0
    ^NSEI Long 05/05/2015 8346 06/05/2015 8250.2 -1.15% -14570.00 -5.82% 150 250379.99 857309.60 2 -7285.00 -1.15% 0.12% 0/0
    ^NSEI Short 06/05/2015 8144.75 08/05/2015 8176.4 0.39% -4947.50 -2.02% 150 244342.49 852362.10 3 -1649.17 -2.30% 1.81% 0/0
    ^NSEI Long 18/05/2015 8332.75 25/05/2015 8380.75 0.58% 7000.00 2.80% 150 249982.49 859362.10 6 1166.67 -0.73% 1.88% 0/0
    ^NSEI Short 26/05/2015 8335 29/05/2015 8379.85 0.54% -6927.50 -2.77% 150 250050.00 852434.60 4 -1731.88 -0.54% 0.78% 0/0
    ^NSEI Long 01/06/2015 8443.9 02/06/2015 8368.65 -0.89% -11487.50 -4.53% 150 253317.00 840947.10 2 -5743.75 -0.89% 0.28% 0/0
    ^NSEI Short 02/06/2015 8270.15 10/06/2015 8120.92 -1.80% 22183.75 8.94% 150 248104.50 863130.85 7 3169.11 -2.12% 3.20% 0/0
    ^NSEI Short 11/06/2015 8005.15 15/06/2015 8051.67 0.58% -7178.75 -2.99% 150 240154.49 855952.10 3 -2392.92 -1.97% 0.81% 0/0
    ^NSEI Long 18/06/2015 8163.05 29/06/2015 8329.45 2.04% 24760.00 10.11% 150 244891.50 880712.10 8 3095.00 -0.75% 3.19% 0/0
    ^NSEI Short 29/06/2015 8257.4 30/06/2015 8309.4 0.63% -8000.00 -3.23% 150 247722.00 872712.10 2 -4000.00 -0.87% 0.75% 0/0
    ^NSEI Long 01/07/2015 8423.15 08/07/2015 8457.5 0.41% 4952.50 1.96% 150 252694.50 877664.60 6 825.42 -0.63% 1.64% 0/0
    ^NSEI Short 08/07/2015 8370.15 13/07/2015 8438.38 0.82% -10434.50 -4.16% 150 251104.50 867230.10 4 -2608.62 -1.04% 0.65% 0/0
    ^NSEI Long 15/07/2015 8480.25 21/07/2015 8533.53 0.63% 7792.00 3.06% 150 254407.49 875022.10 5 1558.40 -0.20% 1.92% 0/0
    ^NSEI Long 23/07/2015 8646.75 24/07/2015 8576.7 -0.81% -10707.50 -4.13% 150 259402.50 864314.60 2 -5353.75 -0.84% 0.09% 0/0
    ^NSEI Short 27/07/2015 8492.2 31/07/2015 8455.45 -0.43% 5312.50 2.09% 150 254765.99 869627.10 5 1062.50 -0.00% 2.01% 0/0
    ^NSEI Long 03/08/2015 8548.95 10/08/2015 8527.28 -0.25% -3450.50 -1.35% 150 256468.51 866176.60 6 -575.08 -1.18% 0.67% 0/0
    ^NSEI Short 11/08/2015 8448.25 14/08/2015 8479.75 0.37% -4925.00 -1.94% 150 253447.49 861251.60 4 -1231.25 -1.28% 1.31% 0/0
    ^NSEI Short 21/08/2015 8322.2 28/08/2015 7994.73 -3.93% 48921.25 19.59% 150 249665.99 910172.85 6 8153.54 -0.00% 7.87% 0/0
    ^NSEI Short 02/09/2015 7746.5 09/09/2015 7764.55 0.23% -2907.50 -1.25% 150 232394.99 907265.35 6 -484.58 -1.50% 2.67% 0/0
    ^NSEI Long 11/09/2015 7846.05 22/09/2015 7908.42 0.79% 9156.25 3.89% 150 235381.49 916421.60 7 1308.04 -1.10% 2.66% 0/0
    ^NSEI Short 23/09/2015 7787.75 24/09/2015 7889.13 1.30% -15406.25 -6.59% 150 233632.49 901015.35 2 -7703.13 -1.30% 0.83% 0/0
    ^NSEI Short 29/09/2015 7723.25 15/10/2015 8166.55 5.74% -66695.00 -28.79% 150 231697.50 834320.35 12 -5557.92 -6.75% 0.41% 0/0
    ^NSEI Long 16/10/2015 8244.5 27/10/2015 8241.95 -0.03% -582.50 -0.24% 150 247334.99 833737.85 7 -83.21 -1.17% 1.11% 0/0
    ^NSEI Short 27/10/2015 8217.15 04/11/2015 8102.35 -1.40% 17020.00 6.90% 150 246514.51 850757.85 7 2431.43 -0.30% 2.70% 0/0
    ^NSEI Short 05/11/2015 7995.6 17/11/2015 7825.95 -2.12% 25247.50 10.53% 150 239868.00 876005.35 8 3155.94 -0.45% 3.52% 0/0
    ^NSEI Long 20/11/2015 7860.45 24/11/2015 7816 -0.57% -6867.50 -2.91% 150 235813.49 869137.85 3 -2289.17 -0.57% 0.59% 0/0
    ^NSEI Long 27/11/2015 7906.95 03/12/2015 7905.65 -0.02% -395.00 -0.17% 150 237208.50 868742.85 5 -79.00 -0.35% 0.92% 0/0
    ^NSEI Short 04/12/2015 7821.4 15/12/2015 7661.15 -2.05% 23837.50 10.16% 150 234641.99 892580.35 8 2979.69 -0.05% 3.46% 0/0
    ^NSEI Long 16/12/2015 7715.75 04/01/2016 7895.52 2.33% 26766.25 11.56% 150 231472.50 919346.60 12 2230.52 0.00% 3.11% 0/0
    ^NSEI Short 04/01/2016 7835.5 14/01/2016 7550.38 -3.64% 42568.75 18.11% 150 235065.00 961915.35 9 4729.86 -1.30% 5.23% 0/0
    ^NSEI Short 18/01/2016 7425.8 20/01/2016 7470.6 0.60% -6920.00 -3.11% 150 222773.99 954995.35 3 -2306.67 -0.60% 1.20% 0/0
    ^NSEI Long 25/01/2016 7470.9 02/02/2016 7501.63 0.41% 4408.75 1.97% 150 224126.99 959404.10 6 734.79 -0.91% 1.73% 0/0
    ^NSEI Short 03/02/2016 7402.8 05/02/2016 7475.38 0.98% -11086.25 -4.99% 150 222083.99 948317.85 3 -3695.42 -0.98% 0.71% 0/0
    ^NSEI Short 09/02/2016 7323.45 16/02/2016 7096.23 -3.10% 33883.75 15.42% 150 219703.51 982201.60 6 5647.29 -0.00% 6.21% 0/0
    ^NSEI Long 18/02/2016 7208.65 23/02/2016 7106.52 -1.42% -15518.75 -7.18% 150 216259.50 966682.85 4 -3879.69 -1.42% 0.61% 0/0
    ^NSEI Short 25/02/2016 7009.75 01/03/2016 7035.1 0.36% -4002.50 -1.90% 150 210292.49 962680.35 4 -1000.63 -1.21% 2.62% 0/0
    ^NSEI Long 02/03/2016 7308.15 11/03/2016 7476.58 2.30% 25063.75 11.43% 150 219244.50 987744.10 7 3580.54 0.00% 3.27% 0/0
    ^NSEI Long 14/03/2016 7547.1 15/03/2016 7504 -0.57% -6665.00 -2.94% 150 226413.01 981079.10 2 -3332.50 -0.57% 0.48% 0/0
    ^NSEI Short 16/03/2016 7424.3 11/04/2016 7645.58 2.98% -33391.25 -14.99% 150 222729.00 947687.85 17 -1964.19 -4.76% 0.26% 0/0
    ^NSEI Long 13/04/2016 7772.2 25/04/2016 7875.33 1.33% 15268.75 6.55% 150 233166.01 962956.60 6 2544.79 0.00% 2.65% 0/0
    ^NSEI Short 26/04/2016 7827 03/05/2016 7884.65 0.74% -8847.50 -3.77% 150 234810.00 954109.10 6 -1474.58 -2.11% 0.63% 0/0
    ^NSEI Short 06/05/2016 7697.25 09/05/2016 7784.3 1.13% -13257.50 -5.74% 150 230917.49 940851.60 2 -6628.75 -1.13% 0.25% 0/0
    ^NSEI Long 10/05/2016 7890.25 11/05/2016 7787.63 -1.30% -15593.75 -6.59% 150 236707.49 925257.85 2 -7796.88 -1.30% 0.08% 0/0
    ^NSEI Long 12/05/2016 7896.9 13/05/2016 7797.2 -1.26% -15155.00 -6.40% 150 236907.00 910102.85 2 -7577.50 -1.26% 0.24% 0/0
    ^NSEI Long 17/05/2016 7916.05 18/05/2016 7856.13 -0.76% -9188.75 -3.87% 150 237481.49 900914.10 2 -4594.38 -0.88% 0.30% 0/0
    ^NSEI Short 19/05/2016 7772.15 25/05/2016 7809.3 0.48% -5772.50 -2.48% 150 233164.49 895141.60 5 -1154.50 -1.34% 0.73% 0/0
    ^NSEI Long 25/05/2016 7882.05 06/06/2016 8198.15 4.01% 47215.00 19.97% 150 236461.49 942356.60 9 5246.11 -0.92% 4.82% 0/0
    ^NSEI Long 07/06/2016 8262 09/06/2016 8224.85 -0.45% -5772.50 -2.33% 150 247859.99 936584.10 3 -1924.17 -0.55% 0.40% 0/0
    Below is the trade report and in chart its showing . on 26/04 the price opened below lower band , pierced middle and upper band. So ideally stop loss should have triggered on same day. can you please check .

    ^NSEI Short 10/06/2016 8184.6 15/06/2016 8176.4 -0.10% 1030.00 0.42% 150 245538.01 937614.10 4 257.50 -0.99% 1.47% 0/0

  3. Hi, thanks for this code. Really appreciate the work you guys are doing.
    Had a couple of queries, how will the returns be affected if the trade dlays are set to 1,1,1,1
    And any idea how many Nifty and BankNifty points you are capturing in total. Guess that number would not be readily available from the backtest reports

    regards, Vivek

    • Hi Vivek,

      Returns would get negatively affected if Trade delays are introduced. The strategy is meant to take position as soon as Crossover happens. Regarding the total points, it can be calculated using Total Profit and Number of Trades (Excluding Brokerage). Give it a try once.

  4. Admin,

    The code doesn’t capture the intra day stop loss hit and gap up stop loss. eg if price opens gap up above stop loss band after a short is entered its not showing the reversal trade and also if short is entered and price cross above stop loss its not captured in trade

  5. Admin,

    The code doesn’t capture the intra day stop loss hit and gap up stop loss. eg if price opens gap up above stop loss band after a short is entered its not showing the reversal trade and also if short is entered and price cross above stop loss its not captured in trade. Can you pls adivse

    • Hi Prasanth,

      Thanks for pointing out this! Check the logic for Price assignments as below, and it should resolve the issue:

      BuyPrice=IIf(Open>DonchianUpper,Open,DonchianUpper);
      SellPrice=IIf(Open<DonchianMiddle,Open,DonchianMiddle);
      ShortPrice=IIf(OpenDonchianMiddle,Open,DonchianMiddle);

      Also,use option Allow same bar Exit/Entry Signal in your backtest settings.

  6. Hi,
    Very awesome blog!

    Could you please tell me where to get reliable intraday data for Indian Futures.
    Also is it possible for you to share the data ?

  7. Hi ,
    Do you mean replace
    BuyPrice=DonchianUpper;
    SellPrice=DonchianMiddle;
    ShortPrice=DonchianLower;
    CoverPrice=DonchianMiddle;

    with the below code
    BuyPrice=IIf(Open>DonchianUpper,Open,DonchianUpper);
    SellPrice=IIf(Open<DonchianMiddle,Open,DonchianMiddle);
    ShortPrice=IIf(Open==DonchianMiddle,Open,DonchianMiddle);
    CoverPrice=DonchianMiddle;

  8. Dear Sir,
    Thanks a lot for Excellent AFL. It is possible for you to add Popup and Sound alert for buy/sell signal.
    Thanks in advance,
    Best Regds

  9. Admin,
    I think it still it needs to be changed for same day stop loss trigger while back testing with EOD candles. I believe long trades give more pft that short trades due to whipsaws.

    I have changed the price fields as below for gap up openings and same day stop loss exits but couldn’t change sell and cover signals Still not showing short and cover on same day for 26/04/2016 date. pls check whether sell and cover signals condition for same day stop loss exits

    on 24/06 we had gap down opening below lower band ..
    BuyPrice=IIf(Open>DonchianUpper,Open,DonchianUpper);
    SellPrice=IIf(Open<DonchianMiddle,Open,IIf( (Cross(High,DonchianUpper) == True) AND (Cross(DonchianMiddle,Low) == True),DonchianMiddle,DonchianMiddle));
    ShortPrice=IIf(Open DonchianMiddle,Open,IIf((Cross(DonchianLower,Low) == True) AND (Cross(High,DonchianMiddle) == True),DonchianMiddle,DonchianMiddle));

    • Hi Prasanth,

      The returns calculated during backtesting does not consider Intraday stoploss, and I don’t recommend to do so for any EOD strategy. In order to consider Intraday movements, we should backtest using 1-minute candles, but the AFL needs to be re-written for that.

  10. Excellent blog and excellent effort from your side. But no post from last one month . Sir please. Post some more intraday system with back tests report for 4 -5 years.

  11. Hello TT,
    Which one do you feel is the best AFL of the Week so far from your side, for Intraday?
    And any reasons for that.

    • Hi Sachin,

      Sorry we cannot quantify any of the AFL as best. All are good depending on your trading style.

  12. hi, thanks for your efforts. This website is very useful and educational. Had a query with respect to this afl, does it plot the stop also on the chart or does it only plot the channel and stop works in the background

    • Hi Vivek,

      This AFL does not plot the stop line. As you said, it works in background while backtesting.

  13. admin great afl ,
    need a small code correction …eg : during gap up opens it takes long @ lowest price for that day and during gap down it shorts at lowest price of the day ..
    added your corrected codebut problem still exists …kindly advice
    grt afl thx for sharing

    • Depending on the Auto Trading software you are using you would need to add few more lines of code.

  14. can I use same code in 15 min timeframe , I backtested It gives very good return, Please suggest

  15. dear
    admin , great work on the coding , i request you to kindly alter the coding
    for back-testing on 5 min candles along with changing the cover to open
    in case of gap ups or downs .kindly help if you find the time . thx

  16. Sir as per Buy Condition Current Candle High is greater than Donchian Channel upper band but how is it possible as donchain channel itself is highest high of last n periods.

    • Hi Dipak,

      The strategy checks last ‘n’ periods with current candle. So its very much possible

  17. I am getting a failure running a backtest “The number of format specifier(s) (%) does not match the number of arguments passed (Ln:12, Col:21)

    Any suggestions appreciated

    • Hi Ryan,

      Kindly comment that line. It doesn’t work in some versions of Amibroker.

  18. Hello Admin,
    Can you kindly tell how much the return will vary if one trades with SAR the highs and lows of the daily candle which breaches of upper and lower channels.
    That means one enters the next day.
    But there comes the problem of gaps. To overcome the gaps either one enters the trade the same day of the breach at the last 5min, or at the open itself the next day.
    If you can kindly answer or for that matter anyone else in details it will be helpful for the lesser mortals like me!
    Thank you.

  19. Does the signal needs to be taken on a closing basis or as soon as the upper or lower band is touched/crossed?

  20. Hello, does it still work on these two indices as of now (2021)? If it does, would you please publish the backtest report? Thanks in advance.

    • Hi Raj,

      Yes, it works in 2021 also. Will share the updated backtest report soon

  21. So, we will get return of 31.23% CAGR but had a draw down of 40% at some point (in BNF) which is practically not possible to stick on for such long long term for a trader. An Investor may stick to it. Am I reading the back test reports correctly ?

    • Hi Vidyasagr,

      We completely understand, but that’s the issue with any trend-following strategy. Drawdowns are hard to avoid

Leave a Reply

Your email address will not be published.