OPEN-SOURCE SCRIPT
Multi-Timeframe SMT

Summery
The Multi-Timeframe SMT indicator is designed to identify and visualize Higher Timeframe (HTF) data on a Lower Timeframe (LTF) chart, allowing traders to see the broader market context without changing their current chart's resolution. It accurately draws pivots and SMT divergences from higher timeframes on the corresponding candles of your current lower timeframe chart.
Its core features include:
Multi-Timeframe Analysis: Configure and monitor pivots on up to four independent timeframes, from intraday to monthly.
Customizable Pivot Detection: Define the strength of pivots by adjusting the number of bars to the left and right.
SMT Divergence: Automatically identifies bullish and bearish SMT divergences by comparing the price action of the main chart symbol with a chosen correlated asset.
Early SMT Detection: A unique feature that monitors a lower "detection timeframe" to provide early warnings of potential SMT setups before they're confirmed on the main timeframe. Note that this early detection is only shown on timeframes equal to or lower than the "Detection timeframe" you have set.
Visual Cues & Alerts: Clear on-chart labels, lines, and fully customizable alerts notify you of confirmed pivots and SMT divergences, ensuring you don't miss key opportunities.
Important Nuance Regarding Pivot Label Display
Due to a self-imposed limit within this script's drawing management logic, the indicator might quickly reach its drawing capacity if you enable pivot crosses for multiple timeframes simultaneously. When this internal drawing limit is exceeded, the script is designed to automatically remove the oldest drawings to make space for new ones.
Therefore, to ensure optimal performance and visibility of the most recent and relevant pivots, it's highly recommended to only enable the "Show Pivot Crosses" option for one timeframe at a time. If you wish to view pivots for a different timeframe, simply disable the pivot crosses for the currently active timeframe and then enable them for your desired one. This approach prevents the rapid cycling and disappearance of pivot labels, providing a clearer and more stable visual experience.
In-Depth Explanation of the Logic
This script is built on two primary concepts: pivot points and Smart Money Technique (SMT) divergence. It systematically collects historical data on multiple timeframes, identifies pivots, and then compares them between two assets to find divergences.
Pivot Point Identification
A pivot is a turning point in the market. A pivot high is a candle that has a higher high than the candles to its immediate left and right. Conversely, a pivot low is a candle with a lower low than its neighbors.
How it Works in the Script:
The script tracks the highest high and lowest low for each period of the selected timeframe (e.g., for each 4-hour candle). When a new high-timeframe candle closes, it stores that high/low value and its bar index in an array. The checkForPivot() function then checks if a recently stored high or low qualifies as a pivot.
Key Inputs:
Left Strength (leftBars1): The number of candles to the left that must have a lower high (for a pivot high) or higher low (for a pivot low).
Right Strength (rightBars1): The number of candles to the right that must meet the same criteria.
For example, with Left Strength and Right Strength both set to 3, a pivot high is only confirmed when its high is greater than the highs of the 3 previous high-timeframe candles and the 3 subsequent high-timeframe candles. Increasing these values will identify more significant, longer-term pivots.
Smart Money Technique (SMT) Divergence
SMT Divergence is a concept popularized by The Inner Circle Trader (ICT). It occurs when two closely correlated assets fail to move in sync. For instance, if Asset A makes a higher high but Asset B fails to do so and instead makes a lower high, this creates a bearish SMT divergence. It suggests that the "smart money" may not be supporting the move in Asset A, signaling a potential reversal.
Bearish SMT: Main asset makes a higher high, while the correlated asset makes a lower high. This is a potential sell signal.
Bullish SMT: Main asset makes a lower low, while the correlated asset makes a higher low. This is a potential buy signal.
How it Works in the Script:
Data Request: For each timeframe, the script uses the request.security() function to fetch the high and low data for both the main chart symbol (syminfo.tickerid) and the chosen Comparison Asset.
Pivot Comparison: When a new pivot is confirmed on the main asset, the script checks if a corresponding pivot also formed on the comparison asset at the same time.
Divergence Check: It then compares the direction of the pivots. For a bearish SMT, it checks if the main asset's new pivot high is higher than its previous pivot high, while the comparison asset's new pivot high is lower than its previous one. The logic is reversed for bullish SMT.
Visualization: If a divergence is found, the script draws a red (bearish) or green (bullish) line connecting the two pivots on your chart and places an "SMT" label.
Early SMT Detection
This is a proactive feature designed to give you a heads-up. Waiting for a 4-hour or daily pivot to form can take a long time. The early detection system looks for SMT divergences on a much smaller, user-defined Detection timeframe (e.g., 15-minute).
How it Works in the Script:
Awaiting Setup: After a primary pivot (Pivot A) is formed on the main timeframe (e.g., a Daily pivot high), the script begins monitoring.
Intraday Monitoring: It then watches the Detection timeframe (e.g., 15-minute) for smaller intraday pivots.
Potential Divergence: It looks for an intraday pivot that forms a divergence against the primary Pivot A.
Watchline & Alert: When this "potential" divergence occurs, the script draws a dashed white line and triggers a "Potential SMT" alert. This isn't a confirmed SMT on the main timeframe yet, but it's a powerful early warning that one may be forming.
Drawing & Object Management
To keep the chart clean and prevent performance issues, the script manages its drawings (lines and labels) efficiently. It stores them in arrays and uses a drawing limit to automatically delete the oldest drawings as new ones are created, ensuring your TradingView remains responsive.
How to Use the Indicator
Configuration
Enable Timeframes: Use the checkboxes (Enable Timeframe 1, Enable Timeframe 2, etc.) to activate the timeframes you want to monitor. It's often best to start with one or two to keep the chart clean.
Select Timeframes: Choose the higher timeframes you want to analyze (e.g., 240 for 4-hour, D for Daily, W for Weekly).
Set Pivot Strength: The default of 3 for Left/Right strength is a good starting point. Increase it to find more significant market structure points or decrease it for more frequent, shorter-term pivots.
Configure SMT:
Check Enable SMT for the timeframes where you want to detect divergence.
Enter a Comparison Asset. This is crucial. Ensure the assets are correlated.
To use the early warning system, check Enable early SMT detection and select an appropriate Detection timeframe (e.g., 15 or 60 minutes for a Daily analysis).
The Multi-Timeframe SMT indicator is designed to identify and visualize Higher Timeframe (HTF) data on a Lower Timeframe (LTF) chart, allowing traders to see the broader market context without changing their current chart's resolution. It accurately draws pivots and SMT divergences from higher timeframes on the corresponding candles of your current lower timeframe chart.
Its core features include:
Multi-Timeframe Analysis: Configure and monitor pivots on up to four independent timeframes, from intraday to monthly.
Customizable Pivot Detection: Define the strength of pivots by adjusting the number of bars to the left and right.
SMT Divergence: Automatically identifies bullish and bearish SMT divergences by comparing the price action of the main chart symbol with a chosen correlated asset.
Early SMT Detection: A unique feature that monitors a lower "detection timeframe" to provide early warnings of potential SMT setups before they're confirmed on the main timeframe. Note that this early detection is only shown on timeframes equal to or lower than the "Detection timeframe" you have set.
Visual Cues & Alerts: Clear on-chart labels, lines, and fully customizable alerts notify you of confirmed pivots and SMT divergences, ensuring you don't miss key opportunities.
Important Nuance Regarding Pivot Label Display
Due to a self-imposed limit within this script's drawing management logic, the indicator might quickly reach its drawing capacity if you enable pivot crosses for multiple timeframes simultaneously. When this internal drawing limit is exceeded, the script is designed to automatically remove the oldest drawings to make space for new ones.
Therefore, to ensure optimal performance and visibility of the most recent and relevant pivots, it's highly recommended to only enable the "Show Pivot Crosses" option for one timeframe at a time. If you wish to view pivots for a different timeframe, simply disable the pivot crosses for the currently active timeframe and then enable them for your desired one. This approach prevents the rapid cycling and disappearance of pivot labels, providing a clearer and more stable visual experience.
In-Depth Explanation of the Logic
This script is built on two primary concepts: pivot points and Smart Money Technique (SMT) divergence. It systematically collects historical data on multiple timeframes, identifies pivots, and then compares them between two assets to find divergences.
Pivot Point Identification
A pivot is a turning point in the market. A pivot high is a candle that has a higher high than the candles to its immediate left and right. Conversely, a pivot low is a candle with a lower low than its neighbors.
How it Works in the Script:
The script tracks the highest high and lowest low for each period of the selected timeframe (e.g., for each 4-hour candle). When a new high-timeframe candle closes, it stores that high/low value and its bar index in an array. The checkForPivot() function then checks if a recently stored high or low qualifies as a pivot.
Key Inputs:
Left Strength (leftBars1): The number of candles to the left that must have a lower high (for a pivot high) or higher low (for a pivot low).
Right Strength (rightBars1): The number of candles to the right that must meet the same criteria.
For example, with Left Strength and Right Strength both set to 3, a pivot high is only confirmed when its high is greater than the highs of the 3 previous high-timeframe candles and the 3 subsequent high-timeframe candles. Increasing these values will identify more significant, longer-term pivots.
Smart Money Technique (SMT) Divergence
SMT Divergence is a concept popularized by The Inner Circle Trader (ICT). It occurs when two closely correlated assets fail to move in sync. For instance, if Asset A makes a higher high but Asset B fails to do so and instead makes a lower high, this creates a bearish SMT divergence. It suggests that the "smart money" may not be supporting the move in Asset A, signaling a potential reversal.
Bearish SMT: Main asset makes a higher high, while the correlated asset makes a lower high. This is a potential sell signal.
Bullish SMT: Main asset makes a lower low, while the correlated asset makes a higher low. This is a potential buy signal.
How it Works in the Script:
Data Request: For each timeframe, the script uses the request.security() function to fetch the high and low data for both the main chart symbol (syminfo.tickerid) and the chosen Comparison Asset.
Pivot Comparison: When a new pivot is confirmed on the main asset, the script checks if a corresponding pivot also formed on the comparison asset at the same time.
Divergence Check: It then compares the direction of the pivots. For a bearish SMT, it checks if the main asset's new pivot high is higher than its previous pivot high, while the comparison asset's new pivot high is lower than its previous one. The logic is reversed for bullish SMT.
Visualization: If a divergence is found, the script draws a red (bearish) or green (bullish) line connecting the two pivots on your chart and places an "SMT" label.
Early SMT Detection
This is a proactive feature designed to give you a heads-up. Waiting for a 4-hour or daily pivot to form can take a long time. The early detection system looks for SMT divergences on a much smaller, user-defined Detection timeframe (e.g., 15-minute).
How it Works in the Script:
Awaiting Setup: After a primary pivot (Pivot A) is formed on the main timeframe (e.g., a Daily pivot high), the script begins monitoring.
Intraday Monitoring: It then watches the Detection timeframe (e.g., 15-minute) for smaller intraday pivots.
Potential Divergence: It looks for an intraday pivot that forms a divergence against the primary Pivot A.
Watchline & Alert: When this "potential" divergence occurs, the script draws a dashed white line and triggers a "Potential SMT" alert. This isn't a confirmed SMT on the main timeframe yet, but it's a powerful early warning that one may be forming.
Drawing & Object Management
To keep the chart clean and prevent performance issues, the script manages its drawings (lines and labels) efficiently. It stores them in arrays and uses a drawing limit to automatically delete the oldest drawings as new ones are created, ensuring your TradingView remains responsive.
How to Use the Indicator
Configuration
Enable Timeframes: Use the checkboxes (Enable Timeframe 1, Enable Timeframe 2, etc.) to activate the timeframes you want to monitor. It's often best to start with one or two to keep the chart clean.
Select Timeframes: Choose the higher timeframes you want to analyze (e.g., 240 for 4-hour, D for Daily, W for Weekly).
Set Pivot Strength: The default of 3 for Left/Right strength is a good starting point. Increase it to find more significant market structure points or decrease it for more frequent, shorter-term pivots.
Configure SMT:
Check Enable SMT for the timeframes where you want to detect divergence.
Enter a Comparison Asset. This is crucial. Ensure the assets are correlated.
To use the early warning system, check Enable early SMT detection and select an appropriate Detection timeframe (e.g., 15 or 60 minutes for a Daily analysis).
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。