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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。