Appearance
Personalize your experience
Mode
Accent Color
Direction
Zero-Lag Trend
FreeZero-lag EMA cross trend entries filtered by slow regime baseline
0.0(0)
0 installs 0 0 commentsQ
quascriptstrategyemazero-lagtrend
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.
Zero-Lag 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
Trades crosses of a zero-lag EMA over a regular EMA in the direction of a slow EMA, with an ATR stop and an exit on the opposite cross.
Settings
Length: 34
Trend filter: 200
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 "Zero-Lag 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 | /// Trades crosses of a zero-lag EMA over a regular EMA in the direction of a slow EMA, with an ATR |
| 11 | /// stop and an exit on the opposite cross. |
| 12 | len = param.int(34, title = "Length", min = 2, max = 500) |
| 13 | trend = param.int(200, title = "Trend filter", min = 10, max = 2000) |
| 14 | stopk = param.float(2.5, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1) |
| 15 | z = ta.zero_lag(close, len) |
| 16 | e = ta.ema(close, len) |
| 17 | t = ta.ema(close, trend) |
| 18 | a = ta.atr(14) |
| 19 | flat = position.size == 0 |
| 20 | if flat and ta.cross_up(z, e) and close > t and not math.is_na(a) { |
| 21 | order.market("L", side.long) |
| 22 | exit.bracket("L stop", entry = "L", stop = close - stopk * a) |
| 23 | } |
| 24 | if flat and ta.cross_down(z, e) and close < t and not math.is_na(a) { |
| 25 | order.market("S", side.short) |
| 26 | exit.bracket("S stop", entry = "S", stop = close + stopk * a) |
| 27 | } |
| 28 | if position.size > 0 and ta.cross_down(z, e) { exit.close_all() } |
| 29 | if position.size < 0 and ta.cross_up(z, e) { exit.close_all() } |
| 30 | risk.max_drawdown(25) |
| 31 | render.line(z, "Zero-lag", color = color.cyan.300, width = 1.5) |
| 32 | render.line(t, "Trend filter", color = color.translucent(color.slate.300, 40), width = 1) |
| 33 |
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.