OPEN-SOURCE SCRIPT

Opening Range Breakout with Multi-Timeframe Liquidity]

314
═══════════════════════════════════════
OPENING RANGE BREAKOUT WITH MULTI-TIMEFRAME LIQUIDITY
═══════════════════════════════════════

A professional Opening Range Breakout (ORB) indicator enhanced with multi-timeframe liquidity detection, trading session visualization, volume analysis, and trend confirmation tools. Designed for intraday trading with comprehensive alert system.

───────────────────────────────────────
WHAT THIS INDICATOR DOES
───────────────────────────────────────

This indicator combines multiple trading concepts:

- Opening Range Breakout (ORB) - Customizable time period detection with automatic high/low identification
- Multi-Timeframe Liquidity - HTF (Higher Timeframe) and LTF (Lower Timeframe) key level detection
- Trading Sessions - Tokyo, London, New York, and Sydney session visualization
- Volume Analysis - Volume spike detection and strength measurement
- Multi-Timeframe Confirmation - Trend bias from higher timeframes
- EMA Integration - Trend filter and dynamic support/resistance
- Smart Alerts - Quality-filtered breakout notifications

───────────────────────────────────────
HOW IT WORKS
───────────────────────────────────────

OPENING RANGE BREAKOUT (ORB):

Concept:
The Opening Range is a period at the start of a trading session where price establishes an initial high and low. Breakouts beyond this range often indicate the direction of the day's trend.

Detection Method:
- Default: 15-minute opening range (configurable)
- Custom Range: Set specific session times with timezone support
- Automatically identifies ORH (Opening Range High) and ORL (Opening Range Low)
- Tracks ORB mid-point for reference

Range Establishment:
1. Session starts (or custom time begins)
2. Tracks highest high and lowest low during the period
3. Range confirmed at end of opening period
4. Levels extend throughout the session

Breakout Detection:
- Bullish Breakout: Close above ORH
- Bearish Breakout: Close below ORL
- Mid-point acts as bias indicator

Visual Display:
- Shaded box during range formation
- Horizontal lines for ORH, ORL, and mid-point
- Labels showing level values
- Color-coded fills based on selected method

Fill Color Methods:

1. Session Comparison:
- Green: Current OR mid > Previous OR mid
- Red: Current OR mid < Previous OR mid
- Gray: Equal or first session
- Shows day-over-day momentum

2. Breakout Direction (Recommended):
- Green: Price currently above ORH (bullish breakout)
- Red: Price currently below ORL (bearish breakout)
- Gray: Price inside range (no breakout)
- Real-time breakout status

MULTI-TIMEFRAME LIQUIDITY:

Two-Tier System for comprehensive level identification:

HTF (Higher Timeframe) Key Liquidity:
- Default: 4H timeframe (configurable to Daily, Weekly)
- Identifies major institutional levels
- Uses pivot detection with adjustable parameters
- Suitable for swing highs/lows where large orders rest

LTF (Lower Timeframe) Key Liquidity:
- Default: 1H timeframe (configurable)
- Provides precision entry/exit levels
- Finer granularity for intraday trading
- Captures minor swing points

Calculation Method:
- Pivot high/low detection algorithm
- Configurable left bars (lookback) and right bars (confirmation)
- Timeframe multiplier for accurate multi-timeframe detection
- Automatic level extension

Mitigation System:
- Tracks when levels are swept (broken)
- Configurable mitigation type: Wick or Close-based
- Option to remove or show mitigated levels
- Display limit prevents chart clutter

Asset-Specific Optimization:
The indicator includes quick reference settings for different assets:
- Major Forex (EUR/USD, GBP/USD): Default settings optimal
- Crypto (BTC/ETH): Left=12, Right=4, Display=7
- Gold: HTF=1D, Left=20

TRADING SESSIONS:

Four Major Sessions with Full Customization:

Tokyo Session:
- Default: 04:00-13:00 UTC+4
- Asian trading hours
- Often sets daily range

London Session:
- Default: 11:00-20:00 UTC+4
- Highest liquidity period
- Major institutional activity

New York Session:
- Default: 16:00-01:00 UTC+4
- US market hours
- High-impact news events

Sydney Session:
- Default: 01:00-10:00 UTC+4
- Earliest Asian activity
- Lower volatility

