PROTECTED SOURCE SCRIPT

4H Range Breakout Strategy — ETH 4H optimized

16
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

  1. Symbol/TF: Works on crypto majors; authors’ defaults typically H1 / M15 / 4H profiles.
  2. Initial capital: 10,000.
  3. Commission: 0.04% per side (adjust to your venue).
  4. Slippage: 2 ticks (adjust to symbol tick size/liquidity).
  5. Position sizing: Fixed-risk = 0.5% of equity per trade (≤1% recommended).
  6. Pyramiding: 0.
  7. 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

  1. Choose a TF profile (M15/H1/4H) and keep the default risk.
  2. Make sure Commission/Slippage match your market.
  3. Use the Forward Plan / Scenario labels to plan entries around the breakout; the lines are projections (not signals).
  4. Optionally toggle Pro signals to see stricter, volume-supported entries (visual only).
  5. 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.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.