Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

Double Donchian Trading System – Amibroker AFL code

1 min read

Double Donchian Trading system is a Breakout trading system inspired from 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.
Double Donchain Trading System

 
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

Double Donchain Trading System Amibroker AFL code

Which is the ideal timeframe to follow?

5min, 10min, 15min timeframes for Stocks/Indices. 10min,15min,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 observation with different parameters.

What is the benifit of trading this system?
It is a low risk trading system with the 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
1. Portfolio Equity
Drawdown Curve
2. Underwater Equity
Profit Table
3. Profit Table

Rajandran R Founder of Marketcalls and Co-Founder Algomojo. Full-Time Derivative Trader. Expert in Designing Trading Systems (Amibroker, Ninjatrader, Metatrader, Python, Pinescript). Trading the markets since 2006. Mentoring Traders on Trading System Designing, Market Profile, Orderflow and Trade Automation.

What is QuantZilla?

Quantzilla is 75+ hours of code mentoring program designed for noncoders who want to learn the coding program right from designing indicators, scanners, trading...
Rajandran R
58 sec read

Things to Consider While Building a Bracket Order Execution…

Building a Bracket Order Strategy is the most demanded request we got from most of the algomojo traders. This article explains the list of...
Rajandran R
12 min read

PlaceOrder – Multi Broker Exectuion Code Snippets for Amibroker

This tutorial explains how to build a button trading right from scratch and with a click of a button how you can send orders...
Rajandran R
7 min read

16 Replies to “Double Donchian Trading System – Amibroker AFL code”

  1. 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

  2. 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

  3. After adding following lines, this AFL gives terrible negative profits

    BuyPrice = Open;
    CoverPrice = Open;
    ShortPrice = Open;
    SellPrice = Open;
    SetTradeDelays( 1, 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.

  4. Can we have double donchain AFL code for the EOD. we do not have option in our office to check markets.

    Regards
    Rajesh R

  5. 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??

      1. K. In ur above back testing result, which money management method u used??. Whether u have increased ur position with increase in trading capital????..

Leave a Reply to Rajandran R Cancel reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More