Isolated Scroll Container

1. Market Structure Confluence Strategy Description

The indicator finds swing highs and lows, marks every Break of Structure (BOS) and Change of Character (CHoCH), colors the candles by the current trend, and then adds a volatility band (WMA ± ATR) drawn only on the trend's side to catch the moments price comes back and touches the band.

1.1 Indicator Concept

The indicator joins two independent "engines" together (that is what Confluence means) and answers two questions in a row: "Which side is the trend currently leaning toward?" and then "When price comes back to the volatility band on that same side, is that a with-the-trend entry point?"

  • Engine 1 — Market Structure: the trend is decided by the most recent break. The indicator finds swing highs and swing lows (points where price clearly turned around: a high that is higher than the 10 bars on its left and the 10 bars on its right is a swing high). When price breaks above the latest swing high (by default a candle close beyond it) → the market has "broken structure" to the upside. When price falls below the latest swing low → structure is broken to the downside. The direction of the most recent break is the current trend.
  • BOS and CHoCH — two names for two kinds of break. BOS (Break of Structure) is a break in the same direction as the existing trend: already rising and it breaks another high → the trend is reinforced. CHoCH (Change of Character) is a break in the opposite direction to the existing trend: already rising and it breaks a swing low → the first sign that buyers are weakening and the trend may have turned.
  • Engine 2 — Volatility Band: a moving average plus/minus a volatility width. The indicator takes a 100-bar WMA of the close (a weighted average: the newer the bar, the heavier it counts), then adds and subtracts 2× a smoothed "average candle range" (ATR) to get an upper and a lower band. But only one band is drawn at any moment, chosen by the trend from Engine 1: uptrend → the lower band (acting as dynamic support); downtrend → the upper band (dynamic resistance).
  • Confluence — where the two engines meet. The ▲ / ▼ arrows appear only when price touches the band while the trend is on the same side as that band. The idea: in an uptrend price often pulls back to support and then continues; the indicator marks exactly those pullbacks.

The underlying belief: markets move in waves of highs and lows, and a break of the latest high/low is the clearest evidence of who is in control. Once the trend is clear, pullbacks to a moving average ± a volatility range are lower-risk with-the-trend entries than chasing price.

1.2 Indicator Features

  • Display:
    • HH / LH / HL / LL swing labels: text placed right on the swing high or low, 50% transparent so it does not clutter the chart. HH (Higher High — a high above the previous high) and HL (Higher Low — a low above the previous low) are aqua-green; LH (Lower High) and LL (Lower Low) are red. High labels sit above the point, low labels below. Can be turned off with "Show Swing Labels".
    • BOS / CHoCH lines: a thin horizontal line (width 1) drawn from the exact candle that made the swing high/low to the candle that broke it. The word "BOS" or "CHoCH" sits in the middle of the line. Break up → aqua-green, text above the line. Break down → red, text below the line. The line style (solid / dashed / dotted) is selectable.
    • Trend-colored candles: every candle on the chart is repainted — aqua-green when the current trend is up, red when it is down. The color depends only on the latest break, not on whether that candle itself rose or fell.
    • Volatility band: a thick line (width 3) shown on one side at a time: the aqua-green lower band in an uptrend, the red upper band in a downtrend. The line breaks (is not connected) whenever the trend switches sides.
    • ▲ / ▼ signal arrows (Bullish / Bearish Signal): a aqua-green ▲ sits below the lower band (exactly 1 ATR away), a red ▼ sits above the upper band. They appear when a candle's body-and-wick range crosses the band (details in 1.4).
    • ◉ Trend Change dot: a circle placed at the band's value on the candle where the trend changes (or is established for the first time). A aqua-green ◉ sits on the lower band line, a red ◉ on the upper band line.
  • Alerts: there are 12 alertcondition() calls you can pick when creating a TradingView alert:
    • Bullish CHoCH / Bullish BOS / Bearish CHoCH / Bearish BOS — 4 alerts for structure breaks. Warning: both "CHoCH" alerts never fire and both "BOS" alerts fire on every break (a code bug, see the note box at the end of this section).
    • HH Detected / LH Detected / HL Detected / LL Detected — each time a new swing high/low is confirmed and classified accordingly (confirmed 10 bars late relative to when the high/low actually formed).
    • Bullish Arrow Signal / Bearish Arrow Signal — when a ▲ / ▼ arrow appears (the message text says "Rejection Signal").
    • Bullish Trend Change / Bearish Trend Change — when a ◉ dot appears, i.e. when the trend reverses (or on the first break on the chart). This is the pair that actually reports CHoCH correctly.
    • All 12 alerts pass through the "Wait for Bar Close (alerts)" box (on by default): when on, they fire only after the candle has closed.

