OPEN-SOURCE SCRIPT
Larry Williams Donchian Breakout Strategy

This strategy is based on a breakout of the Donchian Channel with customizable risk-reward parameters and optional entry filters. It combines visual elements from the Donchian Channel indicator with a fully executable trading logic.
How entries are generated
A long trade is opened when the chosen signal price (either bar’s High or Close) closes above the upper Donchian Channel on each of the three previous bars.
A short trade is opened when the chosen signal price (either bar’s Low or Close) closes below the lower Donchian Channel on each of the three previous bars.
Both long and short signals can be configured to use either High/Low or Close values for confirmation.
Stop Loss and Take Profit
The Stop Loss is automatically placed relative to the Donchian middle line with a user-defined offset.
The Take Profit is calculated using a Risk/Reward multiplier.
Separate risk-reward ratios can be set for long and short positions.
Visual elements
The Donchian Channel (upper, lower, and middle bands) is plotted on the chart.
High-High, Higher-Low, Lower-High, and Lower-Low markers are displayed when pivot conditions are met.
Each trade is visualized with three horizontal lines drawn for a limited number of recent trades:
Entry (blue)
Stop Loss (red)
Take Profit (green)
To keep the chart clean, only the last ten trades (30 lines in total) remain visible.
Entry filters
Two optional filters are included and can be enabled or disabled independently:
LWTI filter – Long trades are only allowed when the Larry Williams Trade Index is green, and short trades are only allowed when the index is red.
Volume filter – Trades are only allowed when the current volume is above its 30-period SMA.
Use case
The strategy is designed to test Donchian Channel breakout conditions with risk management and simple filters. It can serve as a foundation for further development, allowing traders to experiment with additional filters or money management rules.
Disclaimer
This strategy is for educational and research purposes only. It is not financial advice. Always test thoroughly before using any strategy in live trading, and make trading decisions at your own risk.
How entries are generated
A long trade is opened when the chosen signal price (either bar’s High or Close) closes above the upper Donchian Channel on each of the three previous bars.
A short trade is opened when the chosen signal price (either bar’s Low or Close) closes below the lower Donchian Channel on each of the three previous bars.
Both long and short signals can be configured to use either High/Low or Close values for confirmation.
Stop Loss and Take Profit
The Stop Loss is automatically placed relative to the Donchian middle line with a user-defined offset.
The Take Profit is calculated using a Risk/Reward multiplier.
Separate risk-reward ratios can be set for long and short positions.
Visual elements
The Donchian Channel (upper, lower, and middle bands) is plotted on the chart.
High-High, Higher-Low, Lower-High, and Lower-Low markers are displayed when pivot conditions are met.
Each trade is visualized with three horizontal lines drawn for a limited number of recent trades:
Entry (blue)
Stop Loss (red)
Take Profit (green)
To keep the chart clean, only the last ten trades (30 lines in total) remain visible.
Entry filters
Two optional filters are included and can be enabled or disabled independently:
LWTI filter – Long trades are only allowed when the Larry Williams Trade Index is green, and short trades are only allowed when the index is red.
Volume filter – Trades are only allowed when the current volume is above its 30-period SMA.
Use case
The strategy is designed to test Donchian Channel breakout conditions with risk management and simple filters. It can serve as a foundation for further development, allowing traders to experiment with additional filters or money management rules.
Disclaimer
This strategy is for educational and research purposes only. It is not financial advice. Always test thoroughly before using any strategy in live trading, and make trading decisions at your own risk.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.