OPEN-SOURCE SCRIPT

Larry Williams Donchian Breakout Strategy

437
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.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.