OPEN-SOURCE SCRIPT
Multi-Timeframe Supertrend Pro [algotim]

Overview
Multi-Timeframe Supertrend Consensus is a trend-analysis indicator designed to address a common problem with single-timeframe trend signals: a direction change on one chart timeframe does not necessarily represent a broader change in market direction.
Instead of treating one Supertrend state as the complete trend decision, the script evaluates up to three independently configured Supertrend calculations and converts their directional states into a single timeframe-consensus reading.
The purpose is to distinguish isolated timeframe changes from situations where multiple timeframe structures are aligned.
Problem Statement
A conventional Supertrend evaluates price direction from one timeframe. This can be useful for identifying local trends, but it can also produce direction changes that are not supported by the broader timeframe structure.
A trader may therefore see a bullish change on the chart timeframe while the higher timeframe remains bearish.
This script addresses that problem by separating trend detection into three layers:
1. Primary trend on the current chart timeframe.
2. Confirmation trend on an optional timeframe.
3. Higher-timeframe trend on a configurable timeframe.
The resulting directional states are evaluated together rather than interpreted independently.
Methodology
Each Supertrend calculation uses ATR-based bands derived from the selected ATR length and multiplier.
The calculation begins from the midpoint price (`HL2`) and determines upper and lower volatility-adjusted bands using ATR.
The Supertrend state then maintains directional continuity until price crosses the relevant previous band. A bullish state uses the upper calculated Supertrend line, while a bearish state uses the lower line.
The three calculations are independently parameterized, allowing the confirmation and higher-timeframe models to use different ATR lengths and factors from the primary model.
For non-current timeframes, the script requests the corresponding Supertrend state through `request.security()` using `barmerge.lookahead_off`. This prevents the requested timeframe from intentionally using future bars.
The important part of the architecture is what happens after these calculations: their directional states are counted and evaluated through a configurable consensus threshold.
Signal Workflow
The analytical workflow is:
1. Calculate the primary Supertrend using the current chart timeframe.
2. Calculate the optional confirmation Supertrend using the selected confirmation timeframe.
3. Calculate the higher-timeframe Supertrend using the configured higher timeframe.
4. Determine whether each Supertrend is bullish or bearish.
5. Count the number of aligned bullish and bearish timeframe states.
6. Compare that alignment against the user-defined consensus threshold.
7. Issue the corresponding consensus trend state when sufficient timeframe agreement exists.
8. Display the individual Supertrend lines and the consensus information so the trader can see both the underlying states and the resulting agreement.
The consensus threshold controls how selective the framework is. A lower threshold allows a signal with less agreement, while requiring all three timeframes produces the strictest alignment condition.
Why This Indicator Is Different
The primary purpose of this script is not to provide three separate Supertrend lines.
Its purpose is to convert multiple Supertrend states into a **single timeframe-agreement framework**.
A conventional Supertrend answers:
> "What is the trend according to this timeframe?"
This script adds another question:
> "How many of the monitored timeframes agree with that direction?"
This distinction is useful when a trader wants to separate local trend changes from broader directional alignment.
The confirmation and higher-timeframe calculations are also independently configurable rather than being simple copies of the primary settings. This allows the user to make the faster timeframe more responsive while keeping the broader timeframe more selective.
The resulting workflow can therefore be viewed as:
**Local trend -> Confirmation trend -> Higher-timeframe trend -> Agreement calculation -> Consensus state**
This is the central analytical contribution of the script.
Inputs
Primary Supertrend
Controls the Supertrend calculated directly on the chart timeframe.
* ATR Length
* Factor
Confirmation Supertrend
Controls the optional second timeframe calculation.
* Timeframe
* ATR Length
* Factor
Leaving the timeframe blank uses the primary chart-timeframe calculation.
Higher-Timeframe Supertrend
Controls the broader trend reference.
* Timeframe
* ATR Length
* Factor
Consensus Engine
Controls how much timeframe agreement is required.
* Minimum Timeframes Needed for Signal
* Confidence Shading
A threshold of 3 requires all three monitored states to agree and therefore provides stricter filtering than a threshold of 2.
Visual Settings
The script provides independent visibility controls for:
* Primary Supertrend line
* Confirmation Supertrend line
* Higher-timeframe Supertrend line
* Consensus entry signals
Bullish and bearish colors can also be customized.
Alerts
The script provides alert functionality for its consensus-based trend events.
Alerts should be configured from the indicator's available TradingView alert conditions/functions after adding the script to a chart.
Practical Usage
A practical workflow is to use the primary Supertrend to observe the local market direction while using the confirmation and higher-timeframe calculations to determine whether that direction is supported by broader timeframe structure.
For example, requiring two of three timeframes to agree can provide a moderate filtering level. Requiring three of three creates a stricter consensus condition and may result in fewer signals.
The individual lines should remain visible while evaluating the indicator so that the trader can see why a consensus state was produced rather than treating the consensus output as a standalone trading decision.
The indicator can be used for trend filtering, directional analysis, and identifying periods of stronger multi-timeframe alignment.
Limitations
Supertrend remains a reactive, volatility-based trend-following calculation. It does not predict future price movement.
Because the methodology depends on ATR and price crossings, rapid volatility changes can produce direction changes or conflicting timeframe states.
Higher-timeframe values also update according to the availability of confirmed data from their respective timeframe. Signals should therefore be evaluated with awareness of the timeframe relationship.
A consensus state indicates agreement between the configured Supertrend calculations; it does not guarantee continuation of the resulting trend.
The indicator is an analytical tool and should not be treated as a standalone trading system or a guarantee of future performance.
Notes
The script is designed to make multi-timeframe Supertrend agreement visible within one analytical framework.
Its main distinction from a conventional single-timeframe Supertrend is the explicit consensus layer that evaluates the directional state of multiple independently configured timeframe calculations.
Users should select timeframe and ATR parameters appropriate to the instrument and timeframe being analyzed and validate the resulting signals with their own market analysis and risk-management process.
Multi-Timeframe Supertrend Consensus is a trend-analysis indicator designed to address a common problem with single-timeframe trend signals: a direction change on one chart timeframe does not necessarily represent a broader change in market direction.
Instead of treating one Supertrend state as the complete trend decision, the script evaluates up to three independently configured Supertrend calculations and converts their directional states into a single timeframe-consensus reading.
The purpose is to distinguish isolated timeframe changes from situations where multiple timeframe structures are aligned.
Problem Statement
A conventional Supertrend evaluates price direction from one timeframe. This can be useful for identifying local trends, but it can also produce direction changes that are not supported by the broader timeframe structure.
A trader may therefore see a bullish change on the chart timeframe while the higher timeframe remains bearish.
This script addresses that problem by separating trend detection into three layers:
1. Primary trend on the current chart timeframe.
2. Confirmation trend on an optional timeframe.
3. Higher-timeframe trend on a configurable timeframe.
The resulting directional states are evaluated together rather than interpreted independently.
Methodology
Each Supertrend calculation uses ATR-based bands derived from the selected ATR length and multiplier.
The calculation begins from the midpoint price (`HL2`) and determines upper and lower volatility-adjusted bands using ATR.
The Supertrend state then maintains directional continuity until price crosses the relevant previous band. A bullish state uses the upper calculated Supertrend line, while a bearish state uses the lower line.
The three calculations are independently parameterized, allowing the confirmation and higher-timeframe models to use different ATR lengths and factors from the primary model.
For non-current timeframes, the script requests the corresponding Supertrend state through `request.security()` using `barmerge.lookahead_off`. This prevents the requested timeframe from intentionally using future bars.
The important part of the architecture is what happens after these calculations: their directional states are counted and evaluated through a configurable consensus threshold.
Signal Workflow
The analytical workflow is:
1. Calculate the primary Supertrend using the current chart timeframe.
2. Calculate the optional confirmation Supertrend using the selected confirmation timeframe.
3. Calculate the higher-timeframe Supertrend using the configured higher timeframe.
4. Determine whether each Supertrend is bullish or bearish.
5. Count the number of aligned bullish and bearish timeframe states.
6. Compare that alignment against the user-defined consensus threshold.
7. Issue the corresponding consensus trend state when sufficient timeframe agreement exists.
8. Display the individual Supertrend lines and the consensus information so the trader can see both the underlying states and the resulting agreement.
The consensus threshold controls how selective the framework is. A lower threshold allows a signal with less agreement, while requiring all three timeframes produces the strictest alignment condition.
Why This Indicator Is Different
The primary purpose of this script is not to provide three separate Supertrend lines.
Its purpose is to convert multiple Supertrend states into a **single timeframe-agreement framework**.
A conventional Supertrend answers:
> "What is the trend according to this timeframe?"
This script adds another question:
> "How many of the monitored timeframes agree with that direction?"
This distinction is useful when a trader wants to separate local trend changes from broader directional alignment.
The confirmation and higher-timeframe calculations are also independently configurable rather than being simple copies of the primary settings. This allows the user to make the faster timeframe more responsive while keeping the broader timeframe more selective.
The resulting workflow can therefore be viewed as:
**Local trend -> Confirmation trend -> Higher-timeframe trend -> Agreement calculation -> Consensus state**
This is the central analytical contribution of the script.
Inputs
Primary Supertrend
Controls the Supertrend calculated directly on the chart timeframe.
* ATR Length
* Factor
Confirmation Supertrend
Controls the optional second timeframe calculation.
* Timeframe
* ATR Length
* Factor
Leaving the timeframe blank uses the primary chart-timeframe calculation.
Higher-Timeframe Supertrend
Controls the broader trend reference.
* Timeframe
* ATR Length
* Factor
Consensus Engine
Controls how much timeframe agreement is required.
* Minimum Timeframes Needed for Signal
* Confidence Shading
A threshold of 3 requires all three monitored states to agree and therefore provides stricter filtering than a threshold of 2.
Visual Settings
The script provides independent visibility controls for:
* Primary Supertrend line
* Confirmation Supertrend line
* Higher-timeframe Supertrend line
* Consensus entry signals
Bullish and bearish colors can also be customized.
Alerts
The script provides alert functionality for its consensus-based trend events.
Alerts should be configured from the indicator's available TradingView alert conditions/functions after adding the script to a chart.
Practical Usage
A practical workflow is to use the primary Supertrend to observe the local market direction while using the confirmation and higher-timeframe calculations to determine whether that direction is supported by broader timeframe structure.
For example, requiring two of three timeframes to agree can provide a moderate filtering level. Requiring three of three creates a stricter consensus condition and may result in fewer signals.
The individual lines should remain visible while evaluating the indicator so that the trader can see why a consensus state was produced rather than treating the consensus output as a standalone trading decision.
The indicator can be used for trend filtering, directional analysis, and identifying periods of stronger multi-timeframe alignment.
Limitations
Supertrend remains a reactive, volatility-based trend-following calculation. It does not predict future price movement.
Because the methodology depends on ATR and price crossings, rapid volatility changes can produce direction changes or conflicting timeframe states.
Higher-timeframe values also update according to the availability of confirmed data from their respective timeframe. Signals should therefore be evaluated with awareness of the timeframe relationship.
A consensus state indicates agreement between the configured Supertrend calculations; it does not guarantee continuation of the resulting trend.
The indicator is an analytical tool and should not be treated as a standalone trading system or a guarantee of future performance.
Notes
The script is designed to make multi-timeframe Supertrend agreement visible within one analytical framework.
Its main distinction from a conventional single-timeframe Supertrend is the explicit consensus layer that evaluates the directional state of multiple independently configured timeframe calculations.
Users should select timeframe and ATR parameters appropriate to the instrument and timeframe being analyzed and validate the resulting signals with their own market analysis and risk-management process.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Build your trading tools with AI : algotim.com
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
Disclaimer
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Build your trading tools with AI : algotim.com
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
All content provided by AlgoTim (algo_aakash) is for informational and educational purposes only. Trading involves risk, and past performance does not guarantee future results.
Disclaimer
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.