Appearance
Personalize your experience
Trend Breakout (ATR)
FreeBreakouts with ATR stops and targets
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
Donchian breakout in the direction of a 200-EMA trend filter. Size risks 1% of equity on an ATR stop; the target is `reward` times the risk and a trailing stop takes over after 1R.
Settings
Breakout length: 20
Trend EMA: 200
Stop (ATR): 2
Reward (R): 3
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
Exit Conditions
Measured backtest
BTCUSDT 1h (Binance), 2025-11-01 to 2026-11-01 · backtest engine, script costs included
-11.7%
Return
-0.50
Sharpe
-25.1%
Max DD
25.5%
Win Rate
153
Trades
| Market | Trades | Return | Sharpe | Max DD | Win rate | Profit factor |
|---|---|---|---|---|---|---|
| BTCUSDT 1h | 153 | -11.7% | -0.50 | -25.1% | 25.5% | 0.91 |
| ETHUSDT 1h | 197 | -9.1% | -0.28 | -23.9% | 25.9% | 0.94 |
Past results on historical data do not predict future returns.
Source Code
Edit in IDE| 1 | strategy "Trend Breakout (ATR)" { |
| 2 | overlay = true |
| 3 | capital = 100000 |
| 4 | commission = 0.05 |
| 5 | slippage = 1 |
| 6 | sizing = risk_percent |
| 7 | size = 1 |
| 8 | pyramiding = 1 |
| 9 | } |
| 10 | /// Donchian breakout in the direction of a 200-EMA trend filter. Size risks 1% of equity on an |
| 11 | /// ATR stop; the target is `reward` times the risk and a trailing stop takes over after 1R. |
| 12 | use "risk/position_sizing" as ps |
| 13 | |
| 14 | len = param.int(20, title = "Breakout length", min = 5, max = 200) |
| 15 | trend = param.int(200, title = "Trend EMA", min = 20, max = 1000) |
| 16 | stop_k = param.float(2.0, title = "Stop (ATR)", min = 0.5, max = 10, step = 0.1) |
| 17 | reward = param.float(3.0, title = "Reward (R)", min = 0.5, max = 10, step = 0.1) |
| 18 | |
| 19 | (_, upper, lower) = ta.donchian(len) |
| 20 | filter = ta.ema(close, trend) |
| 21 | a = ta.atr(14) |
| 22 | long_sig = close > upper[1] and close > filter |
| 23 | short_sig = close < lower[1] and close < filter |
| 24 | |
| 25 | if position.size == 0 and long_sig { |
| 26 | order.market("L", side.long) |
| 27 | exit.bracket("L exit", entry = "L", stop = close - stop_k * a, target = close + stop_k * a * reward, |
| 28 | trail_offset = stop_k * a, trail_trigger = close + stop_k * a) |
| 29 | } |
| 30 | if position.size == 0 and short_sig { |
| 31 | order.market("S", side.short) |
| 32 | exit.bracket("S exit", entry = "S", stop = close + stop_k * a, target = close - stop_k * a * reward, |
| 33 | trail_offset = stop_k * a, trail_trigger = close - stop_k * a) |
| 34 | } |
| 35 | risk.max_drawdown(25) |
| 36 | risk.max_trades_per_day(4) |
| 37 | |
| 38 | render.line(upper, "Upper", color = color.teal.500, width = 1) |
| 39 | render.line(lower, "Lower", color = color.rose.500, width = 1) |
| 40 | render.line(filter, "Trend filter", color = color.amber.400, width = 2) |
| 41 | render.mark(long_sig and position.size == 0, shape = shape.arrow_up, at = anchor.below_bar, color = color.teal.400, text = "Long") |
| 42 | render.mark(short_sig and position.size == 0, shape = shape.arrow_down, at = anchor.above_bar, color = color.rose.400, text = "Short") |
| 43 |
Reviews
No reviews yet. Be the first to review this listing.