OPEN-SOURCE SCRIPT
Updated MTF market analysis toolkit

The MTF Market Analysis Toolkit is a comprehensive trading tool designed to help traders visualise and analyse price action across multiple timeframes (MTF) directly on their current chart. It offers a robust set of features for understanding market trends, identifying key price levels, and detecting shifts in market structure, making it an essential tool for traders employing multi-timeframe analysis.
Core Functions
Multi-Timeframe Candle Display:
The toolkit overlays a set of candles representing a higher timeframe (e.g., 60-minute candles on a 5-minute chart) on the right side of the chart.
Traders can choose between standard candlesticks or Heikin Ashi candles, which smooth price data for clearer trend identification.
The candles are customisable in terms of size (small, medium, large), colour, and the number displayed (up to a user-defined limit).
Key Price Level Lines:
Lowest Low Line: Draws a horizontal line at the lowest price point of the displayed MTF candles, highlighting potential support levels.
Highest High Line: Marks the highest price point, indicating potential resistance levels.
Midpoint Line: Displays a line at the midpoint of the range between the highest high and lowest low, useful for identifying a balanced price level within the MTF range.
These lines are customisable in colour, style (solid, dotted, dashed), and width, and can be toggled on or off.
Timeframe Range Box:
A semi-transparent box highlights the price range of the MTF candles, either from the open to the midpoint of the previous candle or from the high to the low.
This box visually represents the MTF price range, helping traders assess volatility and key price zones.
OHLC Projections:
Horizontal lines project the Open, High, Low, and Close prices of the current MTF candle forward on the chart.
These lines can include labels showing the exact price values, aiding in quick reference for entry or exit points.
Users can adjust the projection length, line style, and colours, and toggle labels on or off.
Timeframe Separators:
Vertical lines mark the start of each new MTF candle, helping traders visualise transitions between MTF periods.
These lines are customisable in colour, style, and width.
Trend Table:
A table displays the trend direction (Bullish or Bearish) across five user-defined higher timeframes (e.g., 15-minute, 30-minute, 1-hour, 4-hour, daily).
The trend is calculated based on price movement relative to a smoothed average and volatility, providing a clear overview of market direction across multiple timeframes.
The table is customisable in position, text size, colours, and transparency, and can be toggled on or off.
CISD (Change in State of Delivery):
The toolkit identifies significant market structure changes, such as bullish or bearish pullbacks followed by breakouts.
It draws horizontal lines at key levels where the market structure shifts (e.g., a pullback high or low that is broken), labelling them as "+CISD" (bullish) or "-CISD" (bearish).
These levels act as potential support or resistance zones, and users can choose to keep old levels or display only the latest ones.
How to Use the MTF Market Analysis Toolkit
Access the settings to configure the following:
Timeframe: Select the higher timeframe for candle display (e.g., 60-minute) or enable automatic timeframe selection based on the chart’s timeframe.
Candle Settings: Choose the number of MTF candles to display, their size, type (standard or Heikin Ashi), and offset from the chart’s right edge.
Colours and Styles: Customise the colours, line styles, and widths for candles, lines, boxes, and projections.
Trend Table: Select the five timeframes for trend analysis and adjust the table’s appearance and position.
CISD Settings: Configure the pullback size filter, line styles, and whether to keep old CISD levels.
Interpreting the Display:
MTF Candles: Use the overlaid candles to assess price action on a higher timeframe without switching charts. Green candles indicate bullish movement, while red (or user-defined colours) indicate bearish movement.
Key Levels: Monitor the Lowest Low, Highest High, and Midpoint lines for potential support, resistance, or mean-reversion zones.
Range Box: The box highlights the MTF price range, helping you identify areas of consolidation or breakout potential.
OHLC Projections: Use the projected lines to track key price levels for the current MTF candle, useful for setting stop-losses, take-profits, or entry points.
Timeframe Separators: Vertical lines help you align trading decisions with the start of new MTF periods.
Trend Table: Check the table to understand the trend direction across multiple timeframes, aligning trades with the broader market context.
CISD Levels: Watch for "+CISD" or "-CISD" labels to identify significant market structure shifts. These levels can act as entry or exit points or zones to monitor for reversals.
Trading Applications:
Multi-Timeframe Analysis: Combine the MTF candle display and trend table to align trades with the higher timeframe trend, increasing the probability of success.
Support and Resistance: Use the Lowest Low, Highest High, and CISD levels to identify key price zones for entries, exits, or stop-loss placement.
Breakout Trading: Monitor CISD levels for breakouts, as these indicate a change in market structure, often leading to strong trending moves.
Trend Confirmation: The trend table helps confirm whether the market is bullish or bearish across multiple timeframes, aiding in trend-following strategies.
Range Trading: The Midpoint Line and Range Box can help identify mean-reversion opportunities within the MTF range.
Customisation Tips:
Adjust the candle size and offset to ensure MTF candles don’t clutter your chart.
Use distinct colours for bullish and bearish elements to enhance visual clarity.
Position the trend and CISD tables in a corner of the chart to avoid obstructing price action.
Experiment with the CISD pullback size filter to balance sensitivity and reliability, depending on the market’s volatility.
Additional Details for Users
Flexibility: The toolkit is highly customisable, allowing traders to tailor it to their specific trading style, whether they focus on trend-following, breakout, or range trading.
Visual Clarity: The use of boxes, lines, and tables ensures that complex MTF data is presented in an intuitive, easy-to-read format.
Timeframe Versatility: The automatic timeframe selection option adapts the MTF candles to the chart’s timeframe, making it suitable for both short-term and long-term traders.
Market Context: By combining MTF candles, trend analysis, and market structure detection, the toolkit provides a holistic view of the market, helping traders make informed decisions.
Conclusion
The MTF Market Analysis Toolkit aims to provide a simple, clear representation of current and higher time frame price action by displaying MTF candles, key price levels, trend directions, and market structure changes on a single chart. Its customisable settings and intuitive visual elements make it suitable for traders of all experience levels, particularly those who value a clear, data-rich view of the market.
Credit: I'd like to thank the following coders who published great scripts that helped enormously with this project
modhelius for the HTF code, which served as the basis for the candle drawings
BigBeluga for the HTF trend table which was adapted from the excellent zero-lag EMA indicator
neommxm for the CISD code which was modified slightly for use here
Core Functions
Multi-Timeframe Candle Display:
The toolkit overlays a set of candles representing a higher timeframe (e.g., 60-minute candles on a 5-minute chart) on the right side of the chart.
Traders can choose between standard candlesticks or Heikin Ashi candles, which smooth price data for clearer trend identification.
The candles are customisable in terms of size (small, medium, large), colour, and the number displayed (up to a user-defined limit).
Key Price Level Lines:
Lowest Low Line: Draws a horizontal line at the lowest price point of the displayed MTF candles, highlighting potential support levels.
Highest High Line: Marks the highest price point, indicating potential resistance levels.
Midpoint Line: Displays a line at the midpoint of the range between the highest high and lowest low, useful for identifying a balanced price level within the MTF range.
These lines are customisable in colour, style (solid, dotted, dashed), and width, and can be toggled on or off.
Timeframe Range Box:
A semi-transparent box highlights the price range of the MTF candles, either from the open to the midpoint of the previous candle or from the high to the low.
This box visually represents the MTF price range, helping traders assess volatility and key price zones.
OHLC Projections:
Horizontal lines project the Open, High, Low, and Close prices of the current MTF candle forward on the chart.
These lines can include labels showing the exact price values, aiding in quick reference for entry or exit points.
Users can adjust the projection length, line style, and colours, and toggle labels on or off.
Timeframe Separators:
Vertical lines mark the start of each new MTF candle, helping traders visualise transitions between MTF periods.
These lines are customisable in colour, style, and width.
Trend Table:
A table displays the trend direction (Bullish or Bearish) across five user-defined higher timeframes (e.g., 15-minute, 30-minute, 1-hour, 4-hour, daily).
The trend is calculated based on price movement relative to a smoothed average and volatility, providing a clear overview of market direction across multiple timeframes.
The table is customisable in position, text size, colours, and transparency, and can be toggled on or off.
CISD (Change in State of Delivery):
The toolkit identifies significant market structure changes, such as bullish or bearish pullbacks followed by breakouts.
It draws horizontal lines at key levels where the market structure shifts (e.g., a pullback high or low that is broken), labelling them as "+CISD" (bullish) or "-CISD" (bearish).
These levels act as potential support or resistance zones, and users can choose to keep old levels or display only the latest ones.
How to Use the MTF Market Analysis Toolkit
Access the settings to configure the following:
Timeframe: Select the higher timeframe for candle display (e.g., 60-minute) or enable automatic timeframe selection based on the chart’s timeframe.
Candle Settings: Choose the number of MTF candles to display, their size, type (standard or Heikin Ashi), and offset from the chart’s right edge.
Colours and Styles: Customise the colours, line styles, and widths for candles, lines, boxes, and projections.
Trend Table: Select the five timeframes for trend analysis and adjust the table’s appearance and position.
CISD Settings: Configure the pullback size filter, line styles, and whether to keep old CISD levels.
Interpreting the Display:
MTF Candles: Use the overlaid candles to assess price action on a higher timeframe without switching charts. Green candles indicate bullish movement, while red (or user-defined colours) indicate bearish movement.
Key Levels: Monitor the Lowest Low, Highest High, and Midpoint lines for potential support, resistance, or mean-reversion zones.
Range Box: The box highlights the MTF price range, helping you identify areas of consolidation or breakout potential.
OHLC Projections: Use the projected lines to track key price levels for the current MTF candle, useful for setting stop-losses, take-profits, or entry points.
Timeframe Separators: Vertical lines help you align trading decisions with the start of new MTF periods.
Trend Table: Check the table to understand the trend direction across multiple timeframes, aligning trades with the broader market context.
CISD Levels: Watch for "+CISD" or "-CISD" labels to identify significant market structure shifts. These levels can act as entry or exit points or zones to monitor for reversals.
Trading Applications:
Multi-Timeframe Analysis: Combine the MTF candle display and trend table to align trades with the higher timeframe trend, increasing the probability of success.
Support and Resistance: Use the Lowest Low, Highest High, and CISD levels to identify key price zones for entries, exits, or stop-loss placement.
Breakout Trading: Monitor CISD levels for breakouts, as these indicate a change in market structure, often leading to strong trending moves.
Trend Confirmation: The trend table helps confirm whether the market is bullish or bearish across multiple timeframes, aiding in trend-following strategies.
Range Trading: The Midpoint Line and Range Box can help identify mean-reversion opportunities within the MTF range.
Customisation Tips:
Adjust the candle size and offset to ensure MTF candles don’t clutter your chart.
Use distinct colours for bullish and bearish elements to enhance visual clarity.
Position the trend and CISD tables in a corner of the chart to avoid obstructing price action.
Experiment with the CISD pullback size filter to balance sensitivity and reliability, depending on the market’s volatility.
Additional Details for Users
Flexibility: The toolkit is highly customisable, allowing traders to tailor it to their specific trading style, whether they focus on trend-following, breakout, or range trading.
Visual Clarity: The use of boxes, lines, and tables ensures that complex MTF data is presented in an intuitive, easy-to-read format.
Timeframe Versatility: The automatic timeframe selection option adapts the MTF candles to the chart’s timeframe, making it suitable for both short-term and long-term traders.
Market Context: By combining MTF candles, trend analysis, and market structure detection, the toolkit provides a holistic view of the market, helping traders make informed decisions.
Conclusion
The MTF Market Analysis Toolkit aims to provide a simple, clear representation of current and higher time frame price action by displaying MTF candles, key price levels, trend directions, and market structure changes on a single chart. Its customisable settings and intuitive visual elements make it suitable for traders of all experience levels, particularly those who value a clear, data-rich view of the market.
Credit: I'd like to thank the following coders who published great scripts that helped enormously with this project
modhelius for the HTF code, which served as the basis for the candle drawings
BigBeluga for the HTF trend table which was adapted from the excellent zero-lag EMA indicator
neommxm for the CISD code which was modified slightly for use here
Release Notes
Updated to include some stats on the Timeframe Box:he "Timeframe Box Stats" table offers traders statistical insights into price behaviour relative to higher timeframe (HTF) candle timeframe boxes. These boxes, defined by the midpointBox in the Candle type, represent either the range from the HTF candle's open to its body midpoint or its high to low, depending on the tfbox_price_mode input ("Open to Midpoint" or "High to Low"). The stats table, enabled via the stats_table_enabled input, is displayed at a user-specified position (e.g., Bottom Left, Top Right) and provides the following metrics for each HTF candle:
Open Position Percentages:
Percentage and count of HTF candles where the price opens above, below, or inside the timeframe box (e.g., perc_open_above = (count_open_above / total_count) * 100).
Close Outcome Percentages:
For each open category (above, below, inside), the percentage and count of HTF candles where the price closes above, below, or inside the box (e.g., perc_open_above_close_above = (count_open_above_close_above / count_open_above) * 100).
Provides insight into the probability of price closing in different zones based on its opening position.
Average Price Moves:
For each open category, the average upward and downward price movements in percentage terms (e.g., avg_up_move_above = sum_up_move_above / count_open_above) and points (e.g., avg_up_move_points_above = sum_up_move_points_above / count_open_above).
Total average moves across all categories are also shown (e.g., avg_up_move_total).
Useful for understanding typical price excursions within an HTF candle.
The table is updated dynamically as new HTF candles form, with statistics computed in the if newCandle and tfbox_enabled block. The code tracks open positions, close outcomes, and price moves using variables like count_open_above, count_open_above_close_above, sum_up_move_above, and sum_up_move_points_above. The getBoxLevels function retrieves box levels, and percentages/averages are calculated with safeguards against division by zero (e.g., total_count > 0 ? ... : 0).
Note on Usage
To use the Timeframe Box Stats table:
Enable the Feature: Set Show Stats Table to true in the "HTF Candle Settings: Timeframe Box Stats" input group.
Configure Position: Choose the table's position (e.g., Bottom Left) via the Stats Table Position input.
Set HTF Parameters: Adjust the Timeframe (e.g., 60 minutes), Number of HTF Candles (default: 4), and tfbox_price_mode ("Open to Midpoint" or "High to Low") in the "HTF Candle Settings" group to define the timeframe boxes.
Interpret the Table: Use the table to identify patterns, such as the likelihood of price closing above the box when opening below it or the average price movement when opening inside the box. Combine with other indicator features (e.g., HTF candles, trend table, CISD levels) for a comprehensive market analysis.
The table is best used on charts with sufficient historical data to generate meaningful statistics, particularly for higher timeframes (e.g., 1H, 4H, 1D). Traders can leverage the stats to inform entry/exit decisions, risk management, or to validate strategies based on HTF price behaviour.
Cautionary Notes and Limitations
Dependence on Timeframe Box:
The stats rely on the midpointBox of HTF candles, which requires Show Timeframe Box to be enabled (tfbox_enabled = true). If disabled, no statistics are generated.
Ensure the chosen Timeframe aligns with your trading strategy, as box levels vary significantly across timeframes.
Cumulative Statistics:
Statistics are cumulative (e.g., count_open_above persists across all HTF candles), which may lead to large counts on long charts, potentially skewing percentages for recent price action.
Consider resetting the chart or limiting the analysis period if focusing on recent data.
Edge Cases:
The first HTF candle’s close is not evaluated until the next candle begins, slightly delaying initial stats population.
If midpointBox is na (e.g., due to insufficient data or a bug in box creation), some candles may be skipped, leading to incomplete stats. Monitor for unexpected gaps in the table.
Price Data Assumptions:
Price move calculations assume non-zero open prices (current_open_price > 0). While rare, zero or negative prices (e.g., in exotic instruments) could cause errors. The code mitigates this with checks (e.g., current_open_price > 0 ? ... : 0).
Table Styling:
Changes to Stats Table Position or other styling inputs after initial rendering do not update the table’s appearance unless the chart is refreshed. Reapply the indicator if adjustments are needed.
Performance:
On very long charts with many HTF candles, cumulative counters and table updates may slightly impact performance. This is unlikely to be significant but monitor on high-timeframe, long-duration charts.
Stats use:
The stats are descriptive and not predictive!
Release Notes
Tidied an inputOpen-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.
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.
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.