OPEN-SOURCE SCRIPT

ORION: Hybrid Volatility Breakout Strategy

252
📝 Description
Introduction ORION is a specialized volatility breakout strategy designed primarily for XAUUSD (Gold) on the 5-minute timeframe. It is built on the core market principle of "Compression leads to Expansion." The strategy identifies periods of market consolidation (tight, flat ranges) and executes trades when momentum breaks out of these zones in the direction of the dominant trend.

This version is specifically optimized for Proprietary Trading Firms (FTMO, etc.), featuring strict time-based closures, risk management controls, and session filters to comply with "Day Trader" objectives.

🧠 How It Works (The Logic)
The strategy does not guess tops or bottoms. It waits for a specific market structure to form—a "Box." For a valid setup to be identified, the market must pass three strict mathematical filters:

  • Tightness Filter (ATR): The strategy measures the height of the last 15 candles (High vs. Low). If the range height is less than 2.5x ATR (Average True Range), it is considered "compressed" enough to trade.
  • Flatness Filter (Linear Regression): We don't want to trade slanted channels. The strategy calculates the slope of the Linear Regression curve. If the slope is below 0.2, the market is considered flat/horizontal.
  • Squeeze Detection (Standard Deviation): An optional visual aid (Golden Box) appears when Standard Deviation drops significantly, signaling extreme compression and a high probability of explosive movement.
  • Entry Trigger: Once a valid "Box" is drawn, the strategy waits. A trade is entered only if a candle closes outside the box boundaries.
    Long: Candle Close > Box High.
    Short: Candle Close < Box Low.
  • Trend Filter: To avoid false breakouts, the strategy uses a 150 EMA (Exponential Moving Average).
    Longs are only taken if the price is above the 150 EMA.
    Shorts are only taken if the price is below the 150 EMA.


🛡️ Risk Management & Prop Firm Features
This strategy is engineered with capital preservation in mind:
  • Dynamic Position Sizing: Instead of fixed lots, the strategy calculates position size based on % Risk per Trade (default 0.8%). This ensures that a wide stop loss or a tight stop loss results in the exact same dollar risk.
  • Risk:Reward Ratio: Default is set to 1:1.9. Winners are nearly 2x larger than losers.
  • "Zombie Box" Prevention: If a consolidation box is formed but price does not break out within 45 bars (approx. 4 hours), the box is considered invalid and deleted. This prevents the strategy from reacting to "stale" levels.
  • Friday Force Close: To comply with Prop Firm rules regarding weekend holding, the strategy automatically closes all open positions on Friday at 22:00 (adjustable).
  • Session Filter: Trades are only taken during specified active hours (e.g., London/NY sessions) to avoid low-liquidity spreads.


⚙️ User Settings (Inputs)
  • Lookback Period: Length of the consolidation analysis (Default: 15).
  • Box Width (ATR): Sensitivity of the volatility filter. Lower values = stricter entries.
  • EMA Length: Trend filter baseline (Default: 150).
  • Trading Session: Time window for new entries (Default: 06:00 - 23:00).
  • Force Close Day/Hour: Auto-close settings for weekends.
  • Max Leverage Cap: Safety filter to prevent excessive position sizing on tight stops (Default: 30x).


⚠️ Disclaimer
This strategy is a tool for analysis and automated execution logic. Past performance (backtesting) is not indicative of future results.
The default settings are tuned for XAUUSD (Gold) on the 5m timeframe.
Always perform your own backtests before using on a live account.
Ensure your broker's time zone matches the strategy's time logic for the session filters to work correctly.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.