Appearance
Personalize your experience
Mode
Accent Color
Direction
Skew Regime Trend
FreeEMA trend trades filtered by the skew of returns
0.0(0)
0 installs 0 0 commentsQ
quascriptstrategyskewtrend
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.
Skew Regime 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
Trend following that respects the shape of returns: longs on EMA crosses only while returns are right-skewed (gains come in bursts), shorts only while they are left-skewed (losses come in bursts). Exit on the opposite cross or an ATR stop.
Settings
Fast EMA: 20
Slow EMA: 60
Skew window: 100
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 "Skew Regime 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 | /// Trend following that respects the shape of returns: longs on EMA crosses only while returns are |
| 11 | /// right-skewed (gains come in bursts), shorts only while they are left-skewed (losses come in |
| 12 | /// bursts). Exit on the opposite cross or an ATR stop. |
| 13 | fast = param.int(20, title = "Fast EMA", min = 2, max = 500) |
| 14 | slow = param.int(60, title = "Slow EMA", min = 5, max = 1000) |
| 15 | win = param.int(100, title = "Skew window", min = 20, max = 2000) |
| 16 | stopk = param.float(2.5, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1) |
| 17 | r = math.log(close / close[1]) |
| 18 | sk = stat.skew(r, win) |
| 19 | f = ta.ema(close, fast) |
| 20 | s = ta.ema(close, slow) |
| 21 | a = ta.atr(14) |
| 22 | flat = position.size == 0 |
| 23 | if flat and ta.cross_up(f, s) and sk > 0 and not math.is_na(a) { |
| 24 | order.market("L", side.long) |
| 25 | exit.bracket("L stop", entry = "L", stop = close - stopk * a) |
| 26 | } |
| 27 | if flat and ta.cross_down(f, s) and sk < 0 and not math.is_na(a) { |
| 28 | order.market("S", side.short) |
| 29 | exit.bracket("S stop", entry = "S", stop = close + stopk * a) |
| 30 | } |
| 31 | if position.size > 0 and ta.cross_down(f, s) { exit.close_all() } |
| 32 | if position.size < 0 and ta.cross_up(f, s) { exit.close_all() } |
| 33 | risk.max_drawdown(25) |
| 34 | render.line(f, "Fast", color = sk > 0 ? color.lime.300 : color.red.300, width = 1.5) |
| 35 | render.line(s, "Slow", color = color.translucent(color.slate.300, 30), width = 1.5) |
| 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.