Donchian Breakout Strategy

This strategy buys when the Donchian Channel is broken to the upside and uses the lower Donchian Channel line as a trailing stop. You can also choose to use a moving average as a filter to keep you out of trades that are counter trend.

You can also configure which dates you want to backtest, so you can see how this behaves over specific time frames and market cycles.
Versionshinweise: Added the ability to select different lookback periods for upper and lower bands. Results seem to be better with higher numbers for the upper band and lower numbers (tighter stops) for the lower band.
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?


Hi this is fantastic! Thanks for putting this up!

Is there a way I can change the entry criteria to trigger an entry when the RSI crosses above 60? But the trailing conditions maintained as yours? Tried all day but keep getting errors because I have totally zero knowledge in scripting. Would appreciate heaps if you can help me! Turning desperate with all the losses the past weeks, so sad.

length = input(14, title="RSI length")
ob = input(60, title="Overbought level")

rsi = rsi(close, length)

buy = rsi > ob
millerrh Richkierich
@Richkierich, yes you would just put those lines of code in that you have there and change

buySignal = trigResistance >= dcUpper


buySignal = rsi > ob
Richkierich millerrh
@millerrh, dude thanks much! respect!
millerrh arose033
@arose033, It does not look into the future, so that's not the case. but it will trigger/change on the current candle as it changes.
+1 Antworten
Hi Millerrh - sorry to trouble - quick one - the D Channel lines are showing but not the signals for 'long' and 'close entry' as shown on your example chart. Are those supposed to be there with the script, or you added to the example above for illustration?
Many thanks!
@HKTOM, They should be showing. These are the default buy/sell markers provided by TradingView within their strategy scripts whenever the conditions are met. I bet what is happening is that whatever your settings are isn't actually triggering any trades. Look in the "List of Trades" section of the "Strategy Tester" tab at the bottom. Do you see any trades there? if not, that is what is going on.

This strategy only buys when the upper channel is broken. Do you see any instances on your chart where the price goes above that upper channel? If so, one of these buy arrows should appear. If price action is contained within the channel, then you are not triggering any trades.
HKTOM millerrh
@millerrh, Thanks for responding - yes I can see spots where the price goes above. But no arrows on chart, and no trades showing up in the strategy tester...any ideas/ suggestions on settings ? Many thanks!
@HKTOM, Trades are not triggering for some reason. I have built in a number of optional filters in the settings, so my guess is that it is something about those filters being active. Check out the date ranges filter and the ignoring trades under the SMA filter and make sure you're not operating outside of those filters.
Hey Millerrh, I agree with Jordan, can you make this work for taking shorts as well? I'd like to use it on forex and crypto markets. Thank you! Great script!