OPEN-SOURCE SCRIPT

0DTE Options - Iron Condor & Butterfly

106
To help options traders:

Plan and structure Iron Condor or Butterfly spreads in “Setup Mode.”

Track live trades, including P&L, breach risk, and strike distances, in “Live Mode.”

Visualize the trade on the price chart with profit zones, breakeven lines, strike markers, and alerts.

Evaluate market conditions using IV Rank, ATR-based range modeling, and modeled Delta approximation.

Essentially, it turns your TradingView chart into an options risk graph + planning terminal.

⚙️ Core Modes of Operation
🧱 1. Setup Mode

Used for planning new trades. It automatically suggests strikes based on:

ATR (volatility proxy)

IV Rank

Target Delta

Chosen risk tier (High / Mid / Low / Delta)

You can:

Preview recommended short and long strikes.

See estimated credit, width, and risk/reward ratios in a setup table.

Auto-feed these calculated strikes into the Live Mode to track them later.

Example Use:
Before market open, choose Setup Mode → Mid Risk Tier → see what strike widths and credits make sense for the day.

📈 2. Live Mode

Used to track real trades you’ve already opened.

You can:

Paste your real trade data (strikes, credits, etc.) into the 📋 paste field.

Or auto-feed from Setup Mode (if “Auto-Feed” is enabled).

The indicator then plots:

Short/long strikes

Breakevens

Profit/loss zone

Real-time breach detection and delta drift

Alerts when price nears your strikes or exits your safe zone.

Example Use:
After opening an Iron Condor on SPX, paste in 626,628,620,618,1.20,1, and the chart visually shows your safe range and warning zones.

🧮 Built-In Calculations
1. IV Rank (Volatility Environment)

Uses a 20-day log return volatility model to calculate IV Rank (percentile of volatility over the last 252 bars).

You can use this automatically or manually override it if you have data from your broker.

→ High IV Rank (>50) = better for selling Iron Condors (more premium).

2. ATR (Average True Range)

Measures short-term volatility to estimate expected daily price movement.

Used in Setup Mode to model distance between strikes.

3. Strike Calculations (Setup Mode)

Based on risk tier:

High Risk → wide wings, high credit, high potential drawdown

Mid Risk → balanced setup

Low Risk → narrow wings, safer but less credit

Delta Mode → based purely on target delta (e.g., 0.20)

Uses ATR × multiplier to determine how far short strikes should be from current price.

4. Credit Estimation

Based on strike width × IV Rank multiplier:

IV > 50 → 30% of width

IV 30–50 → 25%

IV < 30 → 20%

5. Profit & Loss Modeling

The indicator computes:

Max Profit:

Iron Condor → credit × 100 × contracts

Butterfly → (wing width − debit) × 100 × contracts

Max Loss:

Iron Condor → width − credit

Butterfly → debit × 100 × contracts

Breakevens:

Iron Condor → short strikes ± credit

Butterfly → body ± debit

Current P&L: Approximated by where the underlying is relative to the short/long strikes.

6. Delta Modeling

Estimates each short strike’s modeled delta based on how far it is from current price.

Displays total delta balance to show directional bias.

If Delta drifts too high → market imbalance → consider rolling or adjusting.

7. Breach Detection System

Automatically classifies your trade as:

🟢 In Range: Price between short strikes (safe zone).

🟠 Near Breach: Price close to short strike (risk zone).

🔴 Breached: Price outside long strike (stop or adjust zone).

This dynamically changes color in your profit box and info label.

🎨 Visual Components
Element Meaning Color
Red Line Put side strikes 🔻 Red
Green Line Call side strikes 🔺 Green
Yellow Dotted Lines Breakevens 🟡 Yellow
Green Box Profit zone 🟩 Light green
Orange Box Adjustment zone (near breach) 🟧 Orange
Red Box Breach zone 🟥 Red
White Line Current price ⚪ White

Optional labels display strike details and distances (e.g., “📉 Short Put: 620 – 5 pts away”).

📊 Setup Table (Setup Mode Only)

Displays a grid comparing all risk tiers:

Tier Short Call Short Put Width Est. Credit R:R
High 632 614 4.0 $1.20 0.43
Mid 630 616 3.0 $0.90 0.43
Low 628 618 2.0 $0.60 0.43

Highlighted row = selected risk tier.
This lets you compare how wide/narrow each setup is before committing to a trade.

🧾 Info Box (Live Mode)

Displays real-time stats such as:

🔶 IRON CONDOR | 1 Contract
📊 Calls: 626 / 628 | Puts: 620 / 618
💵 Credit: $1.20 | 💰 Profit: $120 | 🔴 Loss: $180
⬆️ BE: 627.2 | ⬇️ BE: 618.8
📍 Current: $623 | 💵 P&L: +$35.00 (+29.1%)
📏 To Short Call: 3 | To Short Put: 3
📊 Delta: 0.05 | IV Rank: 56% (FAVORABLE)
🔴 BREACH STATUS: In Range

🚨 Alerts

The indicator generates TradingView alerts for:

⚠️ Approaching Call Zone → nearing short call

⚠️ Approaching Put Zone → nearing short put

🛑 Stop Loss Triggered → current P&L exceeds loss threshold

🟠 Near Breach → price entering adjustment zone

🔴 Breached → price outside protection (long strikes)

These alerts can be used with TradingView notifications or webhooks.

🧠 How to Use It Step-by-Step
A. Planning (Setup Mode)

Set mode to “Setup.”

Adjust:

Risk Tier (High / Mid / Low / Delta)

Target Delta (0.15–0.30 recommended)

Strike Interval (e.g., 1.0 or 5.0)

Check Setup Table → see suggested strikes & credits.

Optionally toggle Auto-Feed → Live to send to live mode later.

B. Executing (Broker)

Confirm and enter your trade in your brokerage (use the strikes shown).
Record your strikes, net credit/debit, and number of contracts.

C. Tracking (Live Mode)

Switch to “Live” mode.

Paste your strikes in the 📋 Paste Data field:

Iron Condor Example: 626,628,620,618,1.20,1
Butterfly Example: 600,620,640,2.50,2


The chart updates:

Lines = your strikes

Boxes = profit/risk zones

Labels = strike info, distance to price

Info box = P&L, delta, IV rank, breach status

Set alerts for automatic notifications.

D. Managing the Trade

When the chart turns orange or red, you’re approaching or breaching a strike.

Use this signal to roll, hedge, or close your trade.

Monitor Gamma Risk: warning appears when price nears short strikes (explosive delta risk).

📌 Summary
Feature Description
Mode Switching Plan (Setup) or Track (Live)
IV Rank & ATR Modeling Estimates volatility environment
Auto Strike Planning Suggests strikes based on risk/delta
Visual Range Map Profit, breakeven, and adjustment zones
Real-Time Alerts Warns when nearing or breaching strikes
Trade Info Box Displays live risk, reward, delta, IV, and P&L
Setup Table Compares setups across risk tiers
Fully Configurable Works for Iron Condors or Butterflies

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.