Session Features:
- Shaded background boxes
- Session name labels
- Optional open/close lines
- Session high/low tracking with colored lines
- Each session has independent color settings
- Fully customizable times and timezones

VOLUME ANALYSIS:

Volume-Based Trade Confirmation:

Volume MA:
- Configurable period (default: 20)
- Establishes average volume baseline
- Used for spike detection

Volume Spike Detection:
- Identifies when volume exceeds MA * multiplier
- Default: 1.5x average volume
- Confirms breakout strength

Volume Strength Measurement:
- Calculates current volume as percentage of average
- Shows relative volume intensity
- Used in alert quality filtering

High Volume Bars:
- Identifies bars above 50th percentile
- Additional confirmation layer
- Indicates institutional participation

MULTI-TIMEFRAME CONFIRMATION:

Trend Bias from Higher Timeframes:

HTF 1 (Trend):
- Default: 1H timeframe
- Uses EMA to determine intermediate trend
- Compares current timeframe EMA to HTF EMA

HTF 2 (Bias):
- Default: 4H timeframe
- Uses 50 EMA for longer-term bias
- Confirms overall market direction

Bias Classifications:
- Bullish Bias: HTF close > HTF 50 EMA AND Current EMA > HTF1 EMA
- Bearish Bias: HTF close < HTF 50 EMA AND Current EMA < HTF1 EMA
- Neutral Bias: Mixed signals between timeframes

EMA Stack Analysis:
- Compares EMA alignment across timeframes
- +1: Bullish stack (lower TF EMA > higher TF EMA)
- -1: Bearish stack (lower TF EMA < higher TF EMA)
- 0: Neutral/crossed

Usage:
- Filters false breakouts
- Confirms trend direction
- Improves trade quality

EMA INTEGRATION:

Dynamic EMA for Trend Reference:

Features:
- Configurable period (default: 20)
- Customizable color and width
- Acts as dynamic support/resistance
- Trend filter for ORB trades

Application:
- Above EMA: Favor long breakouts
- Below EMA: Favor short breakouts
- EMA cross: Potential trend change
- Distance from EMA: Momentum gauge

SMART ALERT SYSTEM:

Quality-Filtered Breakout Notifications:

Alert Types:
1. Standard ORB Breakout
2. High Quality ORB Breakout

Quality Criteria:
- Volume Confirmation: Volume > 1.2x average
- MTF Confirmation: Bias aligned with breakout direction

Standard Alert:
- Basic breakout detection
- Price crosses ORH or ORL
- Icon: 🚀 (bullish) or 🔻 (bearish)

High Quality Alert:
- Both volume AND MTF confirmed
- Stronger probability setup
- Icon: 🚀⭐ (bullish) or 🔻⭐ (bearish)

Alert Information Includes:
- Alert quality rating
- Breakout level and current price
- Volume strength percentage (if enabled)
- MTF bias status (if enabled)
- Recommended action

One Alert Per Bar:
- Prevents alert spam
- Uses flag system to track sent alerts
- Resets on new ORB session

───────────────────────────────────────
HOW TO USE
───────────────────────────────────────

OPENING RANGE SETUP:

Basic Configuration:
1. Select time period for opening range (default: 15 minutes)
2. Choose fill color method (Breakout Direction recommended)
3. Enable historical data display if needed

Custom Range (Advanced):
1. Enable Custom Range toggle
2. Set specific session time (e.g., 0930-0945)
3. Select appropriate timezone
4. Useful for specific market opens (NYSE, LSE, etc.)

LIQUIDITY LEVELS SETUP:

Quick Configuration by Asset:
- Forex: Use default settings (Left=15, Right=5)
- Crypto: Set Left=12, Right=4, Display=7
- Gold: Set HTF=1D, Left=20

HTF Liquidity:
- Purpose: Major support/resistance levels
- Recommended: 4H for day trading, 1D for swing trading
- Use as profit targets or reversal zones

LTF Liquidity:
- Purpose: Entry/exit refinement
- Recommended: 1H for day trading, 4H for swing trading
- Use for position management

Mitigation Settings:
- Wick-based: More sensitive (default)
- Close-based: More conservative
- Remove or Show mitigated levels based on preference