1.3 How to Use the Indicator

  • Use the candle color as a directional filter. Aqua-green candles → only look for longs. Red candles → only look for shorts. The color tells you "which side you are on", not where to enter.
  • Treat CHoCH as an early trend-change warning and BOS as continuation confirmation. A CHoCH label = the first break against the old trend: stop adding to positions in the old direction, consider taking partial profit or tightening your Stop Loss. A BOS label = the trend is still healthy, keep holding or look for new entries in that direction.
  • Enter with the trend at the arrows. When candles are aqua-green and a ▲ appears → price has just pulled back to the lower band within an uptrend, a candidate for a long. When candles are red and a ▼ appears → price has just rallied to the upper band within a downtrend, a candidate for a short. This is the indicator's "confluence" part.
  • Treat an arrow as a point of interest, not an automatic order. The arrow's condition only requires the candle to cross the band, not that the candle closes back on the correct side (see the note box). Wait for extra confirmation: a close back on the trend side, or an additional filter of your own.
  • Use the line that was just broken as a Stop Loss anchor. After a break up, the broken high often turns into support, and the latest swing low is a natural technical level for your SL. Do the opposite for shorts. The band can also act as a dynamic SL reference (placed slightly outside the band).
  • Read the HH/HL or LH/LL sequence to judge trend health. A strong uptrend usually has HH and HL chained together. If a LH appears while candles are still green, the new high failed to beat the old one — often a sign of fading momentum before a CHoCH.
  • Tune "Time-Horizon" to your timeframe and style. Leave it at 10 (default) for balanced structure. Drop it to 4–6 → many small swings, BOS/CHoCH print often, suited to scalping but noisy and prone to constant color flips. Raise it to 20–30 → only large swings remain, BOS/CHoCH are rare but more reliable, suited to swing trading but much later.
  • Tune "Basis Length" and "Volatility Multiplier" to hug price tighter or wider. Lower Basis Length to 50 → the average hugs price, the band is closer, arrows print often. Raise it to 200 → the band is far away and is touched only after deep pullbacks.

1.4 How the Indicator Works

Inputs & their roles

Group "Market Structure" — affects only structure, trend, the BOS/CHoCH lines and candle colors

  • swingSize ("Time-Horizon", integer, default 10, minimum 2): the number of bars to look at on each side to define a swing high/low. A bar is accepted as a swing high only if its high is above the 10 bars to its left and the 10 bars to its right. Key consequence: you must wait 10 more bars to know whether it was a swing at all, so every swing is confirmed 10 bars late (but once confirmed it never changes). Example on M15: 10 bars = 2.5 hours. At 10 → a swing needs a 21-bar window and is reported 2.5 hours late. Drop to 5 → reported 1.25 hours late but it catches small waves, so structure flips constantly. Raise to 20 → reported 5 hours late, only large highs/lows are caught. At the minimum of 2, every tiny wiggle becomes a swing and the structure is nearly meaningless.
  • bosConfType ("BOS Confirmation", dropdown with two values "Candle Close" / "Wicks", default Candle Close): decides what part of the candle counts as a "break". Candle Close → the closing price must go beyond the level. Wicks → merely the wick (high/low) poking past the level counts. Example: swing high 2650, a candle has a high of 2651 but closes at 2648. In Wicks mode → counts as a BOS immediately. In Candle Close mode → nothing counts yet and the 2650 swing high stays alive, waiting to be broken. Wicks is more sensitive but picks up fake "wick sweeps".
  • bosStyleIn ("BOS/CHoCH Line Style", dropdown: "Solid" / "Dashed" / "Dotted", default Solid): the stroke style of the BOS/CHoCH line — solid, dashed or dotted. Only changes how the line looks, no effect on logic.
  • showCHoCH ("Show CHoCH", checkbox, default on): on → a break against the trend is labeled "CHoCH". Off → every break is labeled "BOS". Only changes the text on the chart. The trend, candle colors, ◉ dots and alerts still treat CHoCH as usual.
  • showSwing ("Show Swing Labels", checkbox, default on): toggles the HH/LH/HL/LL labels. Display only. The swing classification still runs in the background, so the 4 HH/LH/HL/LL alerts keep working with labels hidden.

