Double Donchian Trading system is a Breakout trading system inspired by Richard J.Dennis. Donchian channels were developed by Richard Donchian, a pioneer of mechanical trend-following systems. Double Donchian trading system is a turtle trading strategy. Curtis Faith in his book Way Of The Turtle describes a variation of the Donchian system used by the legendary Turtle Traders.
Long Entry Rules
Long Entry is made whenever candlestick breaks the outer upper Donchian Channel for the first time on the upper side.
Short Entry Rule
Short Entry is made whenever candlestick breaks the outer Lower Donchian Channel for the first time on the lower side.
Long Exit Rules
Long Entry is made whenever candlestick breaks the inner lower Donchian Channel for the first time on the lower side.
Short Entry Rule
Short Entry is made whenever candlestick breaks the inner upper Donchian Channel for the first time on the upper side.
The Buy and Sell Rules are represented as
Buy = H>Ref(DonchianUpper1,-1);
Short = L<Ref(DonchianLower1,-1);
Cover = H>Ref(DonchianUpper2,-1);
Sell = L<Ref(DonchianLower2,-1);
Further Exrem is used to eliminate the subsequent signals other than the first breakout signal.
The entry and exit signals on the charts are marked as follows
Long Entry – Green Arrow, Short Entry – Red Arrow, Long Exit – Green Star, Short Exit – Red Star
//Coded by Rajandran R
//Founder - www.marketcalls.in
_SECTION_BEGIN("Double Donchain Trading System");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
SetPositionSize(100,spsShares);
pds1 = param("param1",79,30,100,1); //5min - 79 15min - 38
DonchianUpper1 = HHV( Ref( H, -1 ), pds1 ); // Highest high value of highs in last 40 periods
DonchianLower1 = LLV( Ref( L, -1 ), pds1 ); // Lowest low value of low in last 40 periods
pds2 = param("param2",24,5,50,1);; //5min - 24 15min - 6
DonchianUpper2 = HHV( Ref( H, -1 ), pds2 ); // Highest high value of highs in last 14 periods
DonchianLower2 = LLV( Ref( L, -1 ), pds2 ); // Lowest low value of low in last 14 periods
Plot( DonchianUpper1, "Donchian U1", ParamColor( "DU Color1", colorBlue ), ParamStyle( "DU Style", styleLine ) );
Plot( DonchianLower1, "Donchian L1", ParamColor( "DL Color1", colorBlue ), ParamStyle( "DL Style", styleLine ) );
Plot( DonchianUpper2, "Donchian U2", ParamColor( "DU Color2", colorRed ), ParamStyle( "DU Style", styleLine ) );
Plot( DonchianLower2, "Donchian L2", ParamColor( "DL Color2", colorRed ), ParamStyle( "DL Style", styleLine ) );
Buy = H>Ref(DonchianUpper1,-1);
Short = L<Ref(DonchianLower1,-1);
Cover = H>Ref(DonchianUpper2,-1);
Sell = L<Ref(DonchianLower2,-1);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
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(Cover, shapeStar, shapeNone),colorRed, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorGreen, 0, H, Offset=40);
_SECTION_END();
Which is the ideal timeframe to follow?
5min, 10min, 15min timeframes for Stocks/Indices. 10min,15min, and 30min for commodities
What is the Max Winning ratio I can expect?
anywhere between 40-45% across different timeframes.
Can I use the parameter for my studies in other stock/Indices
This parameter is optimized for Nifty and Bank Nifty. Do your own studies and observations with different parameters.
What is the benefit of trading this system?
It is a low-risk trading system with a Max Drawdown% of 13% with 2 lots of Nifty and 2 Lakhs of capital(brokerage included)
Double Donchain Trading System Backtest Results for Nifty Spot Since March 2009 to 10th May 2014
Equity Curve
Drawdown Curve
Profit Table
Sir,
Thanks for the sharing the system. I am not able o backtest this code, the scan shows me the no of rows with Buy/Sell but, the backtest yields no results. I believe using a leading indicator can increase the win% and a better CAR/MDD. Can you plz help me backtest the code
Hi Code is backtestable. However if you are very new to futures backtesting then refer the procedure here
http://www.amibroker.com/guide/h_futbacktest.html
Thanks Sir,
Its working now
Hello Rajendran,
I could not load the Double Donchain AFL code as it throws me the following message
“Error line 16
Too many arguments.”
Request you to verify the error code and upload the workable afl code for donchain.
Regards
Rajesh R
Which Amibroker Version you are using?
After adding following lines, this AFL gives terrible negative profits
BuyPrice = Open;
CoverPrice = Open;
ShortPrice = Open;
SellPrice = Open;
SetTradeDelays( 1, 1, 1, 1 );
Hi,
SetTradeDelays( 1, 1, 1, 1 ); is more than enough condition. BuyPrice = open statement is misleading and the rest of the three variables could give you wrong picture about the system.
Sir,
How can someone play around with the 40 and the 14 period High/Low?
Backtest and understand the trading system before you start trading live.
Whats the parameter for Nifty and Bank nifty Positional Trading(Daily Timeframe)
Sample default parameters as in the AFL code for Nifty and Bank Nifty.
Can we have double donchain AFL code for the EOD. we do not have option in our office to check markets.
Regards
Rajesh R
Dear Rajendran,
hav u used money management while backtesting this strategy?.. like u started with 2 lots for 2 lakhs. when ur capital grows to 3lakhs, do u trade with 3 lots or 2 lots for full backtesting period??
in such a case you can change your position size to percentage based instead of fixed.
K. In ur above back testing result, which money management method u used??. Whether u have increased ur position with increase in trading capital????..
Fixed Position Size. However you can implement your own logic as per your requirement. Above is just a prototype example!
Hi Rajendran, Thank you for sharing this study. In this study, is the signal generated as soon as the channel is breached or the signal is generated only at the close of the candle? I am asking because in the backtest, its taking the closing candle price.
Also, on a related note, i see plenty of Doichian Channel programs (including the one you’ve given in marketcalls portal) where the signal is generated as soon as the channel is breached. which one of them is a good practice? Thank you