Appearance
Personalize your experience
Autocorrelation Fade
FreeFades outsized bars in a significant reversal regime
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.
About
Fades outsized one-bar moves, but only while one-bar returns are significantly negatively autocorrelated, i.e. while the market has been giving back its moves. Outside that regime the same moves are left alone. Trades are short-lived by design. Entry: lag-1 autocorrelation below minus the significance band, and the bar's return beyond k standard deviations; the fade is against that bar. Exit: target half the bar's range back, ATR stop, or after `hold` bars. Risk: 1 % per trade. Method: sample autocorrelation with the 2 / sqrt(n) significance band.
Settings
Autocorrelation window: 150
Move size (sigma): 1.8
Maximum bars held: 6
Stop (ATR): 1.5
Measured backtests
Run by the backtest engine on public candles, 2025-11-01 to 2026-11-01, with the script's own commission and slippage, on BTCUSDT 1h (Binance) and ETHUSDT 1h (Binance). The figures per market are in the Measured backtest panel below. Past results do not predict future returns.
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
- ▸ lag-1 autocorrelation below minus the significance band, and the bar's return beyond k standard deviations; the fade is against that bar
Exit Conditions
- ▸ target half the bar's range back, ATR stop, or after `hold` bars
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
-4.3%
Return
-1.43
Sharpe
-6.0%
Max DD
47.1%
Win Rate
17
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 17 | -4.3% | -1.43 | -6.0% | 47.1% | 0.45 |
| ETHUSDT 1h | 6 | -1.2% | -0.62 | -1.9% | 50.0% | 0.58 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Autocorrelation Fade" { |
| 2 | overlay = true |
| 3 | capital = 100000 |
| 4 | commission = 0.05 |
| 5 | slippage = 1 |
| 6 | sizing = risk_percent |
| 7 | max_leverage = 1 |
| 8 | size = 1 |
| 9 | pyramiding = 1 |
| 10 | } |
| 11 | /// Fades outsized one-bar moves, but only while one-bar returns are significantly negatively |
| 12 | /// autocorrelated, i.e. while the market has been giving back its moves. Outside that regime the |
| 13 | /// same moves are left alone. Trades are short-lived by design. |
| 14 | /// Entry: lag-1 autocorrelation below minus the significance band, and the bar's return beyond |
| 15 | /// k standard deviations; the fade is against that bar. Exit: target half the bar's range back, |
| 16 | /// ATR stop, or after `hold` bars. Risk: 1 % per trade. |
| 17 | /// Method: sample autocorrelation with the 2 / sqrt(n) significance band. |
| 18 | use "viz/premium" as pr |
| 19 | len = param.int(150, title = "Autocorrelation window", min = 30, max = 3000, group = "Regime") |
| 20 | k_sd = param.float(1.8, title = "Move size (sigma)", min = 0.5, max = 5, step = 0.1, group = "Entry") |
| 21 | hold = param.int(6, title = "Maximum bars held", min = 1, max = 100, group = "Exit") |
| 22 | stop_k = param.float(1.5, title = "Stop (ATR)", min = 0.3, max = 6, step = 0.1, group = "Risk") |
| 23 | r = math.log(close / close[1]) |
| 24 | ac = stat.autocorr(r, len, 1) |
| 25 | sd_now = stat.stdev(r, len) |
| 26 | sd = sd_now[1] |
| 27 | sig = 2 / math.sqrt(len) |
| 28 | reverting = ac < -sig |
| 29 | a = ta.atr(20) |
| 30 | big_up = r > k_sd * sd |
| 31 | big_dn = r < -k_sd * sd |
| 32 | flat = position.size == 0 |
| 33 | if flat and reverting and big_dn { |
| 34 | order.market("L", side.long) |
| 35 | exit.bracket("L exit", entry = "L", stop = close - stop_k * a, target = close + 0.5 * (high - low)) |
| 36 | } |
| 37 | if flat and reverting and big_up { |
| 38 | order.market("S", side.short) |
| 39 | exit.bracket("S exit", entry = "S", stop = close + stop_k * a, target = close - 0.5 * (high - low)) |
| 40 | } |
| 41 | if position.size != 0 and position.bars_held >= hold { exit.close_all() } |
| 42 | risk.max_drawdown(25) |
| 43 | render.mark(reverting and big_dn, shape = shape.circle, at = anchor.below_bar, color = color.lime.300, size = 0.6, title = "Fade down move") |
| 44 | render.mark(reverting and big_up, shape = shape.circle, at = anchor.above_bar, color = color.violet.300, size = 0.6, title = "Fade up move") |
| 45 | render.background(reverting ? color.translucent(color.lime.500, 95) : na) |
| 46 | persist t = draw.table.create(anchor.top_right, 4, 2) |
| 47 | if bar.is_last { |
| 48 | pr.heading(t, 2, "Autocorrelation Fade", "Strategy · lag-1 reversal regime") |
| 49 | pr.row(t, 2, "Lag-1 autocorrelation", str.format("{:+.3f}", ac), reverting ? pr.BULL : pr.LABEL) |
| 50 | pr.row(t, 3, "Regime", reverting ? "Reverting: fading" : "No edge", color.white) |
| 51 | } |
| 52 |
Reviews
No reviews yet. Be the first to review this listing.