Group "Band Settings" — affects only the band, the arrows and the position of the ◉ dots, not structure or trend

  • basisLength ("Basis Length", integer, default 100, minimum 1): the number of bars of the WMA that forms the "center" of the band. The larger it is, the slower the center and the farther it sits from price when price runs hard. Example: XAUUSD is rallying, a 100-bar WMA might be at 2640 while price is at 2680; lower it to 50 and the center might be at 2660, hugging price more closely.
  • atrLength ("ATR Length", integer, default 14): the number of bars for ATR (Average True Range — the average range of one candle, including price gaps between candles). This input also sets how far the arrows sit from the band (an arrow sits exactly 1 ATR away from the band). Example: on XAUUSD M15, ATR 14 is typically around 4–6 USD.
  • atrSmooth ("ATR Smoothing", integer, default 21): smooths the ATR with a simple moving average (SMA) over 21 bars so the band width does not jump up and down candle by candle. Raise it → a steadier band width but a slower reaction when the market suddenly expands its range.
  • volMult ("Volatility Multiplier", decimal, default 2.0, step 0.1, minimum 0.1): the multiplier applied to the smoothed ATR to get the half-width of the band. Example: WMA = 2640, smoothed ATR = 4 → upper band = 2640 + 2×4 = 2648, lower band = 2640 − 2×4 = 2632. Set the multiplier to 1.0 → the band narrows to 2644 / 2636 and price touches it more often; set it to 3.0 → 2652 / 2628 and price rarely touches it.

