Appearance
Personalize your experience
Golden Pocket Continuation
FreeJoins impulse legs from the 50 - 61.8 % retracement
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
Joins an impulse leg on its first deep retracement. The newest leg between two confirmed swings must be an impulse (at least `impulse` ATR long). When price then retraces into the 50 - 61.8 % band of that leg (the "golden pocket") and prints a bar that closes back in the leg's direction above the prior bar's high, the pullback is treated as finished. The stop sits beyond the 78.6 % level, where the leg's structure would be broken, and the first target is a retest of the leg's end with the remainder aimed at the 127.2 % extension. Entry: up-leg of `impulse` ATR or more, low inside the pocket, bullish close above the prior high (mirror for down-legs). Exit: stop beyond the 78.6 % level, half at the leg end, the rest at the 127.2 % extension; setup cancelled once price passes 78.6 %. Risk: 1 % per trade.
Settings
Swing bars left: 10
Swing bars right: 5
Minimum leg (ATR): 4
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
- ▸ up-leg of `impulse` ATR or more, low inside the pocket, bullish close above the prior high (mirror for down-legs)
Exit Conditions
- ▸ stop beyond the 78.6 % level, half at the leg end, the rest at the 127.2 % extension; setup cancelled once price passes 78.6 %
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
0.6%
Return
0.11
Sharpe
-15.3%
Max DD
44.3%
Win Rate
122
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 122 | 0.6% | 0.11 | -15.3% | 44.3% | 1.02 |
| ETHUSDT 1h | 114 | 10.3% | 0.94 | -9.4% | 44.7% | 1.29 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Golden Pocket Continuation" { |
| 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 | /// Joins an impulse leg on its first deep retracement. The newest leg between two confirmed swings |
| 12 | /// must be an impulse (at least `impulse` ATR long). When price then retraces into the 50 - 61.8 % |
| 13 | /// band of that leg (the "golden pocket") and prints a bar that closes back in the leg's direction |
| 14 | /// above the prior bar's high, the pullback is treated as finished. The stop sits beyond the 78.6 % |
| 15 | /// level, where the leg's structure would be broken, and the first target is a retest of the leg's |
| 16 | /// end with the remainder aimed at the 127.2 % extension. |
| 17 | /// Entry: up-leg of `impulse` ATR or more, low inside the pocket, bullish close above the prior |
| 18 | /// high (mirror for down-legs). Exit: stop beyond the 78.6 % level, half at the leg end, the rest at |
| 19 | /// the 127.2 % extension; setup cancelled once price passes 78.6 %. Risk: 1 % per trade. |
| 20 | use "viz/premium" as pr |
| 21 | left = param.int(10, title = "Swing bars left", min = 2, max = 50, group = "Swings") |
| 22 | right = param.int(5, title = "Swing bars right", min = 1, max = 30, group = "Swings") |
| 23 | impulse = param.float(4.0, title = "Minimum leg (ATR)", min = 1, max = 20, step = 0.5, group = "Swings") |
| 24 | ph = ta.pivot_high(left, right) |
| 25 | pl = ta.pivot_low(left, right) |
| 26 | a = ta.atr(50) |
| 27 | persist hi_p = na |
| 28 | persist lo_p = na |
| 29 | persist hi_x = 0 |
| 30 | persist lo_x = 0 |
| 31 | persist leg = 0 |
| 32 | if not math.is_na(ph) { |
| 33 | hi_p := ph |
| 34 | hi_x := bar.index - right |
| 35 | leg := hi_x > lo_x and not math.is_na(lo_p) ? 1 : leg |
| 36 | } |
| 37 | if not math.is_na(pl) { |
| 38 | lo_p := pl |
| 39 | lo_x := bar.index - right |
| 40 | leg := lo_x > hi_x and not math.is_na(hi_p) ? -1 : leg |
| 41 | } |
| 42 | span = hi_p - lo_p |
| 43 | strong = span >= impulse * a |
| 44 | // up-leg retracement levels measured down from the high; down-leg levels measured up from the low |
| 45 | p50 = leg == 1 ? hi_p - span * 0.5 : lo_p + span * 0.5 |
| 46 | p618 = leg == 1 ? hi_p - span * 0.618 : lo_p + span * 0.618 |
| 47 | p786 = leg == 1 ? hi_p - span * 0.786 : lo_p + span * 0.786 |
| 48 | ext = leg == 1 ? hi_p + span * 0.272 : lo_p - span * 0.272 |
| 49 | persist armed = false |
| 50 | if (not math.is_na(ph) or not math.is_na(pl)) { armed := strong and leg != 0 } |
| 51 | if leg == 1 and low < p786 { armed := false } |
| 52 | if leg == -1 and high > p786 { armed := false } |
| 53 | go_l = armed and leg == 1 and low <= p50 and low >= p786 and close > open and close > high[1] and close < hi_p |
| 54 | go_s = armed and leg == -1 and high >= p50 and high <= p786 and close < open and close < low[1] and close > lo_p |
| 55 | flat = position.size == 0 |
| 56 | if flat and go_l { |
| 57 | stop = p786 - 0.25 * a |
| 58 | order.market("L", side.long) |
| 59 | exit.bracket("L half", entry = "L", stop = stop, target = hi_p, qty_pct = 50) |
| 60 | exit.bracket("L rest", entry = "L", stop = stop, target = ext) |
| 61 | armed := false |
| 62 | } |
| 63 | if flat and go_s { |
| 64 | stop = p786 + 0.25 * a |
| 65 | order.market("S", side.short) |
| 66 | exit.bracket("S half", entry = "S", stop = stop, target = lo_p, qty_pct = 50) |
| 67 | exit.bracket("S rest", entry = "S", stop = stop, target = ext) |
| 68 | armed := false |
| 69 | } |
| 70 | risk.max_drawdown(25) |
| 71 | show = armed and strong |
| 72 | z_top = render.line(show ? p50 : na, "Pocket 50 %", color = color.translucent(color.amber.300, 30), width = 1) |
| 73 | z_bot = render.line(show ? p618 : na, "Pocket 61.8 %", color = color.translucent(color.amber.300, 30), width = 1) |
| 74 | render.band(z_top, z_bot, texture = "gradient", upper_color = color.translucent(color.amber.300, 70), lower_color = color.translucent(color.orange.500, 70), opacity = 1, title = "Golden pocket") |
| 75 | render.line(show ? p786 : na, "Invalidation 78.6 %", color = color.translucent(color.rose.400, 30), width = 1, stroke = style.dotted) |
| 76 | render.line(show ? ext : na, "Extension 127.2 %", color = color.translucent(color.emerald.300, 40), width = 1, stroke = style.dashed) |
| 77 | render.mark(go_l and flat, shape = shape.triangle_up, at = anchor.below_bar, color = color.amber.300, text = "GP", title = "Long from pocket") |
| 78 | render.mark(go_s and flat, shape = shape.triangle_down, at = anchor.above_bar, color = color.orange.400, text = "GP", title = "Short from pocket") |
| 79 | persist t = draw.table.create(anchor.top_right, 5, 2) |
| 80 | if bar.is_last { |
| 81 | pr.heading(t, 2, "Golden Pocket Continuation", "Strategy · impulse retracement") |
| 82 | pr.row(t, 2, "Leg", leg == 1 ? str.format("Up {:.1f} ATR", span / a) : leg == -1 ? str.format("Down {:.1f} ATR", span / a) : "None", leg == 1 ? pr.BULL : leg == -1 ? pr.BEAR : pr.LABEL) |
| 83 | pr.row(t, 3, "Pocket", show ? str.format("{:.2f} .. {:.2f}", math.min(p50, p618), math.max(p50, p618)) : "Not armed", color.amber.300) |
| 84 | pr.row(t, 4, "Invalidation", show ? str.format("{:.2f}", p786) : "-", pr.BEAR) |
| 85 | } |
| 86 |
Reviews
No reviews yet. Be the first to review this listing.