OPEN-SOURCE SCRIPT
TrendLock | Multi-Timeframe Supertrend Donchian Breakout

Strategy Explanation
TrendLock combines three independent confirmations before it will ever open a trade: a primary Supertrend for local trend direction, a higher-timeframe Supertrend that must agree before entries are allowed, and a Donchian channel breakout that times the actual entry once both trend layers align. A volume-spike filter adds a final check that real participation is behind the move, not just drift.
The idea is simple: most Supertrend scripts fire on every local flip and get chopped up in ranges. TrendLock only engages when the bigger picture and the immediate price action are both pointing the same way, and only pulls the trigger on a genuine breakout — not just a trend-line touch.
Exits are ATR-based (stop and target sized off current volatility, not fixed percentages), with an optional early exit if the primary Supertrend flips against the position.
Features
Tips
Warnings
TrendLock combines three independent confirmations before it will ever open a trade: a primary Supertrend for local trend direction, a higher-timeframe Supertrend that must agree before entries are allowed, and a Donchian channel breakout that times the actual entry once both trend layers align. A volume-spike filter adds a final check that real participation is behind the move, not just drift.
The idea is simple: most Supertrend scripts fire on every local flip and get chopped up in ranges. TrendLock only engages when the bigger picture and the immediate price action are both pointing the same way, and only pulls the trigger on a genuine breakout — not just a trend-line touch.
Exits are ATR-based (stop and target sized off current volatility, not fixed percentages), with an optional early exit if the primary Supertrend flips against the position.
Features
- Dual-timeframe Supertrend agreement filter (toggle on/off)
- Donchian channel breakout entry trigger, plotted with a shaded channel
- Volume-spike confirmation filter
- ATR-based stop loss and take profit
- Optional trend-flip exit independent of the stop/target
- Long-only, short-only, or both-direction modes
- Background tint shows HTF/LTF agreement at a glance
- Built-in alert conditions for long and short signals
Tips
- Pick an HTF meaningfully above your trading timeframe (e.g. 15m chart → 4H filter, 1H chart → 1D filter). Too close and the filter does nothing; too far and setups become rare.
- Test the HTF filter on and off separately — it should reduce trade count and whipsaws, not just trade count.
- Donchian lookback and ATR lengths interact: a longer Donchian window means fewer, larger breakouts, so widen your ATR stop/target multipliers accordingly.
- Try disabling the volume filter on lower-liquidity assets, where volume data can be noisy or unreliable.
- Backtest across several unrelated symbols and timeframes using the same input values — if it only works on one chart, the settings are likely overfit rather than a real edge.
Warnings
- This is a backtesting and research tool, not financial advice — past performance in the Strategy Tester does not predict future results.
- request.security calls for the HTF Supertrend can behave differently between the visible chart and actual live execution; always forward-test on a paper account before risking real capital.
- Breakout strategies are prone to false starts in choppy markets even with trend filters — expect a real losing-streak tail in the backtest, not just the equity curve's best stretch.
- Commission, slippage, and order-fill assumptions in the Strategy Tester are approximations; verify against your actual broker/exchange fee schedule before sizing a live position.
- The HTF filter and volume filter are optional and default to specific settings — review every input before deploying, don't assume the defaults suit your instrument or timeframe.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.