Groups "Appearance" and "⚠️ Alerts"

  • colBull ("Bull Color", color picker, default #00FFBB — bright aqua-green) and colBear ("Bear Color", color picker, default #FF1100 — vivid red): two swatches side by side on one row (inline = "msc"). Unlike many other indicators, these two colors control ALL of the visuals: candles, BOS/CHoCH lines, BOS/CHoCH text, swing labels (at 50% transparency), band, arrows and ◉ dots.
  • waitClose ("Wait for Bar Close (alerts)", checkbox, default on): affects only the 12 alerts, never the drawings. On → alerts fire only once the candle has fully closed (avoids false alerts while price is still moving inside the candle). Off → alerts fire the moment the condition is true during the running candle.

Hard-coded constants (NOT inputs)

  • enMS = true: an "enable market structure" switch locked to on. Just a leftover from an earlier version of the code, with no effect.
  • bosWidth = 1: thickness of the BOS/CHoCH line. Fixed transparency: swing labels 50%, candle color 30%.
  • The 1× ATR factor for arrow distance (arrowOffset = volatility * 1) and the width 3 of the band line: you must edit the code to change them.
  • max_lines_count = 500 and max_labels_count = 500: ceilings on how many lines/labels exist at once; max_bars_back = 5000: the maximum number of bars the indicator can look back. Past the ceiling TradingView deletes the oldest drawings. Note: swing labels (HH/LH/HL/LL) and the BOS/CHoCH text share this single 500-label ceiling.

Main logic blocks

📍 Flow 1 — Finding swing highs/lows (every bar)

  • pivHi = ta.pivothigh(high, swingSize, swingSize) — a built-in Pine function: on each bar it looks back at the bar swingSize bars ago and asks "is that bar's high above all 10 bars to its left and all 10 bars to its right?". If yes → it returns that high price; if not → it returns na (meaning "no value", an empty cell).
  • pivLo = ta.pivotlow(low, swingSize, swingSize) — the mirror image for swing lows.
  • Because 10 bars on the right are required, a swing is always detected 10 bars late. Labels and lines are drawn back onto the real candle of the high/low using bar_index − swingSize, so you see the label sitting in the right place but it only appears 10 bars later.
  • Example: bar 100 has a high of 2650, and the 10 bars before it and the 10 bars after it all have lower highs. On bar 110, pivHi = 2650. A HH/LH label is attached to bar 100, but it only shows up when the chart reaches bar 110. A high and a low can be confirmed on the same bar.

🏷️ Flow 2 — Classifying HH / LH / HL / LL and remembering the level to break (when a new swing appears)

  • The indicator keeps in "memory" (variables declared with the keyword var — meaning they are remembered across bars and not recalculated from scratch on every bar): prevHigh / prevLow are the prices of the latest swing high / low, prevHighIdx / prevLowIdx are their bar numbers, and highActive / lowActive say whether that level is still "unbroken".
  • When a new swing high appears: hh := na(prevHigh) or pivHi >= prevHigh. A new high higher than or equal to the previous swing high → HH. Lower → LH. The first swing high on the chart is always HH (nothing to compare to). Then it overwrites prevHigh := pivHi, prevHighIdx := bar_index − swingSize and sets highActive := true.
  • For lows: hl := na(prevLow) or pivLo >= prevLow. A new low higher than or equal to the previous low → HL, lower → LL. It also overwrites prevLow, prevLowIdx and sets lowActive.
  • Example: previous swing high 2650. New high 2658 → HH. New high 2645 → LH. New high exactly 2650 → still HH (the comparison is "greater than or equal").
  • Two points to remember: (1) the level to break is always the NEWEST swing high/low, even when it is a LH or a HL lower than the old level — older unbroken highs/lows are forgotten completely when a new swing arrives. (2) HH/LH/HL/LL are only labels and alerts; they are not used to decide the trend. The trend is decided only by the breaks in Flows 3–4.

💥 Flow 3 — Detecting a break (every bar)

  • highSrc / lowSrc are the "prices used to test a break": if bosConfType = "Candle Close" both are close; if "Wicks" then highSrc = high and lowSrc = low.
  • Break up: highActive and highSrc > prevHigh → highBroken := true and highActive := false. Break down: lowActive and lowSrc < prevLow → lowBroken := true and lowActive := false.
  • Each level can only be broken once. The moment it is broken the level is "switched off" (Active := false) and only switched back on when a new swing high/low replaces it. So price sitting above an already-broken level does not generate more BOS.
  • No break is missed during the confirmation wait: since a swing is by definition the highest point in the 10 bars to its right, price cannot exceed it during that stretch; the earliest bar that can break it is the bar right after the confirmation bar.
  • Example: prevHigh = 2650, Candle Close mode. Bar 125 closes at 2652 → 2652 > 2650 → highBroken = true. Earlier, bar 120 had a wick to 2655 but closed at 2648 → does not count, because this mode only looks at closing prices.

🧭 Flow 4 — Updating the trend and telling BOS from CHoCH (only on break bars)

  • prevBreakDir is the remembered variable holding the current trend: 1 = up, −1 = down, 0 = no break yet on the chart. lastBreakDir keeps the trend right before this break.
  • On highBroken: lastBreakDir := prevBreakDir (save the old trend), then prevBreakDir := 1 (the new trend is up). The chart text: if the old trend was down (prevBreakDir == −1, measured before the update) and the "Show CHoCH" box is on → the label says "CHoCH", otherwise "BOS".
  • bullishChange := lastBreakDir == −1 or lastBreakDir == 0 — true when the old trend was down or non-existent. This means the ◉ dot (and the "Bullish Trend Change" alert) also fire on the very first break on the chart, even though the chart text then says "BOS" (there is no old trend to oppose).
  • On lowBroken: fully symmetric. lastBreakDir := prevBreakDir, prevBreakDir := −1; "CHoCH" text if the old trend was up; bearishChange := lastBreakDir == 1 or lastBreakDir == 0.
  • Example sequence: (1) First break up → "BOS" text, green ◉, trend = up. (2) Another break up → "BOS" text, no ◉ (uptrend reinforced). (3) Price closes below a swing low → red "CHoCH" text, red ◉, trend = down, all candles turn red. (4) Another low broken → red "BOS" text, no ◉. (5) A swing high is broken upward → green "CHoCH" text, green ◉, candles turn green.
  • An important thing to understand: the indicator's trend only changes on an opposite-direction break. It can keep the same direction for a very long time even if price has gone sideways or drifted a lot.

✏️ Flow 5 — Drawing lines, BOS/CHoCH text, swing labels and coloring the candles

  • BOS/CHoCH line: on the break bar, line.new(prevHighIdx, prevHigh, bar_index, prevHigh, ...) draws a horizontal line from the candle that made the swing high/low to the break candle, at exactly the height of the broken level. Aqua-green for a break up, red for a break down, style per bosStyleIn, thickness bosWidth = 1.
  • Text on the line: a label.new placed at the middle bar of the line (math.floor rounds down), transparent background, small text. Break up → text above the line; break down → text below the line.
  • Swing labels: when showSwing is on, each hh / lh / hl / ll draws a label at bar bar_index − swingSize (the exact bar of the high/low), text 50% transparent, transparent background. Highs use a down-pointing label (sitting above the point), lows use an up-pointing label (sitting below the point).
  • Candle coloring: barcolor(prevBreakDir == −1 ? red 30% : green 30%). Note: every case that is not "down" is painted green, including prevBreakDir = 0 (no break yet). This line runs after the trend has been updated in Flow 4, so the break candle changes color on that very candle.

📊 Flow 6 — The volatility band (every bar)

  • volatility = ta.atr(atrLength) — a 14-bar ATR, the average range of one candle.
  • svol = ta.sma(volatility, atrSmooth) — the average of the last 21 ATR values for smoothing.
  • basis = ta.wma(close, basisLength) — a 100-bar weighted average of the close: the newest bar weighs the most, older bars progressively less → it hugs price more closely than a plain average.
  • upper = basis + volMult * svol and lower = basis − volMult * svol. Example: basis 2640, svol 4, volMult 2 → upper 2648, lower 2632.
  • Only one band is drawn: plot(prevBreakDir == 1 ? lower : na, ...) draws the lower band (aqua-green) in an uptrend; plot(prevBreakDir == −1 ? upper : na, ...) draws the upper band (red) in a downtrend; the plot.style_linebr style lets the line break when the value is na. When prevBreakDir = 0 nothing is drawn.
  • Two easily misunderstood points: (1) The band is not a trailing stop: it is just a WMA ± a constant, so it can move up or down freely, and it is not guaranteed to always sit on the correct side of price (for example right after a bullish CHoCH, the 100-bar WMA is still high from the old downtrend, so the lower band can still be ABOVE price). (2) The two plot lines are near the top of the code and run before prevBreakDir is updated in Flow 4, so they read the trend of the previous bar. Result: the band only starts showing on the bar AFTER the break.

🎯 Flow 7 — The ▲ / ▼ arrows and the ◉ dots (every bar)

  • bullishArrow = prevBreakDir == 1 and low < lower and high > lower: the trend is up and the candle's low is below the lower band and the candle's high is above the lower band. In other words, the candle's low-to-high range crosses the lower band line.
  • bearishArrow = prevBreakDir == −1 and low < upper and high > upper: the mirror image for a downtrend with the upper band.
  • Where they are drawn: ▲ at lower − arrowOffset, ▼ at upper + arrowOffset, where arrowOffset = volatility (1 ATR). The arrow sits outside the band, 1 ATR away, so it does not cover the candles.
  • The ◉ dot: plotchar(bullishChange ? lower : na, ...) places a circle at the lower band's value on the trend-change candle; bearishChange places it on the upper band. Because the dot is positioned by the band and not by price, it can sit far from the candle body when the band is far from price.
  • Example: uptrend, lower band = 2632, ATR = 5. A candle with a low of 2630 and a high of 2636 → low < 2632 < high → a ▲ appears at 2632 − 5 = 2627. Another candle with a low of 2634 (does not reach the band) → no arrow. Another with a high of 2631 (entirely below the band) → also no arrow.
  • Because Flow 6 reads the trend one bar late, an arrow can never appear on the break candle itself; the earliest is the next candle.

🔔 Flow 8 — Alerts (every bar)

  • barConfirmed = not waitClose or barstate.isconfirmed — if "Wait for Bar Close" is off it is always true; if on it is true only once the candle has closed. Each alert is its own condition AND barConfirmed.
  • The 4 BOS/CHoCH alerts use highBroken / lowBroken combined with prevBreakDir (see the bug in the note box). The 4 swing alerts use hh / lh / hl / ll directly. The 2 arrow alerts use bullishArrow / bearishArrow. The 2 Trend Change alerts use bullishChange / bearishChange.

Outputs & their role in use

  • Candle color: a directional filter based on the current trend. The candle recolors exactly on the break candle.
  • BOS / CHoCH line + text: tells you whether the break that just happened is continuation (BOS) or an early reversal (CHoCH), and which price level was just broken — use it as an SL anchor or a watch level.
  • HH / LH / HL / LL labels: structural context, showing whether the highs and lows are stepping up or down. They appear 10 bars late.
  • Volatility band: dynamic with-the-trend support/resistance (thick line, one side), used to find the pullback entry.
  • ▲ / ▼ arrows: points of interest to enter with the trend when price touches the band again. Need extra confirmation.
  • ◉ dots: mark the candle where the trend reverses (or is first established).
  • 12 alerts: automate the monitoring; use the Trend Change pair when you want a correct CHoCH notification.
💡 Important technical notes:
  • BUG in the code: the "Bullish CHoCH" and "Bearish CHoCH" alerts never fire, and the two "BOS" alerts fire on ALL breaks. The alertcondition lines sit after the trend-update block, by which time prevBreakDir has already been switched to the new direction. Example: on a break up, the "Bullish CHoCH" condition is highBroken and prevBreakDir == −1, but prevBreakDir was just assigned 1, so the condition is always false. Conversely the "Bullish BOS" condition prevBreakDir != −1 is always true. Result: the "BOS" alerts cover both BOS and CHoCH, the "CHoCH" alerts stay silent. Workaround: use the Bullish Trend Change / Bearish Trend Change pair to catch CHoCH (that pair is computed correctly, but it also fires on the first break on the chart).
  • The band and arrows read the trend one bar late. Because the two band-plot lines and the arrow calculation sit before the line that updates prevBreakDir, they use the previous bar's value. The break candle itself already changes color and gets its ◉, but the band line only starts on the next bar, and the break candle cannot have an arrow. The ◉ is placed at the band value on the break candle, while the new band line appears 1 bar later.
  • The arrow is not a real "confirmed bounce". The indicator calls it "Rejection", but the condition only needs the candle range to cross the band and does not check whether the close returns to the correct side. A candle that slices straight through the band and closes on the far side still gets an arrow. Arrows can also print on several consecutive candles while price walks along the band.
  • Arrows can flicker intrabar (mild repaint). The condition uses the running candle's high and low, which keep changing until the candle closes. An arrow may appear and vanish a few times. Likewise, in "Candle Close" mode, the running break candle can flicker when the close temporarily pokes above/below the level. Only trust a signal after the candle has closed.
  • The band is not guaranteed to sit on the correct side of price. Since the band is a 100-bar WMA ± a constant, right after a CHoCH (when the trend has just reversed) the WMA still carries the old momentum, so the lower band can sit above current price (or the upper band below price). In that case a ▲ may appear when price rises through the lower band rather than bouncing up from above it.
  • The first bars of the chart are meaningless. It takes at least 21 bars for the first swing plus more time for the first break; 100 bars are needed for the WMA. Before the first break, prevBreakDir = 0 → every candle shows aqua-green whether price is rising or falling, and there is no band. Do not read that stretch as a bullish signal.
  • The indicator remembers exactly one swing high and one swing low. Each new swing overwrites the old one even if the old one was never broken. So a break of a "big high" further away is never recorded if a smaller high has since replaced it. The structure here is the "shortest-wave" structure, not the large-scale structure.
  • Swing labels and swing alerts are 10 bars late. The label shows on the exact bar of the high/low but only appears after 10 more bars, so it cannot be used for early entries. Once shown, it never changes (no repaint).
  • Both levels can be broken on the same candle (a very large candle in Wicks mode, or when the high level and low level are in inverted order). The break-up block runs first and then the break-down block, the trend ends up down, both BOS/CHoCH lines are drawn, and the alerts/◉ dots can fire together. Rare but possible on highly volatile data.
  • The on-chart text and the alerts use different criteria. The "CHoCH" text depends on the "Show CHoCH" box and is printed only when the old trend was opposite; the ◉ dot / Trend Change alert also fire on the first break (when the text says "BOS"). The two will not match 100%.
  • A shared ceiling of 500 labels. Swing labels HH/LH/HL/LL and the BOS/CHoCH text all count toward the 500 limit. On a long history the oldest labels disappear when the chart has too many swings; turn off "Show Swing Labels" to keep the BOS/CHoCH text for longer.
  • For Phase B (if state needs to be read): the variables prevHigh, prevLow, prevBreakDir, highBroken, lowBroken, bullishChange, bearishChange, bullishArrow, bearishArrow, upper, lower all live at global scope and can be read directly. The indicator does not keep a history of old levels, only the single latest high and low.
Zoom/Pan Layered Image
Background Overlay
− +

The indicator above just became a TRADING BOT — 1 AI click

📊Original indicator
→
🤖AI 1-click convert
→
⚙️Bot trading 24/7