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.
Phát hành các Ghi chú: 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.
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Bình luận

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
Phản hồi
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
Phản hồi
Richkierich millerrh
@millerrh, dude thanks much! respect!
Phản hồi
Phản hồi
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 Phản hồi
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!
Phản hồi
@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.
Phản hồi
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!
Phản hồi
@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.
Phản hồi
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!
Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Giới thiệu Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Xu Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Tin nhắn riêng Trò chuyện Đăng xuất