Rearview Download

Supertrend trend following

Ride a trend with a trailing line that only tightens while the trend lasts: buy when the close crosses above the Supertrend line, sell when it crosses back below. The line sits width average true ranges from each bar's midpoint.

Strategies · supertrend_trend.rvw

language 1
strategy "Supertrend trend following" {
  universe   members("SYN500")
  filter     adv(20) > $500000
  line       supertrend(10, width)
  enter long when crosses_above(close, line) and close > sma(close, 100)
  rank by    (close - line) / atr(10)
  size       5% of equity, max 15 positions
  exit when  crosses_below(close, line)
  param      width = 3 in 2..4 step 1
}

Functions it uses

adv, supertrend, crosses_above, sma, atr, crosses_below

Try it

File ▸ New Script from Example adds it to a project. The examples read the sample’s index label, SYN500, and market ETF, SYNSPY; when your data has neither, a sheet asks what to read instead, one of your index labels (or every stock and ETF) and a ticker, so the example runs on your data as it is.

Before you trust what it does on your data, see whether it’s luck: Is this result luck?