Technical Analysis · Supertrend

What Is Supertrend? —
Tuning it, and why it fits automated trading signals

2026-08-18·10 min read

You slap Supertrend onto TradingView. The line is green — long. The line flips red — short. You wire the flip as an alert condition and point the webhook (the HTTP notification TradingView fires when the alert triggers) at TVSBot or any other execution endpoint. First time you run it live, two things happen.

First: the bar hasn't closed, and the signal already went out. Second: the same bar flips back later, and by the time you notice, the position has reversed twice and you've already paid a round of fees. Supertrend isn't broken and your strategy logic isn't wrong — it's that its "answer right now" personality doesn't line up with the cadence of automated execution.

Straight to the point
Supertrend's flip signal has to be tied to bar close before you send it. Pine Script (TradingView's built-in strategy language) offers two ways: alertcondition() plus the UI's "Once Per Bar Close" trigger mode, or barstate.isconfirmed inside the condition. Both filter out the intra-bar flicker. That's the single most important sentence in this piece.

What Supertrend Is Computing — ATR Sets the Width, Close Sets the Direction

Supertrend has two layers. The first is the base band: take each bar's midpoint (high + low) / 2 as the centerline, then push multiplier × ATR in each direction to get the upper and lower rails. ATR is Average True Range, a measure of how much price has been moving lately — a high ATR means volatile, so the band is wide; a low ATR means calm, so the band is tight.

The second layer is direction lock: whether the plotted line is the upper or lower rail depends on the current trend. When short, it plots the upper rail, which can only step down (if a new bar computes a wider upper rail, it keeps the tighter one). When long, it plots the lower rail, which can only step up. The flip trigger is simple: close crosses the current line. Close falls through the lower rail, flip short; close pushes above the upper rail, flip long.

What this rule buys you
The "trailing" part is what makes this work. It stops Supertrend from getting whipsawed back to the centerline by noise inside a trend — once locked, only a real reversal flips it. That's also why many people use it as a **dynamic stop-loss**: when long, the Supertrend line is your stop; break it, you're out.

Two Parameters: ATR Period and Multiplier

Supertrend has two knobs. Everything else is derived from these.

10
TradingView's default ATR period for Supertrend
3
Default multiplier
-1 / +1
direction value: long / short
ParameterWhat it doesTurn it upTurn it down
ATR periodSample length (in bars) for ATRSmoother volatility reading, slower to reactMore sensitive to recent moves, flips more often
multiplierDistance from center to rails (in ATRs)Wider band, fewer flips, tolerates noiseTighter band, denser signals, catches small moves

Supertrend's two parameters and what each one controls. (Verified 2026-08.)

TradingView's built-in ta.supertrend(factor, atrPeriod) defaults to ATR period 10, multiplier 3. TVSBot's Pine templates page uses the same pair — this is where the community starts, not because it's "best," but because it's the shared starting point. Want it more conservative, push multiplier to 4 or 5; want it more sensitive, drop it to 2.

pine
//@version=5
        strategy("TVSBot SuperTrend", overlay=true)

        atrPeriod = input.int(10, "ATR period")
        factor    = input.float(3.0, "SuperTrend multiplier")

        [supertrend, direction] = ta.supertrend(factor, atrPeriod)

        longCondition  = ta.change(direction) < 0  // flip from short to long
        shortCondition = ta.change(direction) > 0  // flip from long to short

        if longCondition
            strategy.entry("Long",  strategy.long,  alert_message='{"side":"buy"}')
        if shortCondition
            strategy.entry("Short", strategy.short, alert_message='{"side":"sell"}')

That's the official TVSBot Pine template, source /docs/pine-templates. ta.supertrend()'s first return value is the line price; the second is direction — -1 is long, 1 is short. So ta.change(direction) < 0 means "this bar flipped from short to long."

Why It Beats RSI/MACD as an Automation Signal

Oscillators — RSI (Relative Strength Index), MACD (fast/slow moving-average spread) — produce continuous values. RSI is a number between 0 and 100; MACD histogram is a shifting spread. To turn either into an automated signal, you have to draw your own line on top (buy when RSI drops below 30, buy when the histogram crosses zero), and that line gets crossed back and forth in chop.

Supertrend is different: it emits discrete state — only up and down, and the flip is a single unambiguous event. There's no "almost flipping" or "about to flip." That matters for webhooks, because a webhook only understands "triggered" or "not triggered" — it can't transmit an in-between state like "getting close."

RSI / MACDSupertrend
Signal shapeContinuous valueDiscrete direction
Flip criterionCross a custom thresholdCross the current trailing band
Stop-loss locationDefined separatelyThe indicator line itself
Behavior in chopNoisy, misfires oftenFew flips, but the full leg
Fit as webhook triggerNeeds an added filterThe flip is the trigger

To be clear: this doesn't mean Supertrend is inherently "more accurate." It's that structurally its interface lines up with automated execution better — you don't need much wrapper logic to turn it into a clean signal source.

But — Signals Flicker Before the Bar Closes

Here is how Pine Script computes "the current bar": on every incoming tick, it recomputes as if the bar just closed at that price. So the current segment of Supertrend you see on the chart is being overwritten in real time.

Not repainting in the strict sense, but it feels the same
Past bars aren't rewritten (that would be repainting in the strict sense); but the direction value on the current bar can be different on every tick until close. Set your alert to "Once Per Bar" and it fires the first time the condition is met — even if that only lasted half a second. The actual direction at the moment of close could be the opposite.

