Appearance

Personalize your experience

Mode
Accent Color
Direction
MarketplacestrategiesRegression Supertrend Trader
QuaScript

Regression Supertrend Trader

Free

Always-in trading on the regression supertrend

0.0(0)
0 installs 0 0 comments
Q
433 listings

The QuaTick team's QuaScript analyses, run by the native C++ engine.

View Profile
quascriptstrategysupertrendregression
Free
Backtest this strategy Open in QuaCode Edit in IDE
Version
Updated
Compatible

Live engine preview

QuaScriptQuaScript

The QuaScript engine's own output on the chart the terminal uses. Change the settings or edit the code and press Run to recompute it.

Regression Supertrend Traderengine result
Loading the engine result…
quatick-charts · QuaScript engine on synthetic 1-minute bars · drag to pan · scroll to zoom · Run executes the script on the engine (⌘/Ctrl+Enter while editing)

About

Always-in trend trading on a supertrend that trails the regression line: long on a bull flip, short on a bear flip, with the trailing stop as the protective exit.


Settings

Regression window: 30

ATR factor: 2.5


Backtest it yourself

Open it on the backtesting page to run it on any symbol, interval and date range, then use Monte Carlo, optimisation, walk-forward and robustness tests.

Strategy Rules

Entry Conditions

    Exit Conditions

      Source Code

      Edit in IDE
      quascript
      1strategy "Regression Supertrend Trader" {
      2 overlay = true
      3 capital = 100000
      4 commission = 0.05
      5 slippage = 1
      6 sizing = risk_percent
      7 size = 1
      8 max_leverage = 1
      9}
      10/// Always-in trend trading on a supertrend that trails the regression line: long on a bull flip,
      11/// short on a bear flip, with the trailing stop as the protective exit.
      12len = param.int(30, title = "Regression window", min = 5, max = 500)
      13factor = param.float(2.5, title = "ATR factor", min = 0.5, max = 10, step = 0.1)
      14(reg, _, _) = stat.linreg(close, len, 0)
      15a = ta.atr(14)
      16persist up = na
      17persist dn = na
      18persist dir = 1
      19up := math.is_na(up) ? reg - factor * a : reg[1] > up ? math.max(reg - factor * a, up) : reg - factor * a
      20dn := math.is_na(dn) ? reg + factor * a : reg[1] < dn ? math.min(reg + factor * a, dn) : reg + factor * a
      21if dir == 1 and reg < up { dir := -1 }
      22else if dir == -1 and reg > dn { dir := 1 }
      23stop = dir == 1 ? up : dn
      24ready = not math.is_na(stop)
      25if ready and dir == 1 and dir[1] == -1 {
      26 order.market("L", side.long)
      27 exit.bracket("L stop", entry = "L", stop = stop)
      28}
      29if ready and dir == -1 and dir[1] == 1 {
      30 order.market("S", side.short)
      31 exit.bracket("S stop", entry = "S", stop = stop)
      32}
      33risk.max_drawdown(30)
      34render.line(dir == 1 ? stop : na, "Bull stop", color = color.emerald.400, width = 2)
      35render.line(dir == -1 ? stop : na, "Bear stop", color = color.rose.400, width = 2)
      36 
      Read-only preview. Open in QuaCode to edit and deploy.

      Reviews

      No reviews yet. Be the first to review this listing.

      Discussion

      Sign in to join the discussion. Your posts and replies show up on your profile.