TRADING SESSIONS SETUP:

Enable/Disable Sessions:
- Master toggle for all sessions
- Individual session controls
- Show/hide session names

Session High/Low Lines:
- Enable to see session extremes
- Each session has custom colors
- Useful for range trading

Customization:
- Adjust session times for your broker
- Set timezone to match your location
- Customize colors for visibility

VOLUME ANALYSIS SETUP:

Enable Volume Analysis:
1. Toggle on Volume Analysis
2. Set MA length (20 recommended)
3. Adjust spike multiplier (1.5 typical)

Usage:
- Confirm breakouts with volume
- Identify climactic moves
- Filter false signals

MULTI-TIMEFRAME SETUP:

HTF Selection:
- HTF 1 (Trend): 1H for day trading, 4H for swing
- HTF 2 (Bias): 4H for day trading, 1D for swing

Interpretation:
- Trade only with bias alignment
- Neutral bias: Be cautious
- Bias changes: Potential reversals

EMA SETUP:

Configuration:
- Period: 20 for responsive, 50 for smoother
- Color: Choose contrasting color
- Width: 1-2 for visibility

Usage:
- Filter trades: Long above, Short below
- Dynamic support/resistance reference
- Trend confirmation

ALERT SETUP:

TradingView Alert Creation:
1. Enable alerts in indicator settings
2. Enable ORB Breakout Alerts
3. Right-click chart → Add Alert
4. Select this indicator
5. Choose "Any alert() function call"
6. Configure delivery method (mobile, email, webhook)

Alert Filtering:
- All alerts include quality rating
- High Quality alerts = Volume + MTF confirmed
- Standard alerts = Basic breakout only

───────────────────────────────────────
TRADING STRATEGIES
───────────────────────────────────────

CLASSIC ORB STRATEGY:

Setup:
1. Wait for opening range to complete
2. Price breaks and closes above ORH or below ORL
3. Volume > average (if enabled)
4. MTF bias aligned (if enabled)

Entry:
- Bullish: Buy on break above ORH
- Bearish: Sell on break below ORL
- Consider retest entries for better risk/reward

Stop Loss:
- Bullish: Below ORL or range mid-point
- Bearish: Above ORH or range mid-point
- Adjust based on volatility

Targets:
- Initial: Range width extension (ORH + range width)
- Secondary: HTF liquidity levels
- Final: Session high/low or major support/resistance

ORB + LIQUIDITY CONFLUENCE:

Enhanced Setup:
1. Opening range established
2. HTF liquidity level near or beyond ORH/ORL
3. Breakout occurs with volume
4. Price targets the liquidity level

Entry:
- Enter on ORB breakout
- Target the HTF liquidity level
- Use LTF liquidity for position management

Management:
- Partial profits at ORB + range width
- Move stop to breakeven at LTF liquidity
- Final exit at HTF liquidity sweep

ORB REJECTION STRATEGY (Counter-Trend):

Setup:
1. Price breaks above ORH or below ORL
2. Weak volume (below average)
3. MTF bias opposite to breakout
4. Price closes back inside range

Entry:
- Failed bullish break: Short below ORH
- Failed bearish break: Long above ORL

Stop Loss:
- Beyond the failed breakout level
- Or beyond session extreme

Target:
- Opposite end of opening range
- Range mid-point for partial profit

SESSION-BASED ORB TRADING:

Tokyo Session:
- Typically narrower ranges
- Good for range trading
- Wait for London open breakout

London Session:
- Highest volume and volatility
- Strong ORB setups
- Major liquidity sweeps common

New York Session:
- Strong trending moves
- News-driven volatility
- Good for momentum trades

Sydney Session:
- Quieter conditions
- Suitable for range strategies
- Sets up Tokyo session

EMA-FILTERED ORB:

Rules:
- Only take bullish breaks if price > EMA
- Only take bearish breaks if price < EMA
- Ignore counter-trend breaks

Benefits:
- Reduces false signals
- Aligns with larger trend
- Improves win rate

───────────────────────────────────────
CONFIGURATION GUIDE
───────────────────────────────────────

OPENING RANGE SETTINGS:

Time Period:
- 15 min: Standard for most markets
- 30 min: Wider range, fewer breakouts
- 60 min: For slower markets or swing trades

