Donchian Channel trend strategy
Author: Dramsey7
Creation Date: 9/9/2012 2:04 PM
profile picture

Dramsey7

#1
hi guys, im completely new to wealth lab and would like some help creating a simple strategy. i would like to create a dual donchian band strategy where the longer band is used only for trend direction and the shorter one is used to trade. For example, wait for the market to break the 120 day high i.e trend turns up, and thereafter only take buys when the market breaks the 20 day high. The stop would be the 20 day low and for shorts the rules would be reversed. Obviously i´d also like to be able to try and optimise it. Can anyone help?

thanks in advance

David
profile picture

Eugene

#2
Welcome to the forums David.

Your strategy has been uploaded. Check this out:

Dual Donchian Bands

I recommend downloading it directly using the convenient "Strategy Download" feature (found in Wealth-Lab's "Open Strategy" dialog).


profile picture

Dramsey7

#3
thanks so much Eugene. thats exactly what i was looking for. just one thing though. i was trying to look at the strategy using a 2% stop of total equity and i get an error saying "strategy code must set risk stop level in order to use market risk position size." is it possible that the initial trade size is related to where the shorter donchian band is at the time? Sorry to be a pest...

best regards

David
profile picture

Eugene

#4
No David, it's a different thing. You didn't specify this condition, and it requires extra code. Look up RiskStopLevel in the QuickRef and also check out the User Guide on position sizing.

CODE:
Please log in to see this code.


I've uploaded a revised version of the Strategy that includes this tweak. Just repeat the known steps to get the updated Strategy.
profile picture

Dramsey7

#5
Understood. Thanks so much for your help
profile picture

Dramsey7

#6
eugene, can i ask one more favour please. i want to look at a variation of the other strategy where i buy on a break of the 20 day donchian but only if the 70 day SMA is rising at the same time. The stop is an initial stop of 3 times the ATR using 2% of the available capital and then the opposite 20 day donchian band. This one seems complex to me and i have no idea where to start. can you help?

thank you
profile picture

Eugene

#7
Define the SMA:
CODE:
Please log in to see this code.

Then add a condition like this on top of the BuyAtStop (reverse for ShortAtStop). This is just for example, since you haven't specified what a rising SMA is:
CODE:
Please log in to see this code.

QUOTE:
The stop is an initial stop of 3 times the ATR using 2% of the available capital

Again, it's not clear what the ATR initial stop is:

1. a volatility money management, and therefore you can follow this FAQ: How do I implement volatility position sizing?,
2. or is the last close price minus 3 ATRs? In this case, just modify the RiskStopLevel as shown below:
CODE:
Please log in to see this code.

Reverse for shorts.
profile picture

Eugene

#8
QUOTE:
and then the opposite 20 day donchian band.

When exactly "then"? Next time please be precise when describing your rules.

Switching from the initial ATR-based stop to the channel stop may be tricky for you. So here's the complete Strategy code, as I understood it:
CODE:
Please log in to see this code.

Here, when the bar's low exceeds the entry price (vice versa for shorts) the Strategy switches from the initial stop to the channel-based. I commented out the channels so you could notice the transition easily.
profile picture

Dramsey7

#9
thank you
profile picture

Dramsey7

#10
OK,i appreciate your help.it seems i wasnt very clear so i´ll start again. first of all i meant new strategy rather that a variation of the Dual donchian bands.

Buy signal: break of 20 day high donchian whilst 70 day SMA is rising.
initial stop loss: entry price - 3* ATR. Once the trade is in profit the lower 20 day donchian band is the stop.

Sell signal is the reverse of the above.

position size : a % of initial equity (2% is an example)

i would like to be able to optimise the strategy as well to see if other donchian bands and MA lengths work better

i apologise for my lack of clarity in the earlier post.

best regards

profile picture

Eugene

#11
QUOTE:
first of all i meant new strategy rather that a variation of the Dual donchian bands.

Oh man. On 9/12/2012 3:55 AM, didn't you ask for a variation, in the topic named Donchian? Nevermind, I replied there with new Strategy code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).