TradingView indicators

SSL Channel indicator: high/low averages and state changes

SSL Channel tracks two moving averages and remembers which side price last broke. In the close-based version, a close above the high average sets bullish state +1; a close below the low average sets bearish state -1. Inside the channel, the previous state survives. That memory explains why a pullback can leave the SSL direction unchanged.

H = SMA(high, N); L = SMA(low, N)
Close > H: +1 | Close < L: -1 | Otherwise: previous state

A state is a calculation result, not a prediction or an order.

Check the nine-bar example

Which SSL script are you using?

For the community script by ErwinBeckers, use the author's SSL channel listing on TradingView. This page explains an explicit SMA state model and supplies an educational Pine v6 implementation with close confirmation. It does not claim to reproduce every community variant.

SSL Hybrid by Mihkel00 is a separate script. Its author describes a baseline, a secondary SSL for continuation trades and a third SSL for exits. Matching the name or one MA length does not make the basic channel produce Hybrid entries and exits. Check the author, script version and all input settings before comparing screenshots or signals.

The formula keeps direction inside the channel

Calculate H and L from the most recent N highs and lows, including the current bar. For equal-length SMAs, H − L equals the average of those bars' high-low ranges, so H cannot be below L on valid OHLC data. The state, often called HLV, follows these rules at each confirmed close:

Close-based SSL state and line assignment
Close conditionNew HLVSSL Up / SSL Down
Close > H+1H / L
Close < L-1L / H
L ≤ Close ≤ HPrevious HLVKeep the previous assignment
No valid averages or no initial break0 in this exampleHidden until direction exists

Equality does not flip the state. If H = 13 and L = 9, a close of exactly 13 or 9 keeps the prior direction. Also, SSL Up is a line name, not a promise that it is geometrically above SSL Down: their assignments swap when the state reverses.

A nine-bar example you can recalculate

These are invented OHLC prices in arbitrary price units, not historical returns. Use N = 3 and initial HLV = 0. Averages shown below are rounded to four decimals; comparisons use unrounded values. Open is included to make the candles reproducible but is not an input to this close-based SSL calculation.

Three-bar SSL calculation from nine OHLC candles
BarOpenHighLowCloseHLHLVResult
1101289Warm-upWarm-up0No direction
2913910Warm-upWarm-up0No direction
310141013.513.00009.0000+1Initialize; no flip
413.514101113.66679.6667+1Inside; hold +1
5111288.513.33339.3333-1Bearish flip
691291112.66679.0000-1Inside; hold -1
71114101312.66679.0000+1Bullish flip
8131388.513.00009.0000-1Bearish flip
991491413.66679.0000+1Bullish flip

At bar 5, H = (14 + 14 + 12) / 3 = 13.3333 and L = (10 + 10 + 8) / 3 = 9.3333. Close 8.5 is below L, so HLV flips from +1 to -1. At bar 6, close 11 is back inside the channel, but HLV stays -1. Only bar 7's close of 13 breaks above H = 12.6667 and reverses the state. Bars 7, 8 and 9 then flip on consecutive closes, demonstrating how a range can produce repeated reversals.

Price crosses, line crosses and flips are different tests

Price can cross back above L while still below H. Bar 6 does exactly that and leaves bearish HLV unchanged. A bullish reversal requires the previous HLV to be -1 and the new HLV to be +1; merely being above an average is insufficient.

For this equal-length SMA model, SSL Up minus SSL Down is HLV × (H − L) once HLV is nonzero. When channel width is strictly positive on both bars, a line crossover corresponds to a state reversal. If the width becomes zero, the lines can touch and separate without a reversal. Initialization can also differ between scripts. Test HLV transitions directly when you mean flips, rather than assuming every drawn crossing is a new trade.

Changing the two lengths independently, using different MA types, or using an overshooting smoother changes the assumptions behind this comparison. A wick-based version changes the trigger too: one wide candle can pierce both averages, so the script must specify which condition wins. The example below uses closes and equal-length SMAs to avoid that ambiguity.

Pine Script v6 with confirmed flip alerts

Paste this indicator into TradingView's Pine Editor, save it and add it to a standard candlestick chart. It defaults to 10 bars as an example setting; use 3 to reproduce the table's calculation on the same inputs. Read HLV and the two underlying averages in the Data Window. UP and DOWN labels mark reversals, not the first assignment from state 0.

