OPEN-SOURCE SCRIPT
SMC Structure + HTF Levels + Volatility

Description: This script is a comprehensive "Smart Money Concepts" (SMC) toolkit designed to filter out market noise and focus only on the Major Market Structure. It combines structural analysis, multi-timeframe key levels, and volatility tracking into a single chart overlay.
Unlike standard fractal indicators that clutter the chart with every minor pivot, this script uses a "Retroactive" logic system to only mark significant Higher Highs (HH), Higher Lows (HL), Lower Lows (LL), and Lower Highs (LH) that confirm a trend break.
Key Features
1. Major Structure Mapping (Retroactive Logic)
The Problem: Standard indicators often mark a "Lower High" too early, only for price to continue higher.
The Solution: This script waits for a Major Low to be broken (confirmed break of structure) before identifying the peak that caused it. It then "looks back" and retroactively labels that peak as the valid Lower High (LH).
Result: You get a clean chart that shows only the true structural legs of the trend, filtering out internal sub-swings and fake-outs.
2. Multi-Timeframe (MTF) Steplines
Automatically plots the previous highs and lows from higher timeframes:
PDH / PDL: Previous Day High & Low (Blue)
PWH / PWL: Previous Week High & Low (Orange)
PMH / PML: Previous Month High & Low (Purple)
These act as major magnet levels for price targets or reversal zones.
3. Volatility Regimes (Expansion vs. Consolidation)
Uses Bollinger Band Width to analyze market energy.
Green Background (Expansion): Volatility is above average. The market is moving fast (breakout or trend).
Gray Background (Consolidation): Volatility is below average. The market is squeezing, indicating a potential big move is building up.
How to Use It
Trend Following: Look for price to form a HL (Higher Low) in an uptrend. Wait for the background to turn Gray (Consolidation), then enter when it turns Green (Expansion) as price breaks upward.
Reversals: Watch for price to hit a PWH (Previous Week High). If a LH (Lower High) label appears shortly after, it confirms the reversal is valid.
Stop Placement: Use the most recent HL or LH labels as safe zones for stop-loss placement, as these represent protected structural points.
Settings
Swing Length: Adjusts how sensitive the structure detection is (Default: 5). Increase this number to see even longer-term structure.
Colors: Fully customizable colors for Bullish/Bearish structure, HTF lines, and Volatility zones.
Show/Hide: You can toggle off any element (like the Monthly levels or Volatility background) to keep your chart clean.
Unlike standard fractal indicators that clutter the chart with every minor pivot, this script uses a "Retroactive" logic system to only mark significant Higher Highs (HH), Higher Lows (HL), Lower Lows (LL), and Lower Highs (LH) that confirm a trend break.
Key Features
1. Major Structure Mapping (Retroactive Logic)
The Problem: Standard indicators often mark a "Lower High" too early, only for price to continue higher.
The Solution: This script waits for a Major Low to be broken (confirmed break of structure) before identifying the peak that caused it. It then "looks back" and retroactively labels that peak as the valid Lower High (LH).
Result: You get a clean chart that shows only the true structural legs of the trend, filtering out internal sub-swings and fake-outs.
2. Multi-Timeframe (MTF) Steplines
Automatically plots the previous highs and lows from higher timeframes:
PDH / PDL: Previous Day High & Low (Blue)
PWH / PWL: Previous Week High & Low (Orange)
PMH / PML: Previous Month High & Low (Purple)
These act as major magnet levels for price targets or reversal zones.
3. Volatility Regimes (Expansion vs. Consolidation)
Uses Bollinger Band Width to analyze market energy.
Green Background (Expansion): Volatility is above average. The market is moving fast (breakout or trend).
Gray Background (Consolidation): Volatility is below average. The market is squeezing, indicating a potential big move is building up.
How to Use It
Trend Following: Look for price to form a HL (Higher Low) in an uptrend. Wait for the background to turn Gray (Consolidation), then enter when it turns Green (Expansion) as price breaks upward.
Reversals: Watch for price to hit a PWH (Previous Week High). If a LH (Lower High) label appears shortly after, it confirms the reversal is valid.
Stop Placement: Use the most recent HL or LH labels as safe zones for stop-loss placement, as these represent protected structural points.
Settings
Swing Length: Adjusts how sensitive the structure detection is (Default: 5). Increase this number to see even longer-term structure.
Colors: Fully customizable colors for Bullish/Bearish structure, HTF lines, and Volatility zones.
Show/Hide: You can toggle off any element (like the Monthly levels or Volatility background) to keep your chart clean.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.