INDICATOR MANUAL
Market structure indicatorMarket Structure + Swing Levels [AFD] · full manual · published to TradingView
Read confirmed swings, volatility-scaled zones, and Break or Shift events without turning them into trade instructions.
Start here
What the indicator does, the questions it can help answer, and its fresh-install defaults.
A swing high or low is accepted only after the selected number of bars exists on both sides of its origin. The script then compares it with the prior swing of the same type and can label it higher, equal, or lower.
Each confirmed swing can create a zone. In ATR mode, the zone uses ATR from the swing’s origin bar. Overlapping zones on the same side merge transitively while preserving the complete price union and the number of represented swings.
Structure events are evaluated on confirmed bars. A Break continues the tracked direction. After direction exists, a Shift clears the opposite-side reference and changes that direction; the first qualifying clearance instead appears as Shift (Initial) and establishes direction without claiming a reversal.
If you arrived from the smart-money vocabulary, Break is the event elsewhere called a break of structure (BOS) and Shift is the one called a change of character (CHoCH). The plain words are used here because they describe what the script measures — a level being cleared on a confirmed bar — without importing the claim that either event reveals institutional intent.
Fresh-install defaults8 documented defaults
Swipe or scroll horizontally to see every column.
| Area | Default | Result |
|---|---|---|
| Preset Profile | Swing | Uses an effective Swing Strength of 7; the stored Custom value of 5 is inactive. |
| Swing labels | On | Shows H/HH/EH/LH and L/HL/EL/LL classifications after confirmation. |
| Structure | Enabled · Close | Breaks and shifts require a confirmed close beyond the tracked reference. |
| Structure drawings | Labels and lines off | The state engine continues while optional event drawings remain hidden. |
| Zones | On · ATR 0.5 · ATR length 14 | Creates a half-width of 0.5 ATR on each side of the swing origin price. |
| Broken zones | On · 20 bars | Freezes and recolors a broken zone for 20 chart bars, subject to the FIFO cap. |
| Dashboard | On · nearest-zone rows on | Shows direction, last event, active-zone counts, and the nearest zone above and below. |
| Dynamic alerts | On · zone breaks included | Aggregates confirmed events into one alert() message per bar when configured in TradingView. |
How it works
How the indicator turns chart data into the states and drawings you see.
Swing confirmation
The selected strength is used on both sides of a pivot. A strength-7 swing therefore becomes known seven bars after its origin. The label is placed at the origin only after that confirmation exists.
Swing classification
A confirmed high is H, HH, EH, or LH; a confirmed low is L, HL, EL, or LL. Equal-price swings keep separate origin identities for later structure events.
Zone geometry and clustering
ATR, ticks, points, or currency define the half-width around each swing. Same-side overlaps merge into an exact-union cluster; ×N counts represent confirmed swing zones, not repeated tests of one price.
Break and Shift logic
Close requires the bar to finish beyond the reference. Body requires both open and close to clear it. Break follows the current direction. Shift (Initial) assigns the first direction; later Shifts clear the opposite reference and change direction.
Zone lifecycle
Zone Break Basis can follow the structure confirmation rule or use inclusive wick contact at the far edge. Broken zones leave the active set immediately, even when their frozen drawing is retained temporarily.
Drawing and dashboard pass
Optional live lines, shift triggers, frozen event segments, labels, age colors, and dashboard rows display the stored state. Hiding them does not disable the underlying confirmed-bar calculations.
Output and state reference9 documented states
Swipe or scroll horizontally to see every column.
| Output or state | When it appears | Meaning |
|---|---|---|
| SWING CONFIRMED | Selected strength satisfied | A pivot high or low is added at its historical origin. |
| HH / EH / LH | Confirmed high | The high is above, equal to, or below the prior confirmed swing high. |
| HL / EL / LL | Confirmed low | The low is above, equal to, or below the prior confirmed swing low. |
| ACTIVE ZONE | Confirmed swing | A standalone or merged same-side band remains eligible for break checks. |
| STRUCTURE BREAK | Continuation clearance | Price cleared the same-direction swing reference under Close or Body confirmation. |
| STRUCTURE SHIFT | Opposite-reference clearance | The tracked direction changed after a confirmed clearance. |
| SHIFT (INITIAL) | First qualifying clearance | Assigns the first tracked direction on the chart; it is not a reversal. |
| BROKEN ZONE | Far edge cleared or touched | The zone is no longer active; its optional frozen drawing expires after the selected memory. |
| DASHBOARD | Latest chart update | Reports direction, latest event, zone counts, and optional nearest-zone distances. |
Settings
The 56 rows below match the current public Pine input surface. Conditional controls are dimmed in TradingView until their parent setting makes them applicable.
⚙️ General1 input
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Preset Profilepreset | Choice / text | Swing | Custom · Scalper · Intraday · Swing |
📐 Swing Detection2 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Swing Strengthswing_strength | Whole number | 5 | Min 1 · Max 500 | Conditional |
| Show Swing Classification Labelsshow_swing_labels | Toggle | On | — |
🏛️ Structure Detection2 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Enable Structurestructure_enable | Toggle | On | — |
| Structure Confirmstructure_confirm | Choice / text | Close | Close · Body |
🏷️ Structure Labels3 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Break Labelsshow_break_labels | Toggle | Off | Conditional |
| Show Shift Labelsshow_shift_labels | Toggle | Off | Conditional |
| Event Label Sizeevent_label_size | Choice / text | Normal | Tiny · Small · Normal | Conditional |
📏 Structure Lines7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Structure Linesshow_structure_lines | Toggle | Off | Conditional |
| Live Line Colorlive_line_color | Color | Gray · 35% transparent | Conditional |
| Live Line Widthlive_line_width | Whole number | 1 | Min 1 | Conditional |
| Live Line Stylelive_line_style | Choice / text | Solid | Solid · Dashed · Dotted | Conditional |
| Show Shift Trigger Lineshow_shift_trigger | Toggle | Off | Conditional |
| Shift Trigger Colorshift_trigger_color | Color | Orange | Conditional |
| Shift Trigger Styleshift_trigger_style | Choice / text | Dashed | Solid · Dashed · Dotted | Conditional |
🧊 Event-Line History11 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Break Line Colorbreak_line_color | Color | Yellow | Conditional |
| Shift Line Colorshift_line_color | Color | Purple | Conditional |
| Color Frozen Lines by Directionfrozen_dir_color | Toggle | Off | Conditional |
| Break Up Colorbreak_up_color | Color | Blue | Conditional |
| Break Down Colorbreak_dn_color | Color | Blue | Conditional |
| Shift Up Colorshift_up_color | Color | Purple | Conditional |
| Shift Down Colorshift_dn_color | Color | Purple | Conditional |
| Frozen Line Widthfrozen_line_width | Whole number | 1 | Min 1 | Conditional |
| Frozen Line Stylefrozen_line_style | Choice / text | Dotted | Solid · Dashed · Dotted | Conditional |
| Frozen Line Extendfrozen_line_extend | Choice / text | None | None · Left · Right · Both | Conditional |
| Previous Frozen Lines Keptfrozen_lines_kept | Whole number | 0 | Min 0 · Max 50 | Conditional |
🧱 Zone Calculation7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Zonesshow_zones | Toggle | On | — |
| Zone Width Modezone_width_mode | Choice / text | ATR | ATR · Ticks · Points · Currency ($) | Conditional |
| Zone Widthzone_width_val | Decimal | 0.5 | Min 0.01 | Conditional |
| ATR Lengthatr_length | Whole number | 14 | Min 1 | Conditional |
| Zone Break Basiszone_break_basis | Choice / text | Same as Structure | Same as Structure · Touch (High/Low) | Conditional |
| Show Broken Zonesshow_broken_zones | Toggle | On | Conditional |
| Broken Zone Memory (bars)broken_zone_keep_bars | Whole number | 20 | Min 1 · Max 500 | Conditional |
🎨 Zone Appearance7 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Cluster Labelsshow_cluster_labels | Toggle | On | Conditional |
| Swing High/Low Label Positioncluster_label_position | Choice / text | Swing Origin | Right Edge · Swing Origin | Conditional |
| Swing High Zone Colorzone_hi_color | Color | Red · 85% transparent | Conditional |
| Swing Low Zone Colorzone_lo_color | Color | Green · 85% transparent | Conditional |
| Swing High Text Colorzone_hi_text_color | Color | White | Conditional |
| Swing Low Text Colorzone_lo_text_color | Color | White | Conditional |
| Broken Zone Colorbroken_zone_color | Color | Gray · 80% transparent | Conditional |
🕰️ Zone Age10 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Zone Ageshow_zone_age | Toggle | Off | Conditional |
| Age Unitage_unit | Choice / text | Days | Bars · Hours · Days | Conditional |
| Age Label Sizeage_label_size | Choice / text | Normal | Tiny · Small · Normal | Conditional |
| Color Zones by Ageage_color_mode | Choice / text | Off | Off · Auto (Gradient) · Preset · Dark · Contrast · Warm · Mono · Cool · Pastel · Subdued | Conditional |
| Extra Color Opacityage_opacity | Whole number | 0 | Min -40 · Max 40 | Conditional |
| Gradient Range (bars)age_gradient_bars | Whole number | 200 | Min 1 | Conditional |
| Gradient End Colorage_gradient_end | Color | Gray · 70% transparent | Conditional |
| Fresh→Mid (bars)age_band1_bars | Whole number | 20 | Min 1 | Conditional |
| Mid→Old (bars)age_band2_bars | Whole number | 100 | Min 1 | Conditional |
| Age Label Colorage_label_color | Color | White | Conditional |
📊 Dashboard4 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Show Dashboardshow_dashboard | Toggle | On | — |
| Dashboard Positiondash_position | Choice / text | Top Right | Top Right · Bottom Right · Bottom Left · Top Left | Conditional |
| Text Sizedash_text_size | Choice / text | Small | Tiny · Small · Normal | Conditional |
| Show Nearest Zone Distanceshow_nearest_zone | Toggle | On | Conditional |
🔔 Alerts2 inputs
Swipe or scroll horizontally to see every column.
| Setting | Control | Default | Choices, limits & availability |
|---|---|---|---|
| Dynamic Alert Textdyn_alerts | Toggle | On | — |
| Include Zone Breaks in Dynamic Alertzone_break_alerts | Toggle | On | Conditional |
Alerts and limitations
What can notify you, what can change the output, and what the indicator cannot establish.
4 fixed alert conditions
Confirmed continuation above the tracked swing high.
Confirmed continuation below the tracked swing low.
Confirmed clearance of the high held while direction was down.
Confirmed clearance of the low held while direction was up.
Limits to keep visible
- A swing is deliberately delayed by the selected right-side strength; the newest apparent turn is not yet confirmed.
- Zone width is user-selected geometry. ATR, ticks, points, or currency distance does not establish that a zone will hold or matter later.
- Currency mode depends on the symbol’s point-value data. When it is unavailable, the indicator cannot create that zone.
- Hours and Days age labels are approximations derived from chart bars and do not correct for session gaps.
- The indicator caps active zones at 40 per side, retained broken zones at 20, swing labels at 50, and event labels at 60; older objects leave in FIFO order.
- Alerts describe indicator events only. They do not size a position, define risk, or confirm delivery in the user’s TradingView setup.
Troubleshooting
Start with what you see on the chart. Each answer explains the likely cause and the first setting, timeframe, or data condition to check.
Why did a swing label show up after the turn?
The script waits for the swing to be confirmed before drawing it. A strength-7 swing appears seven bars after the turning bar. Check the active preset or Custom Swing Strength if you want to understand the delay; lowering it finds turns sooner but also accepts smaller swings.
Why did price wick through a structure level without a Break?
A wick alone does not meet the current confirmation rule. With Close selected, wait for a candle to close beyond the level. With Body selected, both the open and close must be beyond it. Check Structure Confirm and make sure the candle has closed.
Why did ×N rise even though price did not retest that price?
×N is not a retest counter. It tells you how many confirmed swing zones overlap inside the merged band. A new nearby swing can raise the count without price returning to the exact same level.
Why do Break and Shift states keep updating after I hide the drawings?
Hiding lines or labels only cleans up the chart; it does not stop the structure calculation. Check Enable Structure if you want to control whether Break and Shift states are calculated at all.
Why is the zone missing when I choose Currency width?
TradingView may not provide a usable point value for that symbol, so the script cannot convert the selected cash amount into chart distance. Try ATR, Ticks, or Points. If those work, the missing point-value data—not the swing—is the issue.