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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.