Skip to main content

Supertrend Strategy

Discover our SuperTrend Strategy PineScript template, designed for traders seeking to use SuperTrend indicator. Easily backtest on TradingView and live execute this template on AlgoTest. Adjusting inputs like ATR Length, Multiplier, target points, and stop loss points to suit your trading preferences.

Supertrend Indicator Pinescript

strategy("Supertrend Strategy", overlay=true)

// Input parameters
atr_length =, title="ATR Length")
multiplier = input.float(3.0, title="Multiplier")

target_points =, title="Target Points")
stop_loss_points =, title="Stop Loss Points")

// Calculate ATR and Supertrend
atr = ta.atr(atr_length)
upper_band = hlc3 + (multiplier * atr)
lower_band = hlc3 - (multiplier * atr)
is_uptrend = close > lower_band
is_downtrend = close < upper_band
trend_changed = (is_uptrend[1] and is_downtrend) or (is_downtrend[1] and is_uptrend)

// Strategy logic
long_condition = is_uptrend and trend_changed
short_condition = is_downtrend and trend_changed

// Plot Supertrend
plot(is_uptrend ? lower_band : na,, title="Supertrend Up", style=plot.style_linebr)
plot(is_downtrend ? upper_band : na,, title="Supertrend Down", style=plot.style_linebr)

// Strategy entry and exit
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)

// Calculate target and stop loss levels
long_target = strategy.position_avg_price + target_points
long_stop_loss = strategy.position_avg_price - stop_loss_points
short_target = strategy.position_avg_price - target_points
short_stop_loss = strategy.position_avg_price + stop_loss_points

// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)

Understanding the Supertrend Indicator

History of the Supertrend Indicator

The Supertrend indicator was developed primarily for intraday traders. It's a trend-following indicator that's used across different markets to determine the direction of the current price momentum. The name "Supertrend" is derived from its ability to identify the prevailing trend.

A Brief About SuperTrend

The Supertrend indicator is a volatility-based calculation that combines ATR (Average True Range) and median price data to determine potential buy and sell signals in a market. It is represented visually by a line that follows the price, changing color based on the trend direction.

How to Use the Indicator for Analysis

The Supertrend indicator is typically used in technical analysis as follows:

Buy Signal: When the Supertrend line changes from red to green and appears below the price.

Sell Signal: When the Supertrend line changes from green to red and appears above the price. Adjusting its settings (such as the period and multiplier) can tailor the indicator's sensitivity to market changes.

Best Use Cases

The Supertrend indicator excels in markets exhibiting strong trends. It is best used:

  • In combination with other indicators like RSI or MACD to confirm trends and potential reversals.
  • For establishing stop-loss levels, as the indicator provides a clear representation of market volatility.
  • Across different time frames, but it performs well particularly in longer time frames such as daily charts for reducing noise and false signals.


What is a good setting for the Supertrend indicator?

A common setting is 7 for the period and 3 for the multiplier, but these can be adjusted based on the volatility and characteristics of the asset being traded.

What does Supertrend 7 3 mean?

This setting refers to a period of 7 and a multiplier of 3, which helps in determining the sensitivity and the responsiveness of the indicator to price changes.

Is Supertrend a good indicator?

Yes, it is particularly effective in trending markets for identifying direction and optimal entry and exit points.

How effective is Supertrend for intraday trading?

It is highly regarded among intraday traders for its simplicity and effectiveness in trend-based strategies.

Can Supertrend be used for all types of assets?

Yes, it is versatile and can be used across stocks, commodities, forex, and even cryptocurrency markets.

For more detailed strategies and settings, visit AlgoTest's Strategy Builder and Signals for practical applications of the Supertrend indicator in real market scenarios.