Appearance

Personalize your experience

Mode
Accent Color
Direction
MarketplacestrategiesEfficiency Trend
QuaScript

Efficiency Trend

Free

Joins moves that are efficient on most of eight horizons

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
quascriptstrategyefficiencytrendkaufman
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.

Efficiency Trendengine 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

Joins trends when price moves efficiently on several horizons at once (Kaufman efficiency, signed by direction, above the threshold on most of eight horizons) and exits when the move turns noisy again or a Kaufman-average trailing stop is hit.


Settings

Efficiency threshold: 0.2

Horizons required (of 8): 5

Stop (ATR): 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 "Efficiency Trend" {
      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/// Joins trends when price moves efficiently on several horizons at once (Kaufman efficiency,
      11/// signed by direction, above the threshold on most of eight horizons) and exits when the move
      12/// turns noisy again or a Kaufman-average trailing stop is hit.
      13thr = param.float(0.2, title = "Efficiency threshold", min = 0.05, max = 0.95, step = 0.01)
      14need = param.int(5, title = "Horizons required (of 8)", min = 1, max = 8)
      15stopk = param.float(2.5, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1)
      16up_n = 0
      17dn_n = 0
      18for len in [8, 13, 21, 34, 55, 89, 144, 233] {
      19 q = hft.efficiency(close, len) * math.sign(close - close[len])
      20 if q > thr { up_n := up_n + 1 }
      21 if q < -thr { dn_n := dn_n + 1 }
      22}
      23kama = ta.kaufman(close, 21, 2, 30)
      24a = ta.atr(14)
      25flat = position.size == 0
      26if flat and up_n >= need and not math.is_na(a) {
      27 order.market("L", side.long)
      28 exit.bracket("L stop", entry = "L", stop = close - stopk * a, trail_offset = stopk * a, trail_trigger = close + a)
      29}
      30if flat and dn_n >= need and not math.is_na(a) {
      31 order.market("S", side.short)
      32 exit.bracket("S stop", entry = "S", stop = close + stopk * a, trail_offset = stopk * a, trail_trigger = close - a)
      33}
      34if position.size > 0 and (up_n < need / 2 or close < kama) { exit.close_all() }
      35if position.size < 0 and (dn_n < need / 2 or close > kama) { exit.close_all() }
      36risk.max_drawdown(25)
      37render.line(kama, "Kaufman average", color = up_n >= need ? color.lime.300 : dn_n >= need ? color.fuchsia.400 : color.slate.400, width = 2)
      38render.candle_color(up_n >= need ? color.lime.500 : dn_n >= need ? color.fuchsia.500 : na)
      39 
      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.