OPEN-SOURCE SCRIPT
업데이트됨 Iron Fly 0DTE Strategy

Overview
This indicator identifies optimal entry and exit points for 0DTE (zero days to expiration) Iron Fly options strategies on SPX. It uses a combination of DMI (Directional Movement Index) regime classification and ATR (Average True Range) volatility measurement to determine when market conditions favor non-directional premium selling.
An Iron Fly is a neutral options strategy that profits when price stays near a central strike. This indicator automates the decision of WHEN to enter and at WHAT strikes, based on quantifiable market conditions rather than discretionary judgment.
How It Works
Market Regime Classification
The core logic uses DMI and ADX to classify market conditions into four regimes:
The DI Spread is calculated as the absolute difference between DI+ and DI-. A low spread indicates balanced buying and selling pressure, which favors range-bound price action.
Dynamic Wing Width Calculation
Wing width (the distance between the short strikes and protective long strikes) is calculated dynamically using:
Wing Width = ATR(14) × Multiplier × Late Session Factor
The multiplier varies by Entry Aggressiveness setting (5x to 7x ATR). Wings are widened by 20% in CAUTION regime for additional protection. Late in the session (after 50% elapsed), wings narrow by up to 20% as less time remains for adverse moves.
Wing width is bounded between 15 and 50 points and rounded to the nearest 5-point strike.
Entry Logic
New positions open when:
Exit Logic
Positions close when price exceeds a dynamic exit threshold:
Exit Threshold = Wing Width × (Base Exit Percent + Time Decay Bonus)
The Base Exit Percent varies by Exit Aggressiveness (50% to 80%). The Time Decay Bonus increases throughout the session (0% to 25%), allowing wider tolerance as theta decay works in your favor.
What Makes This Original
This indicator differs from simple moving average or RSI-based approaches by:
Settings Guide
Strategy Settings
Session Settings
How to Use
Alert Messages
OPEN alerts provide: Strike price, wing width, and all four leg strikes (short call, short put, long call, long put).
CLOSE alerts provide: Strike price and exit reason (price exceeded threshold or session ended).
Status Panel
The on-chart panel displays:
Limitations
Best Conditions
This strategy performs best during:
Avoid using during:
Disclaimer
This indicator is for educational and informational purposes only. It does not constitute financial advice.
This indicator identifies optimal entry and exit points for 0DTE (zero days to expiration) Iron Fly options strategies on SPX. It uses a combination of DMI (Directional Movement Index) regime classification and ATR (Average True Range) volatility measurement to determine when market conditions favor non-directional premium selling.
An Iron Fly is a neutral options strategy that profits when price stays near a central strike. This indicator automates the decision of WHEN to enter and at WHAT strikes, based on quantifiable market conditions rather than discretionary judgment.
How It Works
Market Regime Classification
The core logic uses DMI and ADX to classify market conditions into four regimes:
- SAFE - ADX below 25 AND DI Spread below 20: Low directional momentum, ideal for Iron Flies
- CAUTION - ADX below 35 AND DI Spread below 30: Moderate conditions, wider wings recommended
- WARNING - ADX below 45 OR DI Spread below 45: Elevated risk, no new entries
- NO ENTRY - ADX above 45 AND DI Spread above 45: Strong trend, avoid premium selling
The DI Spread is calculated as the absolute difference between DI+ and DI-. A low spread indicates balanced buying and selling pressure, which favors range-bound price action.
Dynamic Wing Width Calculation
Wing width (the distance between the short strikes and protective long strikes) is calculated dynamically using:
Wing Width = ATR(14) × Multiplier × Late Session Factor
The multiplier varies by Entry Aggressiveness setting (5x to 7x ATR). Wings are widened by 20% in CAUTION regime for additional protection. Late in the session (after 50% elapsed), wings narrow by up to 20% as less time remains for adverse moves.
Wing width is bounded between 15 and 50 points and rounded to the nearest 5-point strike.
Entry Logic
New positions open when:
- Market regime is SAFE or CAUTION
- Current open positions are below the maximum limit
- Daily trade count is below the daily limit
- Price has moved sufficiently from the last entry (trigger distance)
- No existing position at the calculated strike
Exit Logic
Positions close when price exceeds a dynamic exit threshold:
Exit Threshold = Wing Width × (Base Exit Percent + Time Decay Bonus)
The Base Exit Percent varies by Exit Aggressiveness (50% to 80%). The Time Decay Bonus increases throughout the session (0% to 25%), allowing wider tolerance as theta decay works in your favor.
What Makes This Original
This indicator differs from simple moving average or RSI-based approaches by:
- Using DMI spread (not just ADX) to measure directional balance, which better identifies consolidation
- Dynamically sizing wings based on current ATR rather than fixed widths
- Adjusting exit tolerance based on session progress to account for theta decay
- Implementing regime-based position management that automatically steps aside during trending conditions
- Providing complete strike calculations for the 4-leg Iron Fly structure
Settings Guide
Strategy Settings
- Entry Aggressiveness - Controls how often new trades open. LOW: fewer trades, wider wings, more selective. MID: balanced. HIGH: more trades, tighter wings.
- Exit Aggressiveness - Controls how long positions are held. LOW: exits early at 50% of wing. MID: exits at 65% plus time bonus. HIGH: holds longer, exits at 80%.
- Max Concurrent Flies - Maximum simultaneous open positions (1-5). Start with 1-2.
- Max Trades Per Day - Daily limit to prevent overtrading (3-30).
Session Settings
- Session Start/End - Trading hours in Eastern Time. Default 10:00-16:00.
How to Use
- Add indicator to SPX chart (1-5 minute timeframe recommended)
- Create alert with condition "Any alert() function call"
- When OPEN alert fires, execute the 4-leg Iron Fly in your broker at the specified strikes
- When CLOSE alert fires, close the position
- Always verify the premium collected justifies the risk before entering
Alert Messages
OPEN alerts provide: Strike price, wing width, and all four leg strikes (short call, short put, long call, long put).
CLOSE alerts provide: Strike price and exit reason (price exceeded threshold or session ended).
Status Panel
The on-chart panel displays:
- Positions - Current open count vs maximum
- Market - Current regime classification
- Wings - Current calculated wing width
- Exit @ - Current exit threshold distance
- Trades - Daily trade count vs limit
Limitations
- Designed specifically for SPX 0DTE options; may not suit other underlyings
- Does not account for bid-ask spreads or execution slippage
- Market regime classification may lag during rapid regime changes
- Past performance of signals does not guarantee future results
- Requires manual execution in your options broker
Best Conditions
This strategy performs best during:
- Range-bound, choppy market conditions
- Normal volatility days (avoid major news events)
- Regular trading hours (10 AM - 4 PM ET)
Avoid using during:
- Strong trending days
- FOMC announcements, CPI releases, earnings
- Pre-market or after-hours
Disclaimer
This indicator is for educational and informational purposes only. It does not constitute financial advice.
- Options trading involves substantial risk of loss
- Iron Flies can result in losses up to the wing width minus premium collected
- Past indicator signals do not guarantee future performance
- Always understand your maximum risk before entering any trade
- Never risk more than you can afford to lose
- Conduct your own research and consider consulting a financial advisor
릴리즈 노트
Version 3.9.4 Update- Added VIX Gate filter - blocks new entries when VIX exceeds user-defined threshold
- New VIX Threshold input (default 20.0) in Strategy settings
- Status panel now displays current VIX level vs threshold
- Improved protection during volatility spikes
───────────────────────────────────
릴리즈 노트
v3.9.5: Fire at bar OPEN instead of bar CLOSE — removes 30 min delay on 30m chart오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.