Tradingbot
Pine Script v6 · FREE RESOURCE

Supertrend

ATR-based trend overlay. Expect whipsaws in sideways markets and confirm signals on closed candles.

ICODERX Editorialv1.0.0Updated 11/20/20260 saves

Source code

v1.0.0
//@version=6
// ICODERX Trading — MIT License. Educational example.
indicator("ICODERX Supertrend", overlay=true)
length = input.int(10, "ATR length", minval=1)
factor = input.float(3.0, "Factor", minval=0.1, step=0.1)
[trend, direction] = ta.supertrend(factor, length)
plot(direction < 0 ? trend : na, "Uptrend", color=color.teal, style=plot.style_linebr)
plot(direction > 0 ? trend : na, "Downtrend", color=color.red, style=plot.style_linebr)
alertcondition(ta.change(direction) != 0 and barstate.isconfirmed, "Trend change", "Supertrend direction changed")
1 files · Read-only · MIT · Source is not executed here

How it works

ATR-based trend overlay. Expect whipsaws in sideways markets and confirm signals on closed candles.

Install on TradingView

  1. Open a TradingView chart and select Pine Editor.
  2. Create a new indicator and replace its contents with the complete source below.
  3. Save and select Add to chart. For alerts, create an Alert and select the script condition where available.

Configuration and examples

Begin with the defaults to understand behavior, then adjust for your timeframe. Compare trending, declining and ranging periods. Evaluate signals after candles close.

Limitations

Indicators use historical inputs and lag price. Open-candle values change on every tick. This code places no orders, promises no profit and has no verified backtest performance. This Pine Script runs in TradingView Pine Editor, not on the internal chart.

License

MIT — learn, modify and share with the copyright notice.

References

https://www.tradingview.com/pine-script-docs/

Educational content, not investment advice. Trading can result in capital loss. No profit is guaranteed.

FAQ

Is the source code free?

Yes. Examples use the MIT license and can be modified and shared with attribution.

Does this guarantee profit?

No. This is educational material. Independently validate assumptions, costs and risks.

Join the discussion