OPEN-SOURCE SCRIPT
SPX 0DTE Move Study

Overview
This is a research tool, not a signal generator. It answers one narrow question: on days that open with a given VIX level and a given ATR regime, how often has SPX's open-to-close range historically exceeded a chosen distance (e.g. 17, 25, 35, or 50 points)?
That question matters for any options structure whose payoff depends on the underlying moving far enough by expiration — for example a long (debit) iron condor, which is the mirror image of the far more common short iron condor: instead of collecting a credit and profiting when price stays inside a range, it costs a debit and profits when price travels beyond a range. This script does not evaluate, price, or recommend that or any other structure. It only measures how often the day's cash-settled move has historically cleared a distance, split by conditions known before the open.
How It Works
The measurement
Each trading day contributes one data point: the absolute distance between the 09:30 ET open and the 16:00 ET close. Only that single number is used — not the day's high, low, or path.
Daily vs. intraday
On a daily chart, the bar's own open and close ARE the 09:30 and 16:00 prints, which lets the study run over decades of history instead of the ~1500 days an intraday chart can hold. Both modes are supported and can be cross-checked against each other on the same window.
The conditioning variables
Every day is bucketed by the VIX level at the open and by that day's ATR regime — where ATR (read only from the last CLOSED daily bar, never the forming one) sits relative to its own moving average. The ATR ratio is bucketed rather than raw points, so the study reads the same on SPX at 2,000 and at 7,500.
The nested test
The core view splits each VIX band into ATR sub-rows and reports what the ATR split adds INSIDE that band — a bracketed delta versus the VIX band's own baseline, so the VIX condition is held fixed rather than compared against all days blended together. A per-band sign-agreement count and a "day of week" control (which cannot logically move SPX and so defines the noise floor at the current sample size) are both included specifically to help separate a real conditional effect from one that only looks like one.
No lookahead
The colored column plot ("traffic light") scores each day using only the days that finished before it — the running tally is read, then updated, so no day is ever colored using its own outcome or a future one.
What Makes This Different
Most VIX/ATR overlays plot the raw values and leave interpretation to the reader. This script instead builds an actual frequency table conditioned on both variables jointly, checks whether a split's effect is consistent across bands (rather than reporting one flattering number), and includes a built-in noise-floor control so a spread can be judged against what chance alone produces at that sample size.
Features
Settings Guide
Distances
VIX Bands
ATR Regime
Display
How to Use
Alerts
No built-in alert conditions — this is a statistics/research tool, not a signal generator. If wanted, a price-crossing alert can be set manually on the "odds over D1 (%)" plot using TradingView's standard alert dialog.
Limitations
Disclaimer
This script is for educational and research purposes only. It does not constitute financial or investment advice, and it does not recommend any specific options structure, position, or trade.
Credits
Original methodology and implementation by the author. No third-party code was reused.
This is a research tool, not a signal generator. It answers one narrow question: on days that open with a given VIX level and a given ATR regime, how often has SPX's open-to-close range historically exceeded a chosen distance (e.g. 17, 25, 35, or 50 points)?
That question matters for any options structure whose payoff depends on the underlying moving far enough by expiration — for example a long (debit) iron condor, which is the mirror image of the far more common short iron condor: instead of collecting a credit and profiting when price stays inside a range, it costs a debit and profits when price travels beyond a range. This script does not evaluate, price, or recommend that or any other structure. It only measures how often the day's cash-settled move has historically cleared a distance, split by conditions known before the open.
How It Works
The measurement
Each trading day contributes one data point: the absolute distance between the 09:30 ET open and the 16:00 ET close. Only that single number is used — not the day's high, low, or path.
Daily vs. intraday
On a daily chart, the bar's own open and close ARE the 09:30 and 16:00 prints, which lets the study run over decades of history instead of the ~1500 days an intraday chart can hold. Both modes are supported and can be cross-checked against each other on the same window.
The conditioning variables
Every day is bucketed by the VIX level at the open and by that day's ATR regime — where ATR (read only from the last CLOSED daily bar, never the forming one) sits relative to its own moving average. The ATR ratio is bucketed rather than raw points, so the study reads the same on SPX at 2,000 and at 7,500.
The nested test
The core view splits each VIX band into ATR sub-rows and reports what the ATR split adds INSIDE that band — a bracketed delta versus the VIX band's own baseline, so the VIX condition is held fixed rather than compared against all days blended together. A per-band sign-agreement count and a "day of week" control (which cannot logically move SPX and so defines the noise floor at the current sample size) are both included specifically to help separate a real conditional effect from one that only looks like one.
No lookahead
The colored column plot ("traffic light") scores each day using only the days that finished before it — the running tally is read, then updated, so no day is ever colored using its own outcome or a future one.
What Makes This Different
Most VIX/ATR overlays plot the raw values and leave interpretation to the reader. This script instead builds an actual frequency table conditioned on both variables jointly, checks whether a split's effect is consistent across bands (rather than reporting one flattering number), and includes a built-in noise-floor control so a spread can be judged against what chance alone produces at that sample size.
Features
- Four table views — VIX only, ATR only, VIX × ATR (nested), and a Day-of-Week control
- Up to 4 configurable distance thresholds per table
- Minimum-sample-size floor — thin rows are greyed out and excluded from the verdict line
- Forward-only "traffic light" plot showing each day's historical odds before the fact
- ATR plotted as a percentage of its own moving average, sharing one scale with VIX
- Configurable VIX band edges (up to 5 splits) and ATR split method (over/under average, rising/falling, or four combined states)
- Optional date-range restriction, for testing whether a result survives outside the window it was found in
- CSV export via Pine Logs
- Works on daily (recommended, full history) or intraday (adjustable entry offset) charts
Settings Guide
Distances
- [code]Table[/code] - Which conditioning view to display; "Day of week" is the control, not a predictor
- [code]Distance 1-4[/code] - The point thresholds each column measures; Distance 1 also drives the traffic-light plot and the verdict line
- [code]Lookback[/code] - How many recent trading days feed the table and the running tally
- [code]Min Days per Band[/code] - Rows below this are excluded from the verdict as statistically unreliable
VIX Bands
- [code]VIX edge 1-5[/code] - Where the VIX bands split; fewer edges means larger, more stable buckets
ATR Regime
- [code]ATR split[/code] - Over/under its average is the simplest and most sample-efficient choice
- [code]ATR length / EMA of ATR[/code] - How the current ATR and its baseline average are measured
Display
- [code]Show the table[/code] / [code]Traffic light[/code] - Toggle the statistics table and the forward-only day coloring independently
How to Use
- Add to a daily SPX chart on the regular session (required for the open/close reading to be correct)
- Read the TODAY row: current VIX, current ATR regime, and how many historical days matched
- Check the row's sample size against your Min Days setting before drawing any conclusion from it
- Look at the VIX × ATR view to see whether ATR regime adds anything on top of VIX alone, and whether that addition agrees in sign across bands
- Compare against the Day-of-week control on the same lookback to see where the noise floor currently sits
Alerts
No built-in alert conditions — this is a statistics/research tool, not a signal generator. If wanted, a price-crossing alert can be set manually on the "odds over D1 (%)" plot using TradingView's standard alert dialog.
Limitations
- Reports historical base rates, not predictions — a day matching a bucket's profile does not guarantee that day repeats the bucket's history
- Only measures the open-to-close distance; it says nothing about the intraday path, which matters for any position that could be affected by movement before expiration
- VIX and ATR band edges are user-chosen; different edges can produce different-looking splits, so results should be checked for robustness across edge choices
- Excludes thin rows from the verdict, but a row that just clears the minimum sample is still a small-sample estimate
- Does not model options pricing, bid-ask spread, commissions, or fill quality for any specific structure
- Intraday entry offset has no effect on daily charts, and daily analysis requires the regular session (extended-hours daily bars are flagged as invalid)
Disclaimer
This script is for educational and research purposes only. It does not constitute financial or investment advice, and it does not recommend any specific options structure, position, or trade.
- Past frequency does not guarantee future results
- Historical base rates are not a forecast for any individual day
- Always conduct your own research and consider your own risk tolerance before making any trading decision
Credits
Original methodology and implementation by the author. No third-party code was reused.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.