OPEN-SOURCE SCRIPT
Aggiornato

Casper SMC: 5m ORB + Retest

4 913
Casper SMC: 5m ORB + Retest

This strategy is an Opening Range Breakout (ORB) system combined with Smart Money Concept (SMC) style wick-retest entries.
It is designed for 5-minute charts and trades only during the New York session.

The goal is to trade confirmed breakouts followed by a controlled pullback, using fixed risk and realistic P/L calculations.
────────────────────────────
Core Logic
  1. Capture the Opening Range High, Low, and Mid
  2. Wait for a confirmed breakout above or below the range
  3. Look for a wick retest back into the range
  4. Enter only if the candle body stays outside the range
  5. Use fixed RR with automatic TP & SL

────────────────────────────
Session Rules
  • Opening Range (ORB): 09:30 – 09:35 New York time
  • Entries allowed only until the configured cutoff time
  • Maximum of one trade per day
  • If breakout fully reverses through the range, the session is cancelled

────────────────────────────
Entry Conditions

Bullish Setup
  • Candle closes above ORB High
  • After breakout, a candle wicks back below ORB High
  • Candle body remains fully above ORB High
  • Wick depth must be within the user-defined percentage range


Bearish Setup
  • Candle closes below ORB Low
  • After breakout, a candle wicks back above ORB Low
  • Candle body remains fully below ORB Low
  • Wick depth must be within the user-defined percentage range

────────────────────────────
Risk Management
  • Stop Loss: ORB Midpoint
  • Take Profit: Risk × RR Ratio
  • Fixed lot size for every trade
  • Automatic TP / SL handling

────────────────────────────
Realistic P/L Calculation

Profit and loss values are calculated using lot size and contract size:

Pine Script®
Profit = (TP − Entry) × ContractSize × LotSize Loss = (Entry − SL) × ContractSize × LotSize


This allows accurate estimation for:
  • Forex
  • Gold (XAUUSD)
  • Crypto
  • Indices

────────────────────────────
Visual Features
  • ORB High / Low / Mid plotted on chart
  • Entry labels showing expected TP & SL in USD
  • Trade duration label displayed after exit
  • Session cancellation warnings

────────────────────────────
Recommended Usage
  • Timeframe: 5 minutes
  • Best session: New York
  • Instruments: Forex, Gold, Indices, Crypto
  • Always forward-test before live trading

────────────────────────────
Disclaimer

This script is for educational and research purposes only.
Past performance does not guarantee future results.
Always manage risk and test thoroughly before trading real capital.
Note di rilascio
New Feature: The Volatility "Gatekeeper"
Based on community feedback, I have added an ATR Range Filter. This prevents the strategy from taking trades on low-volume, "choppy" days where the Opening Range is too small to be safe.

How it works: If the height of the Opening Range is smaller than ATR x Multiplier, the day is skipped.
Why use it: Small ranges often lead to "fakeouts" and stop hunts. This filter ensures you only trade when there is enough momentum to hit targets.
Note di rilascio
some fixes
Note di rilascio
🆕 Partial Take Profit System
- Enable Partial TP — When enabled, the strategy splits the exit into two stages instead of one full exit.
- TP1 (Partial Close) — Closes a configurable percentage of the position (e.g. 50%) at a configurable R level (e.g. 1.0R). Great for locking in profit early on volatile days.
- TP2 (Final Close) — The remaining position rides toward the full target (e.g. 2.0R or 2.5R).
- Correct P/L Accounting — All scenarios are handled correctly:
Pine Script®
Scenario 1 — Straight SL (no TP hit): → Full position closes at SL in ONE trade → No phantom TP labels. No double counting. Scenario 2 — TP1 hit, then SL: → 50% closed at TP1 (profit) → Remaining 50% closed at SL (small loss) → Net result: reduced loss or breakeven Scenario 3 — Both TPs hit: → 50% closed at TP1 (profit) → 50% closed at TP2 (larger profit) → Best case scenario


🆕 Move SL to ORB After TP1
- Dependency enforced in code — This option is only active when Enable Partial TP is also enabled. If Partial TP is off, this setting is automatically ignored regardless of the checkbox state.
- How it works — After TP1 is hit, the Stop Loss of the remaining position is moved from orbMid to the ORB boundary:
-- Long trade → SL moves to orbHigh (price must drop back below the breakout level to stop out)
-- Short trade → SL moves to orbLow (price must rally back above the breakdown level to stop out)
- Why use it — Protects the remaining position after a partial win. Worst case after TP1 is a small loss instead of a full loss.
Note di rilascio
Update: Confluence Filters & Momentum Gating

This update introduces a "disciplined" layer to the Casper ORB logic. We have added a new "Confluence Filters" settings group designed to filter out low-probability "noise" and prevent "chop suicide" during non-trending sessions.

New Features:

1. ADX Filter (Trend Strength)
The Average Directional Index (ADX) measures the strength of a trend regardless of direction.

* Logic: When enabled, entries are blocked if the ADX is below the threshold (Default: 25).
* Benefit: Keeps you out of the market when price is just "drifting" sideways.

2. 4H VWAP Filter (Institutional Bias)
Uses a 4-Hour Volume Weighted Average Price as a medium-term "gravity" line.

* Long Bias: Only permits Long entries when price is above the 4H VWAP.
* Short Bias: Only permits Short entries when price is below the 4H VWAP.
* Visuals: An orange line is plotted on the chart when this filter is active to show the current bias.

[h2]Technical Logic Applied[/h2]
We have introduced three new logic gates that must return true before an order is executed:

* adxPass — Validates that momentum is sufficient.
* vwapLong — Validates price is on the bullish side of the 4H volume average.
* vwapShort — Validates price is on the bearish side of the 4H volume average.

⚠️ Note on Settings:
To maintain consistency with your existing backtests, both filters are OFF by default. You can enable them individually under the new "Confluence Filters" group in the script settings.

Code changes: Expanded logic from 20 lines to 40 lines in the filtering block for casper-orb-dynamic.pine.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.