Pine Script v6 · indicator
//@version=6
indicator("SSL Channel: confirmed state", overlay=true)

length = input.int(10, "SMA length", minval=1)
maHigh = ta.sma(high, length)
maLow = ta.sma(low, length)
ready = not na(maHigh) and not na(maLow)

// Keep the last confirmed direction until the opposite boundary is broken.
var int hlv = 0
previousState = nz(hlv[1], 0)
if barstate.isconfirmed and ready
    hlv := close > maHigh ? 1 : close < maLow ? -1 : previousState

// Zero means no direction has been established yet.
sslUp = hlv == 0 ? na : hlv == 1 ? maHigh : maLow
sslDown = hlv == 0 ? na : hlv == 1 ? maLow : maHigh
bullFlip = barstate.isconfirmed and hlv == 1 and previousState == -1
bearFlip = barstate.isconfirmed and hlv == -1 and previousState == 1

upPlot = plot(sslUp, "SSL Up", color=color.teal, linewidth=2)
downPlot = plot(sslDown, "SSL Down", color=color.orange, linewidth=2)
fill(upPlot, downPlot, color=hlv == 1 ? color.new(color.teal, 85) : color.new(color.orange, 85), title="SSL state")
plot(hlv, "Confirmed HLV state", display=display.data_window)
plot(maHigh, "High SMA", display=display.data_window)
plot(maLow, "Low SMA", display=display.data_window)
plotshape(bullFlip, title="Bullish flip", text="UP", style=shape.labelup, location=location.belowbar, color=color.teal, textcolor=color.white)
plotshape(bearFlip, title="Bearish flip", text="DOWN", style=shape.labeldown, location=location.abovebar, color=color.orange, textcolor=color.white)
alertcondition(bullFlip, "Confirmed bullish SSL flip", "SSL state changed from -1 to +1 at bar close.")
alertcondition(bearFlip, "Confirmed bearish SSL flip", "SSL state changed from +1 to -1 at bar close.")

The code updates HLV only when barstate.isconfirmed is true. The current high and low averages still move while a bar is open; the state and reversal labels wait for the close. Select a confirmed flip condition when creating an alert and use Once Per Bar Close. This indicator contains no orders or strategy return calculation.

Where the rules can fail as trading signals

  • In sideways trading, closes can alternate across both boundaries. Close confirmation does not remove the consecutive flips shown above.
  • Waiting for the opposite close can surrender part of a move. A flip is not a stop-loss price, and a gap can move beyond a planned exit.
  • An unconfirmed cross may disappear before the close. Historical candle data cannot establish every intrabar path.
  • Changing the symbol feed, session, timeframe, chart type or available history can change the averages and remembered state. Compare identical inputs.
  • An attractive length on one sample may fail elsewhere. Define entry timing, exit rules, position size, fees and slippage before evaluating a separate test period.

TradingView's repainting documentation explains why closing-bar logic addresses only part of the historical-versus-realtime problem. This page is educational information, not investment advice; neither a confirmed state nor a syntax check demonstrates profitability.

Turn the state into an explicit strategy requirement

Pineify's Pine Script AI Coding Agent can help draft or modify the script from specified rules. For example, ask for a long-only strategy that enters on a confirmed -1 to +1 reversal, ignores the first 0 to +1 assignment, exits on a confirmed +1 to -1 reversal, and reports commissions and slippage. Specify order fill timing separately from signal timing, then request a syntax check and compare the generated state values against the table.

That workflow produces code for review and testing. The example on this page does not place broker orders, include SSL Hybrid filters or establish a profitable parameter set.

SSL Channel questions

Sources and related indicators

Source listings and documentation checked October 17, 2026. The table is a synthetic calculation, not an author backtest.

  • ErwinBeckers: SSL channel

    Author-published TradingView script dated March 28, 2019. Use this listing when looking for that community script.

  • Mihkel00: SSL Hybrid

    A separate script with baseline, continuation and exit components; its credits include ErwinBeckers.

  • TradingView: Bar states

    barstate.isconfirmed is true on historical bars and on the closing update of a realtime bar.

  • TradingView: Repainting

    Explains fluid realtime prices, historical versus live calculations and data revisions.

Review simple moving averages for the underlying window calculation, or Supertrend for a different stateful indicator based on ATR. Browse the TradingView indicator directory for other calculation guides.