Appearance
Personalize your experience
Mode
Accent Color
Direction
Efficiency Trend
FreeJoins moves that are efficient on most of eight horizons
0.0(0)
0 installs 0 0 commentsQ
quascriptstrategyefficiencytrendkaufman
Live engine preview
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 IDEquascript
| 1 | strategy "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. |
| 13 | thr = param.float(0.2, title = "Efficiency threshold", min = 0.05, max = 0.95, step = 0.01) |
| 14 | need = param.int(5, title = "Horizons required (of 8)", min = 1, max = 8) |
| 15 | stopk = param.float(2.5, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1) |
| 16 | up_n = 0 |
| 17 | dn_n = 0 |
| 18 | for 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 | } |
| 23 | kama = ta.kaufman(close, 21, 2, 30) |
| 24 | a = ta.atr(14) |
| 25 | flat = position.size == 0 |
| 26 | if 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 | } |
| 30 | if 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 | } |
| 34 | if position.size > 0 and (up_n < need / 2 or close < kama) { exit.close_all() } |
| 35 | if position.size < 0 and (dn_n < need / 2 or close > kama) { exit.close_all() } |
| 36 | risk.max_drawdown(25) |
| 37 | render.line(kama, "Kaufman average", color = up_n >= need ? color.lime.300 : dn_n >= need ? color.fuchsia.400 : color.slate.400, width = 2) |
| 38 | render.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.