Overview The Donchian Breakout Strategy is a trend-following system that identifies potential long trade opportunities based on price breakouts from a specified range (Donchian Channel). This script enhances the traditional Donchian breakout strategy by adding an optional volume filter and integrating the Supertrend indicator for additional confirmation.
This indicator is particularly effective on daily or weekly charts of indices like Nifty and BankNifty, but it can also be used on other instruments with strong trending characteristics.
Key Features Donchian Channel:
Calculates the highest high and lowest low over a user-defined period. Provides visual cues for price breakouts (upper band) and breakdowns (lower band). Optional Volume Filter:
Filters buy signals by requiring volume to exceed its 20-period moving average (enabled/disabled via a toggle). Supertrend Indicator:
Confirms the trend direction. Plots a green line for bullish trends and a red line for bearish trends. Configurable Exit Options:
Multiple exit strategies, including lower Donchian band, mid-band (basis line), or Supertrend. Trailing stop-loss option to lock in profits. Backtest Date Range:
Specify the start and end dates for backtesting the strategy. Inputs and Settings 1. Donchian Channel Length: The number of bars used to calculate the highest high and lowest low (default: 21). 2. Volume Filter Enable Volume Filter: Toggles the volume filter on or off. When enabled, long entries require the volume to exceed its 20-period moving average. 3. Supertrend Multiplier: Adjusts the sensitivity of the Supertrend indicator (default: 1). Length: Defines the period for the Supertrend calculation (default: 10). 4. Exit Options Exit Option: Option 1: Exit when the price crosses below the lower Donchian band. Option 2: Exit when the price crosses below the mid-band (basis line). Option 3: Exit when the price crosses below the Supertrend line. Option 4: Use a trailing stop-loss (default percentage: 3%). 5. Backtesting Range Start/End Date: Define the period for backtesting trades. Entries and exits will only occur within this range. How to Use Step 1: Add the Indicator Apply this script to your TradingView chart. Use it on instruments with strong trending characteristics, such as indices or trending stocks. Step 2: Configure Inputs Adjust the Donchian length based on your preferred timeframe and market conditions (e.g., 21 for daily, 52 for weekly charts). Toggle the volume filter to filter false signals during low-volume periods. Customize the Supertrend multiplier and length to align with your risk tolerance. Step 3: Interpret Signals Long Entry: Triggered when the price closes above the upper Donchian band. (Optional) Volume must exceed its 20-period moving average if the filter is enabled. Exit: Select an exit strategy that matches your trading style: Trend-following: Use the Supertrend line. Range-bound: Use the lower Donchian band or mid-band. Example Usage Scenarios Trending Markets:
Apply on indices like Nifty or BankNifty with daily/weekly timeframes. Enable the volume filter to confirm strong breakouts. Use the Supertrend for trend direction and trailing stops. Swing Trading:
Use shorter Donchian lengths (e.g., 10) to capture smaller price movements. Disable the volume filter for highly liquid instruments. Best Practices Combine with higher timeframes (e.g., weekly chart) for trend confirmation. Use the Supertrend indicator to stay in trades during trending markets. Backtest with various settings to identify optimal parameters for your preferred instruments. Warnings This strategy works best in trending markets; performance may degrade in choppy or range-bound conditions. The volume filter might reduce the number of signals, which could limit opportunities in low-volume instruments. Always combine this indicator with proper risk management practices. Visualization Donchian Channel:
Upper band: Represents breakout levels. Lower band: Represents breakdown levels. Mid-band (orange): Average of the upper and lower bands. Supertrend:
Green line: Bullish trend. Red line: Bearish trend. Volume Filter:
Ensure volume exceeds the 20-period moving average for valid long entries (when enabled).
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
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.