PROTECTED SOURCE SCRIPT
4H Range Breakout Strategy — ETH 4H optimized

4H Range Breakout Strategy — with Regime Auto-Tuning, Fixed-Risk Sizing & Forward Plan (no-repaint)
What it is
A rules-based breakout strategy that trades the confirmed prior 4H range (no repaint), then adapts to market regime (Trend / Range / High-Vol) and sizes positions by fixed account risk. It includes a forward plan (projected SL/TP levels), a scenario engine (Breakout / Retest / Failed-breakout paths), and optional Pro signals that require volume/RSI confirmation.
Why this is original/useful
All components are designed to work together around a single idea: only trade when price closes beyond the prior 4H range and the market conditions justify it. Filters (EMA200/ADX, volatility, volume) gate entries; risk is standardized in % of equity; exits combine TP1 scale-out + dynamic BE + ATR chandelier. The scenario/forward tools help users plan trades without repainting.
How it works (logic)
Higher-TF range: We fetch previous 4H High/Low (confirmed, lookahead_off).
Breakout triggers:
– Long when close > (4H High + buffer).
– Short when close < (4H Low − buffer).
Filters:
– Trend: Daily EMA200 and/or ADX with a minimum threshold.
– Volatility/Volume: ATR>SMA(ATR) and Volume>SMA(Vol).
– Optional RSI guard (avoid OB/OS extremes).
Stops/Targets:
– Initial stop = ATR-based (or %).
– TP Final = ATR multiple or R multiple (user-selectable).
– TP1 scale-out moves the rest to breakeven, then trails via ATR chandelier.
Cool-down: Blocks immediate re-entries for N bars.
Fixed-risk sizing: Each trade risks a fixed % of equity (default 0.5%), respecting min/step and a max exposure cap.
Kill-Switch (prop-style): Stops new entries after a daily loss limit or a losing streak; resets per rules.
Regime Auto-Tune: Uses ADX, EMA200 Daily slope and ATR z-score to tighten/loosen buffers, targets and trailing in Trend / Range / High-Vol regimes.
Forward Plan & Scenarios: Projects next SL/TP lines and labels; draws primary path (Breakout/Retest/Failed) towards nearest HTF S/R (from pivots) for planning only (no orders).
No-repaint policy: All signals use bar closes and request.security(..., lookahead_off). No future-bar data, no repainting.
Default Properties & Backtest Settings
These defaults are intentionally conservative and should be kept when publishing.
How to use
Limitations & notes
Credits
Pine built-ins (RSI/ADX/ATR), EMA200. All other logic, regime control, fixed-risk sizing, kill-switch and forward/scenario modules implemented by the author for this strategy.
Changelog: v1.0 – initial public release with regime auto-tune, fixed-risk sizing, forward plan & Pro markers.
What it is
A rules-based breakout strategy that trades the confirmed prior 4H range (no repaint), then adapts to market regime (Trend / Range / High-Vol) and sizes positions by fixed account risk. It includes a forward plan (projected SL/TP levels), a scenario engine (Breakout / Retest / Failed-breakout paths), and optional Pro signals that require volume/RSI confirmation.
Why this is original/useful
All components are designed to work together around a single idea: only trade when price closes beyond the prior 4H range and the market conditions justify it. Filters (EMA200/ADX, volatility, volume) gate entries; risk is standardized in % of equity; exits combine TP1 scale-out + dynamic BE + ATR chandelier. The scenario/forward tools help users plan trades without repainting.
How it works (logic)
Higher-TF range: We fetch previous 4H High/Low (confirmed, lookahead_off).
Breakout triggers:
– Long when close > (4H High + buffer).
– Short when close < (4H Low − buffer).
Filters:
– Trend: Daily EMA200 and/or ADX with a minimum threshold.
– Volatility/Volume: ATR>SMA(ATR) and Volume>SMA(Vol).
– Optional RSI guard (avoid OB/OS extremes).
Stops/Targets:
– Initial stop = ATR-based (or %).
– TP Final = ATR multiple or R multiple (user-selectable).
– TP1 scale-out moves the rest to breakeven, then trails via ATR chandelier.
Cool-down: Blocks immediate re-entries for N bars.
Fixed-risk sizing: Each trade risks a fixed % of equity (default 0.5%), respecting min/step and a max exposure cap.
Kill-Switch (prop-style): Stops new entries after a daily loss limit or a losing streak; resets per rules.
Regime Auto-Tune: Uses ADX, EMA200 Daily slope and ATR z-score to tighten/loosen buffers, targets and trailing in Trend / Range / High-Vol regimes.
Forward Plan & Scenarios: Projects next SL/TP lines and labels; draws primary path (Breakout/Retest/Failed) towards nearest HTF S/R (from pivots) for planning only (no orders).
No-repaint policy: All signals use bar closes and request.security(..., lookahead_off). No future-bar data, no repainting.
Default Properties & Backtest Settings
- Symbol/TF: Works on crypto majors; authors’ defaults typically H1 / M15 / 4H profiles.
- Initial capital: 10,000.
- Commission: 0.04% per side (adjust to your venue).
- Slippage: 2 ticks (adjust to symbol tick size/liquidity).
- Position sizing: Fixed-risk = 0.5% of equity per trade (≤1% recommended).
- Pyramiding: 0.
- Sample size: Use a dataset large enough to obtain >100 trades before drawing conclusions (e.g., 1–3 years on BTC/ETH M15/H1).
These defaults are intentionally conservative and should be kept when publishing.
How to use
- Choose a TF profile (M15/H1/4H) and keep the default risk.
- Make sure Commission/Slippage match your market.
- Use the Forward Plan / Scenario labels to plan entries around the breakout; the lines are projections (not signals).
- Optionally toggle Pro signals to see stricter, volume-supported entries (visual only).
- Review the Kill-Switch and cool-down if you’re prop-testing.
Limitations & notes
- Not financial advice. Trend/range detection and S/R from pivots are heuristic and can fail in chop or news.
- Do not over-optimize parameters on a single symbol/TF; validate on out-of-sample data.
- The “Pro signals” are markers only; orders are placed by the core breakout logic.
Credits
Pine built-ins (RSI/ADX/ATR), EMA200. All other logic, regime control, fixed-risk sizing, kill-switch and forward/scenario modules implemented by the author for this strategy.
Changelog: v1.0 – initial public release with regime auto-tune, fixed-risk sizing, forward plan & Pro markers.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.