donchian channel .docx

Author: aggelos-kotsokolos

Post on 05-Jan-2016

216 views

Category:

Documents


0 download

Embed Size (px)

DESCRIPTION

DONCHIAN CHANNEL

TRANSCRIPT

input:

AccountSize(100000), {size of trading account in dollars}AcctRisk(.01), {% Risk per trade}ATRMult(2), {Stop size in multiples of the average range}EntryLength(40), {Trade on a break of the highest high or lowest low of X bars}BarsBack(10); {number of bars to look back to calculate average range for stop size}

vars: BuyPx(0), SellPx(0), StopSize(0), Risk(0);

BuyPx = Highest(high, EntryLength); {buy point, in this case highest high of the last 40 bars, defined by EntryLength above}SellPx = Lowest(Low, EntryLength); {sell point, in this case lowest low of the last 40 bars, defined by EntryLength above} StopSize = Average(Range, BarsBack)*ATRMult; {sets the size of the stop loss, in this case it is the average range of the 10 bars multiplied by two}Risk = accountsize*acctrisk; {Total risk per trade, in this case 100,000 x .01 = $1000}

Buy Risk/StopSize contracts next bar at buypx stop; {Buy condition}Sellshort Risk/StopSize contracts next bar at sellpx stop; {Sell condition}

Setdollartrailing(Risk); {Trailing stoploss}

Here is the code for a basic Donchian Channel breakout. You can copy and paste it into a Tradestation EasyLanguage Editor and compile it, or another EasyLanguage editor. Then you can Insert Strategy on a daily chart of EURUSD and see how it works. I have included explanations of what each part of the code does in braces. You can also optimize it by right clicking on the chart with the strategy and selecting "Format Strategies", then click "Format".

The difference between my Donchian channel system and others is that I use a tighter ATR stop, and the original would exit when it hit a 10 day high or low in the opposite direction of the original trade.