OPEN-SOURCE SCRIPT
Supertrend Transition Framework

Supertrend Transition Framework is not a basic Supertrend clone.
The Supertrend line is the visible base layer. The main contribution is a neutral transition layer that describes profile agreement, boundary distance, transition pressure, flip age, boundary touches, flip cascade context, and trail behavior.
This script is designed for traders who want a trend-direction reference from ATR-based trailing boundaries while also seeing context around boundary proximity, profile agreement, recent transitions, and trail behavior.
It is a context and visualization tool only. It does not provide trade-action instructions and it is not a trading system.
What it shows
- A manually calculated ATR-based Supertrend boundary.
- Optional fast, base, and slow Supertrend profiles.
- Profile agreement across enabled Supertrend profiles.
- Boundary distance measured in ATR units.
- Transition pressure based on proximity to the active boundary.
- Flip age for the base profile.
- Boundary touch context.
- Flip cascade context across profiles.
- Trail slope context.
- ATR input drift.
- A compact state fingerprint.
- A context table with Compact, Standard, and Detailed layouts.
- Optional capped event labels.
- Factual alert conditions.
Manual Supertrend profiles
The script calculates Supertrend profiles directly from current chart bars.
Each profile uses:
- ATR length
- ATR multiplier
- band source
- flip source
- enable switch
- optional line display
- visual settings
The default profiles are:
- Fast profile: ATR length 7, multiplier 2.0
- Base profile: ATR length 10, multiplier 3.0
- Slow profile: ATR length 21, multiplier 4.0
The base profile is the primary visible boundary by default. Fast and slow profile lines are available but are not shown by default to keep the chart clean.
The default inputs are common starting points. They are not optimized settings.
Profile Agreement
The script compares the valid Supertrend profile directions.
Agreement Score ranges from about -100 to +100:
- +100 means all valid profiles are upward.
- -100 means all valid profiles are downward.
- near 0 means profiles are mixed.
Agreement requires the base profile to be valid and at least two valid profiles to be available. A single valid profile is not treated as profile agreement.
Possible agreement states include:
- Need profiles
- Need base profile
- Warming up
- Need 2+ valid profiles
- Agreement upward
- Agreement downward
- Mixed profiles
Boundary Distance
The base Supertrend boundary is used as the active boundary.
The script calculates the distance from the selected price to the active boundary in ATR units.
This is shown as Boundary distance.
This field describes current distance only. It is not a risk model, projected level, or instruction.
Transition Pressure
Transition Pressure describes proximity to the active Supertrend boundary.
It is calculated from the distance to the boundary and the selected pressure ATR window.
A higher value means price is closer to the active boundary.
This does not tell users what will happen next. It only describes proximity to the active boundary.
Flip Age
Flip Age counts how many bars have passed since the base profile last changed direction.
This helps users see how long the current base structure has persisted.
Boundary Touch Context
A boundary touch is observed when price touches or approaches the active Supertrend boundary within the selected ATR tolerance.
The script tracks Boundary touch age.
The touch event is rising-edge based, so it does not repeatedly fire every bar while price stays near the boundary.
Flip Cascade Context
The script tracks whether fast, base, and slow profiles have recently changed into the same current base direction within the selected cascade lookback.
Cascade context can read as:
- No cascade
- Partial cascade
- Full cascade
- n/a
This is descriptive only.
Trail Slope Context
The script measures how the base Supertrend trail has changed over the selected trail slope lookback.
Trail slope context can read as:
- Rising trail
- Falling trail
- Flat trail
- n/a
ATR Input Drift
Because Supertrend uses ATR, the script includes a simple ATR input drift readout.
ATR input drift compares the current base ATR to a prior base ATR value over the selected lookback.
It can read as:
- ATR input rising
- ATR input falling
- ATR input steady
- n/a
This is not a volatility-regime classifier. It only describes how the ATR input used by the base profile has changed.
Transition State and Transition Context
The main State is direction and agreement focused.
Possible states include:
- Need profiles
- Need base profile
- Warming up
- Need 2+ valid profiles
- Upward agreement
- Downward agreement
- Upward base / mixed profiles
- Downward base / mixed profiles
- Mixed profiles
Transition Context is shown separately so that boundary proximity does not hide the direction/agreement state.
Transition Context can show:
- Boundary touched
- Cascade active
- Full cascade
- High boundary pressure
- Moderate boundary pressure
- Low boundary pressure
- n/a
State Fingerprint
The Fingerprint is a compact summary row for quick reading.
Example:
B+ A+ P34 C2 F18
Meaning:
- B+ means the base profile is upward.
- B- means the base profile is downward.
- B0 means the base profile is unavailable.
- A+ means upward profile agreement.
- A- means downward profile agreement.
- A0 means mixed or unavailable agreement.
- P shows boundary pressure.
- C shows cascade count.
- F shows base flip age.
The fingerprint is a compact context summary. It is not an instruction.
Context table
The context table is on by default.
Compact layout shows:
- State
- Fingerprint
- Transition context
- Base direction
- Agreement
- Boundary distance
- Flip age
Standard layout adds:
- Agreement score
- Boundary pressure
- Boundary distance ATR
- Cascade
- Trail slope
- Last boundary touch
- Alert mode
- Label mode
- Bar status
Detailed layout adds research fields, including:
- Fast direction
- Base direction
- Slow direction
- Enabled profiles
- Valid profiles
- Up / Down profile count
- Agreement ready
- Fast / Base / Slow readiness
- Fast / Base / Slow ATR
- Base trail
- Trail slope %
- ATR drift %
- Cascade count
- Pressure window
- Touch tolerance
- Cooldown state
- Last event age
- Label cap
- State ID
- Active settings
The context table is the primary research surface. The script does not add extra chart plots for these research fields.
Labels and alerts
Labels are optional and off by default.
Label modes:
- Off
- Base flips
- All events
Labels are capped by a user-defined maximum. Older labels are deleted after the cap is reached.
Labels are confirmed-bar visual records by default.
Alert mode and label mode are disclosed separately in the context table. Alerts are confirmed on close by default, and intrabar alert behavior can be enabled from the settings.
The final event engine is shared by alerts and labels. Event cooldown and one-event-per-bar behavior apply to final events.
Factual alert conditions include:
- Base Supertrend flipped upward
- Base Supertrend flipped downward
- Profiles reached upward agreement
- Profiles reached downward agreement
- Profiles became mixed
- Boundary pressure reached threshold
- Boundary touch observed
- Cascade context changed
Customization
Users can adjust:
- band source
- flip source
- confirmed-bar event mode
- automatic warm-up behavior
- fast/base/slow profile enable settings
- fast/base/slow ATR lengths
- fast/base/slow multipliers
- fast/base/slow line visibility
- fast/base/slow colors, widths, and transparency
- agreement threshold
- pressure ATR window
- high pressure threshold
- boundary touch tolerance
- cascade lookback
- trail slope lookback
- trail slope flat threshold
- ATR drift lookback
- ATR drift threshold
- minimum state bars for events
- event cooldown
- context table layout
- context table position
- table text size
- event label mode
- background tint
- label cap
- table colors
- label colors
- tint transparency
Visual settings do not affect calculations.
Plot-budget design
The script keeps chart plots minimal.
Only the fast, base, and slow Supertrend trails are plotted as lines.
Labels are used for optional event records instead of shape plots, and they are capped. No extra chart plots are used for research fields.
Different from other tools
This script does not use Keltner channels, session shading, volatility-regime classification, VWAP, volume weighting, RSI divergence, or moving-average structure analysis.
It focuses only on ATR-based Supertrend boundaries and their transition context.
Limitations
Supertrend is ATR-based and changes when ATR length, multiplier, or source settings change.
ATR-based boundaries lag price by design.
A profile agreement state can persist, unwind, or flip.
Boundary pressure does not tell users that a boundary change will occur.
A mixed profile state does not tell users that direction will change.
Defaults are starting points, not optimized settings.
The script describes current and recently observed structure. It is not financial advice and not a trading system.
Japanese notes
このスクリプトは通常のSupertrendライン表示だけではなく、Fast / Base / Slow の一致、境界までの距離、境界圧力、Flip age、Boundary touch、Cascade、Trail slope、ATR drift、Fingerprint、Context tableでSupertrendの転換文脈を可視化する補助ツールです。売買判断や将来の値動きを示すものではなく、現在のATRベース境界とその周辺状況を整理するためのツールです。
The Supertrend line is the visible base layer. The main contribution is a neutral transition layer that describes profile agreement, boundary distance, transition pressure, flip age, boundary touches, flip cascade context, and trail behavior.
This script is designed for traders who want a trend-direction reference from ATR-based trailing boundaries while also seeing context around boundary proximity, profile agreement, recent transitions, and trail behavior.
It is a context and visualization tool only. It does not provide trade-action instructions and it is not a trading system.
What it shows
- A manually calculated ATR-based Supertrend boundary.
- Optional fast, base, and slow Supertrend profiles.
- Profile agreement across enabled Supertrend profiles.
- Boundary distance measured in ATR units.
- Transition pressure based on proximity to the active boundary.
- Flip age for the base profile.
- Boundary touch context.
- Flip cascade context across profiles.
- Trail slope context.
- ATR input drift.
- A compact state fingerprint.
- A context table with Compact, Standard, and Detailed layouts.
- Optional capped event labels.
- Factual alert conditions.
Manual Supertrend profiles
The script calculates Supertrend profiles directly from current chart bars.
Each profile uses:
- ATR length
- ATR multiplier
- band source
- flip source
- enable switch
- optional line display
- visual settings
The default profiles are:
- Fast profile: ATR length 7, multiplier 2.0
- Base profile: ATR length 10, multiplier 3.0
- Slow profile: ATR length 21, multiplier 4.0
The base profile is the primary visible boundary by default. Fast and slow profile lines are available but are not shown by default to keep the chart clean.
The default inputs are common starting points. They are not optimized settings.
Profile Agreement
The script compares the valid Supertrend profile directions.
Agreement Score ranges from about -100 to +100:
- +100 means all valid profiles are upward.
- -100 means all valid profiles are downward.
- near 0 means profiles are mixed.
Agreement requires the base profile to be valid and at least two valid profiles to be available. A single valid profile is not treated as profile agreement.
Possible agreement states include:
- Need profiles
- Need base profile
- Warming up
- Need 2+ valid profiles
- Agreement upward
- Agreement downward
- Mixed profiles
Boundary Distance
The base Supertrend boundary is used as the active boundary.
The script calculates the distance from the selected price to the active boundary in ATR units.
This is shown as Boundary distance.
This field describes current distance only. It is not a risk model, projected level, or instruction.
Transition Pressure
Transition Pressure describes proximity to the active Supertrend boundary.
It is calculated from the distance to the boundary and the selected pressure ATR window.
A higher value means price is closer to the active boundary.
This does not tell users what will happen next. It only describes proximity to the active boundary.
Flip Age
Flip Age counts how many bars have passed since the base profile last changed direction.
This helps users see how long the current base structure has persisted.
Boundary Touch Context
A boundary touch is observed when price touches or approaches the active Supertrend boundary within the selected ATR tolerance.
The script tracks Boundary touch age.
The touch event is rising-edge based, so it does not repeatedly fire every bar while price stays near the boundary.
Flip Cascade Context
The script tracks whether fast, base, and slow profiles have recently changed into the same current base direction within the selected cascade lookback.
Cascade context can read as:
- No cascade
- Partial cascade
- Full cascade
- n/a
This is descriptive only.
Trail Slope Context
The script measures how the base Supertrend trail has changed over the selected trail slope lookback.
Trail slope context can read as:
- Rising trail
- Falling trail
- Flat trail
- n/a
ATR Input Drift
Because Supertrend uses ATR, the script includes a simple ATR input drift readout.
ATR input drift compares the current base ATR to a prior base ATR value over the selected lookback.
It can read as:
- ATR input rising
- ATR input falling
- ATR input steady
- n/a
This is not a volatility-regime classifier. It only describes how the ATR input used by the base profile has changed.
Transition State and Transition Context
The main State is direction and agreement focused.
Possible states include:
- Need profiles
- Need base profile
- Warming up
- Need 2+ valid profiles
- Upward agreement
- Downward agreement
- Upward base / mixed profiles
- Downward base / mixed profiles
- Mixed profiles
Transition Context is shown separately so that boundary proximity does not hide the direction/agreement state.
Transition Context can show:
- Boundary touched
- Cascade active
- Full cascade
- High boundary pressure
- Moderate boundary pressure
- Low boundary pressure
- n/a
State Fingerprint
The Fingerprint is a compact summary row for quick reading.
Example:
B+ A+ P34 C2 F18
Meaning:
- B+ means the base profile is upward.
- B- means the base profile is downward.
- B0 means the base profile is unavailable.
- A+ means upward profile agreement.
- A- means downward profile agreement.
- A0 means mixed or unavailable agreement.
- P shows boundary pressure.
- C shows cascade count.
- F shows base flip age.
The fingerprint is a compact context summary. It is not an instruction.
Context table
The context table is on by default.
Compact layout shows:
- State
- Fingerprint
- Transition context
- Base direction
- Agreement
- Boundary distance
- Flip age
Standard layout adds:
- Agreement score
- Boundary pressure
- Boundary distance ATR
- Cascade
- Trail slope
- Last boundary touch
- Alert mode
- Label mode
- Bar status
Detailed layout adds research fields, including:
- Fast direction
- Base direction
- Slow direction
- Enabled profiles
- Valid profiles
- Up / Down profile count
- Agreement ready
- Fast / Base / Slow readiness
- Fast / Base / Slow ATR
- Base trail
- Trail slope %
- ATR drift %
- Cascade count
- Pressure window
- Touch tolerance
- Cooldown state
- Last event age
- Label cap
- State ID
- Active settings
The context table is the primary research surface. The script does not add extra chart plots for these research fields.
Labels and alerts
Labels are optional and off by default.
Label modes:
- Off
- Base flips
- All events
Labels are capped by a user-defined maximum. Older labels are deleted after the cap is reached.
Labels are confirmed-bar visual records by default.
Alert mode and label mode are disclosed separately in the context table. Alerts are confirmed on close by default, and intrabar alert behavior can be enabled from the settings.
The final event engine is shared by alerts and labels. Event cooldown and one-event-per-bar behavior apply to final events.
Factual alert conditions include:
- Base Supertrend flipped upward
- Base Supertrend flipped downward
- Profiles reached upward agreement
- Profiles reached downward agreement
- Profiles became mixed
- Boundary pressure reached threshold
- Boundary touch observed
- Cascade context changed
Customization
Users can adjust:
- band source
- flip source
- confirmed-bar event mode
- automatic warm-up behavior
- fast/base/slow profile enable settings
- fast/base/slow ATR lengths
- fast/base/slow multipliers
- fast/base/slow line visibility
- fast/base/slow colors, widths, and transparency
- agreement threshold
- pressure ATR window
- high pressure threshold
- boundary touch tolerance
- cascade lookback
- trail slope lookback
- trail slope flat threshold
- ATR drift lookback
- ATR drift threshold
- minimum state bars for events
- event cooldown
- context table layout
- context table position
- table text size
- event label mode
- background tint
- label cap
- table colors
- label colors
- tint transparency
Visual settings do not affect calculations.
Plot-budget design
The script keeps chart plots minimal.
Only the fast, base, and slow Supertrend trails are plotted as lines.
Labels are used for optional event records instead of shape plots, and they are capped. No extra chart plots are used for research fields.
Different from other tools
This script does not use Keltner channels, session shading, volatility-regime classification, VWAP, volume weighting, RSI divergence, or moving-average structure analysis.
It focuses only on ATR-based Supertrend boundaries and their transition context.
Limitations
Supertrend is ATR-based and changes when ATR length, multiplier, or source settings change.
ATR-based boundaries lag price by design.
A profile agreement state can persist, unwind, or flip.
Boundary pressure does not tell users that a boundary change will occur.
A mixed profile state does not tell users that direction will change.
Defaults are starting points, not optimized settings.
The script describes current and recently observed structure. It is not financial advice and not a trading system.
Japanese notes
このスクリプトは通常のSupertrendライン表示だけではなく、Fast / Base / Slow の一致、境界までの距離、境界圧力、Flip age、Boundary touch、Cascade、Trail slope、ATR drift、Fingerprint、Context tableでSupertrendの転換文脈を可視化する補助ツールです。売買判断や将来の値動きを示すものではなく、現在のATRベース境界とその周辺状況を整理するためのツールです。
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.