Pine has two built-in ways to filter that. In the TradingView UI, alertcondition() lets you pick Once Per Bar Close, which fires only when the condition is met at bar close. And barstate.isconfirmed — a built-in that's only true at bar close — can go straight into your if condition to filter intra-bar flicker.

The template above uses the strategy.entry path via alert() / alert conditions, so the normal path relies on the trigger mode you set when creating the alert. If you pull out a custom condition via alertcondition(), you have to pick the close option — otherwise everything above is wasted.

Four Things to Check Before Pointing a Webhook at It

If any of the following isn't in place, your Supertrend signals will either flicker intra-bar or behave differently from what you expect. Get all of them green before going live.

1
Did you pick Once Per Bar Close as the alert trigger mode?
NoGo back to alert settings and fix that. It's problem zero — nothing else matters until it's set.
YesMove on.
2
Does direction in the Data Window bounce around intra-bar?
YesNormal. Intra-bar signals don't count; wait for the close tick.
NoYour timeframe may be off — confirm the chart and the alert are on the same timeframe.
3
After a few days of dry-run, do the signal timestamps line up with the flip positions on the chart?
They line upYou're ready for live.
OffGo back to the first two questions — usually it's alert trigger mode or a timeframe mismatch.
  • When creating the alert, pick Once Per Bar Close, not Once Per Bar. The latter fires the first moment the condition is met, and intra-bar flip-flops are the norm.
  • If you write your own alertcondition(), or your strategy entry/exit conditions can't rely on the UI, add and barstate.isconfirmed inside the condition. That's Pine's recommended intra-bar filter.
  • Use TradingView's Data Window (top-right {} icon → Data Window) to watch the direction column. Stare at a single bar as it forms; if the value flips back and forth, so will your alerts.
  • In the webhook payload, {{strategy.order.action}} is the order direction TradingView had at the exact moment of trigger. What you send before the bar closes isn't necessarily what you'd send after — so the first item is non-negotiable, otherwise this payload is lying to you.
  • In the TVSBot dashboard, enable dry-run (runs the execution flow without placing real orders) for a few days. Compare each Supertrend flip on the chart with the timestamp the dashboard received. Any drift, go back to the first three.

An Honest Aside: What Supertrend Isn't Good At

Supertrend performs best in single-direction trends — once locked, it just rides the wind. Flipped around, in choppy ranges it takes slap after slap: no matter how wide you set the band, price bouncing inside eventually pushes through a line, flips, and flips back. That's not bad tuning; it's how the indicator is built.

It also only gives you direction, not size. Short-to-long is buy; long-to-short is sell. But how much to buy, whether to add on, when to take profit — those are all separate. In the TVSBot payload, margin_pct, tp_pct, and sl_pct are the fields you have to decide on top of the Supertrend signal (how to size positions in webhook-driven automation breaks that apart in more detail). The indicator doesn't know your account size or your risk appetite.

Another thing users routinely miss: Supertrend's signal is scoped to a timeframe. Parameters tuned on a 4H chart don't transfer to 15m as-is. Multiplier 3 is steady on 4H; on 5m it may flip every two hours. Tune parameters against the timeframe you plan to run, or you'll think you're running a conservative strategy while actually running a noise machine.

FAQ

Can I use the defaults (ATR 10, multiplier 3) as-is?
Use them as a starting point, not a destination. That pair is the common demo for ta.supertrend() and the TVSBot template default, but whether it's appropriate depends on your timeframe and the asset's volatility. Use TradingView's Strategy Tester to backtest ATR period 7–14 and multiplier 2–5, and pick the pair whose max drawdown you can stomach.
Why did the line flip color, but the direction value didn't change?
Almost always a timeframe mismatch — your chart is 15m, your alert is on 1H; or you're watching the live bar and direction is still moving around. The Data Window shows the actual value of direction at that moment.
Does Once Per Bar Close make me enter one bar late?
Yes, and that's deliberate. Bar close is when "this bar really flipped" gets confirmed; the pre-close signal may retract, which isn't conservative — it's noise. Backtest and live have to use the same trigger mode, otherwise backtest numbers lie.
Can Supertrend be combined with other indicators?
Yes — and it needs help in choppy ranges. A common approach is to add a trend confirmation filter: e.g. 200 EMA (see the full moving-averages guide) as directional bias and only take Supertrend flips in that direction, or add a volume condition to filter low-volume flips. More filters, fewer signals — the tradeoff is yours.
If I send Supertrend webhooks to TVSBot, can I place multiple orders from the same Pine file?
Yes, but the default is counterintuitive: strategy()'s pyramiding parameter defaults to 0, meaning "only one entry allowed per direction — subsequent same-direction strategy.entry() calls get rejected." To actually add on, you have to explicitly write pyramiding=2 (or higher) in the strategy(...) declaration. To hold multiple independent positions, use TVSBot's strategy field in the payload to distinguish strategies, or run a separate Pine file per position. That's not a Supertrend thing — it's a Pine position-sizing pitfall.

Get started

Ready to ship what you just learned?

Route your Supertrend flip signals into the exchange — TVSBot uses your own API keys, supports dry-run, and puts risk controls in your hands. Seven exchanges supported.

Get started for free