TrendPine Script v6

ta.supertrend()

Supertrend

The Supertrend indicator is a trend-following overlay that uses ATR to calculate its values.

Syntax

Syntax
ta.supertrend(factor, atrPeriod) → [series float, series float]

Arguments

ParameterTypeDescription
factorsimple int/floatATR multiplier.
atrPeriodsimple intATR period.

Returns

Tuple of two series: supertrend line and direction (-1 for uptrend, 1 for downtrend).

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.supertrend")
[supertrend, direction] = ta.supertrend(3, 10)
plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style=plot.style_linebr)

Trading Applications

Identify clear trend direction with visual overlay

Use as a dynamic trailing stop

Generate buy/sell signals on direction changes

Combine with volume for breakout confirmation

Related Functions

Frequently Asked Questions

Generate ta.supertrend() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.supertrend() and other built-in functions instantly.