Custom Range:
- Use for specific market opens
- NYSE: 0930-1000 EST
- LSE: 0800-0830 GMT
- Set timezone to match exchange

Historical Display:
- Enable: See all previous session data
- Disable: Cleaner chart, current session only

LIQUIDITY SETTINGS:

Left Bars (5-30):
- Lower: More frequent, sensitive levels
- Higher: Fewer, more significant levels
- Recommended: 15 for most markets

Right Bars (1-25):
- Confirmation period
- Higher: More reliable, less frequent
- Recommended: 5 for balance

Display Limit (1-20):
- Number of active levels shown
- Higher: More context, busier chart
- Recommended: 7 for clarity

Extension Options:
- Short: Levels visible near formation
- Current: Extended to current bar (recommended)
- Max: Extended indefinitely

VOLUME SETTINGS:

MA Length (5-50):
- Shorter: More responsive to spikes
- Longer: Smoother baseline
- Recommended: 20 for balance

Spike Multiplier (1.0-3.0):
- Lower: More sensitive spike detection
- Higher: Only extreme spikes
- Recommended: 1.5 for day trading

MULTI-TIMEFRAME SETTINGS:

HTF 1 (Trend):
- 5m chart: Use 15m or 1H
- 15m chart: Use 1H or 4H
- 1H chart: Use 4H or 1D

HTF 2 (Bias):
- One level higher than HTF 1
- Provides longer-term context
- Don't use same as HTF 1

EMA SETTINGS:

Length:
- 20: Responsive, more signals
- 50: Smoother, stronger filter
- 200: Long-term trend only

Style:
- Choose contrasting color
- Width 1-2 for visibility
- Match your trading style

───────────────────────────────────────
BEST PRACTICES
───────────────────────────────────────

Chart Timeframe Selection:
- ORB Trading: Use 5m or 15m charts
- Session Review: Use 1H or 4H charts
- Swing Trading: Use 1H or 4H charts

Quality Over Quantity:
- Wait for high-quality alerts (volume + MTF)
- Avoid trading every breakout
- Focus on confluence setups

Risk Management:
- Position size based on range width
- Wider ranges = smaller positions
- Use stop losses always
- Take partial profits at targets

Market Conditions:
- Best results in trending markets
- Reduce position size in choppy conditions
- Consider session overlaps for volatility
- Avoid trading near major news if inexperienced

Continuous Improvement:
- Track win rate by session
- Note which confluence factors work best
- Adjust settings based on market volatility
- Review performance weekly

───────────────────────────────────────
PERFORMANCE OPTIMIZATION
───────────────────────────────────────

This indicator is optimized with:
- max_bars_back declarations for efficient processing
- Conditional calculations based on enabled features
- Proper memory management for drawing objects
- Minimal recalculation on each bar

Best Practices:
- Disable unused features (sessions, MTF, volume)
- Limit historical display to reduce rendering
- Use appropriate timeframe for your strategy
- Clear old drawing objects periodically

───────────────────────────────────────
EDUCATIONAL DISCLAIMER
───────────────────────────────────────

This indicator combines established trading concepts:
- Opening Range Breakout theory (price action)
- Liquidity level detection (pivot analysis)
- Session-based trading (time-of-day patterns)
- Volume analysis (confirmation technique)
- Multi-timeframe analysis (trend alignment)

All calculations use standard technical analysis methods:
- Pivot high/low detection algorithms
- Moving averages for trend and volume
- Session time filtering
- Timeframe security functions

The indicator identifies potential trading setups but does not predict future price movements. Success requires proper application within a complete trading strategy including risk management, position sizing, and market context.

───────────────────────────────────────
USAGE DISCLAIMER
───────────────────────────────────────

This tool is for educational and analytical purposes. Opening Range Breakout trading involves substantial risk. The alert system and quality filters are designed to identify potential setups but do not guarantee profitability. Always conduct independent analysis, use proper risk management, and never risk capital you cannot afford to lose. Past performance does not indicate future results. Trading intraday breakouts requires experience and discipline.

───────────────────────────────────────
CREDITS & ATTRIBUTION
───────────────────────────────────────

ORIGINAL SOURCE:
This indicator builds upon concepts from LuxAlgo's-ORB

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.