OPEN-SOURCE SCRIPT
DOUBLE SUPERTREND PYRAMID STRATEGY

Double Supertrend Pyramid Strategy
This strategy trades off two Supertrend indicators calculated on independent, user-selected timeframes (defaults: 1-minute and 2-minute). A trade is only taken when both Supertrends agree on direction — when they align upward, the strategy goes long; when they align downward, it goes short. Each new alignment is treated as a new "plotted course," and the strategy tracks that course's direction so it doesn't re-enter on every bar, only on an actual flip.
Core Entry Logic
Long/Short/Both direction control, so you can restrict the strategy to one side of the market if desired.
A session time-window filter (with a timezone dropdown covering major global zones) lets you restrict trading to specific hours, with an option to auto-close everything when the window ends.
On a Supertrend flip, the strategy normally waits until the position is completely flat before entering the new direction — it does not force-close open tiered or pyramid contracts just because the trend flipped. (See "Exit At Next Supertrend Plotted Course" below for the opt-in alternative.)
Tiered Exit System
Three independent, fully self-contained profit-scaling tiers (Tier 1/2/3), each with:
A profit target (ticks) and contract quantity to scale out at that target
An optional Stop Loss, and an optional Trailing Stop with a separate activation threshold (ticks, own enable checkbox)
An "Exit At Next Supertrend Plotted Course" checkbox — when checked, that tier's contracts are force-closed the moment the trend flips; when unchecked (default), the tier runs entirely on its own Target/Stop/Trailing settings regardless of what the trend does next.
Pyramid Add-On System
Eight independent pyramid types can each be enabled separately to add contracts in the direction of an existing position when their own specific condition fires:
Turtle ATR Unit — adds every time price moves a set fraction of ATR in your favor from the last fill.
Swing Structure — adds on a new confirmed swing high/low in the trend direction.
Momentum Re-confirmation — adds when ADX is rising with DI+/DI- agreement and RSI holds past a threshold.
Breakout / Consolidation — adds on a fresh Donchian channel breakout.
Multi-Timeframe Alignment — adds only when a higher-timeframe EMA filter agrees with the trade direction.
Error-Function One-Tailed Test — adds when the current bar's move is statistically significant versus its recent return distribution (Normal or Student-T approximation).
KDE Percentile — adds when the current move ranks in the top percentile of a non-parametric kernel-density estimate of recent returns.
Viterbi Regime Detection — adds only while a 2-state Hidden Markov Model infers the market is in a "trending" (versus "ranging") regime.
Each pyramid type is fully self-contained: its own contracts-per-signal size, its own optional TP/SL/Trailing Stop, its own per-course contract and signal caps, a delay-between-signals timer, a minimum-distance-before-next-add gate (selectable as ATR multiple, percent, ticks, points, or dollars), and its own "Exit At Next Supertrend Plotted Course" checkbox. All types default to fully disabled.
Global Risk Controls (always active, override everything)
Max contracts per trade (position size cap across core + pyramid adds)
Master daily $ take-profit and $ max-loss halts
Volatility Exit — flattens everything if ATR expands beyond a multiple of its recent average
ATR Protective Stop — a catastrophic-loss stop measured off the position's average entry price
Reverse-At-Stop-Loss — an optional system that flips the core position to the opposite side when the per-course Stop Loss is hit, capped at a configurable number of reversals per course
This strategy trades off two Supertrend indicators calculated on independent, user-selected timeframes (defaults: 1-minute and 2-minute). A trade is only taken when both Supertrends agree on direction — when they align upward, the strategy goes long; when they align downward, it goes short. Each new alignment is treated as a new "plotted course," and the strategy tracks that course's direction so it doesn't re-enter on every bar, only on an actual flip.
Core Entry Logic
Long/Short/Both direction control, so you can restrict the strategy to one side of the market if desired.
A session time-window filter (with a timezone dropdown covering major global zones) lets you restrict trading to specific hours, with an option to auto-close everything when the window ends.
On a Supertrend flip, the strategy normally waits until the position is completely flat before entering the new direction — it does not force-close open tiered or pyramid contracts just because the trend flipped. (See "Exit At Next Supertrend Plotted Course" below for the opt-in alternative.)
Tiered Exit System
Three independent, fully self-contained profit-scaling tiers (Tier 1/2/3), each with:
A profit target (ticks) and contract quantity to scale out at that target
An optional Stop Loss, and an optional Trailing Stop with a separate activation threshold (ticks, own enable checkbox)
An "Exit At Next Supertrend Plotted Course" checkbox — when checked, that tier's contracts are force-closed the moment the trend flips; when unchecked (default), the tier runs entirely on its own Target/Stop/Trailing settings regardless of what the trend does next.
Pyramid Add-On System
Eight independent pyramid types can each be enabled separately to add contracts in the direction of an existing position when their own specific condition fires:
Turtle ATR Unit — adds every time price moves a set fraction of ATR in your favor from the last fill.
Swing Structure — adds on a new confirmed swing high/low in the trend direction.
Momentum Re-confirmation — adds when ADX is rising with DI+/DI- agreement and RSI holds past a threshold.
Breakout / Consolidation — adds on a fresh Donchian channel breakout.
Multi-Timeframe Alignment — adds only when a higher-timeframe EMA filter agrees with the trade direction.
Error-Function One-Tailed Test — adds when the current bar's move is statistically significant versus its recent return distribution (Normal or Student-T approximation).
KDE Percentile — adds when the current move ranks in the top percentile of a non-parametric kernel-density estimate of recent returns.
Viterbi Regime Detection — adds only while a 2-state Hidden Markov Model infers the market is in a "trending" (versus "ranging") regime.
Each pyramid type is fully self-contained: its own contracts-per-signal size, its own optional TP/SL/Trailing Stop, its own per-course contract and signal caps, a delay-between-signals timer, a minimum-distance-before-next-add gate (selectable as ATR multiple, percent, ticks, points, or dollars), and its own "Exit At Next Supertrend Plotted Course" checkbox. All types default to fully disabled.
Global Risk Controls (always active, override everything)
Max contracts per trade (position size cap across core + pyramid adds)
Master daily $ take-profit and $ max-loss halts
Volatility Exit — flattens everything if ATR expands beyond a multiple of its recent average
ATR Protective Stop — a catastrophic-loss stop measured off the position's average entry price
Reverse-At-Stop-Loss — an optional system that flips the core position to the opposite side when the per-course Stop Loss is hit, capped at a configurable number of reversals per course
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。