OPEN-SOURCE SCRIPT
SPY Wheel Strategy

SPY Wheel Strategy — Methodology
Version: 1.0
Instrument: SPY (SPDR S&P 500 ETF)
Timeframe: Daily chart
Backtested: April 2023 – March 2026
Overview
This strategy implements a modified covered call wheel on SPY. The core idea is simple: hold 100 shares, sell a daily covered call slightly above market, collect premium continuously, and re-enter immediately when shares are called away. The strategy is designed as a premium income machine first, with share appreciation as a secondary benefit.
Options premium income is not modeled in the TradingView backtest — the P&L shown reflects share transactions only. Estimated real-world premium income adds approximately $1,500–2,500 over the backtest period on top of reported figures, depending on prevailing IV.
Entry
Buy 100 shares of SPY at market open on the strategy start date. This is the only discretionary entry — all subsequent re-entries are rule-based.
Covered Call Leg (CC)
No gate required. The CC fires every trading day while shares are held.
Normal conditions (VIX < 25): Sell a 1DTE call at the strike price calculated as ceil(close × 1.0125), rounded up to the nearest $1 strike.
Elevated volatility (VIX ≥ 25): Switch to a 0DTE call at ceil(close × 1.03) to eliminate overnight gap risk while maintaining wider strike protection.
Cost basis rule: The CC strike is never set below the current cost basis. On days where the calculated strike would fall below cost basis, no CC is sold and the position is held unchanged. This prevents locking in a loss on assignment.
Assignment trigger: Shares are called away only if the daily close exceeds the strike. Intraday touches do not constitute assignment. This matches real 1DTE options expiration behavior.
Re-entry
After CC assignment, shares are repurchased at the open of the next trading day. No waiting, no conditions. Instant re-entry was chosen over a CSP-based re-entry after backtesting showed that gate-filtered CSP waiting caused the strategy to sit idle during extended bull runs, significantly underperforming buy and hold.
CSP Gate — Six Conditions (Reference Only)
The six-gate framework was developed for an optional CSP re-entry mode and for live trading order discipline. All six must pass before a CSP order is placed. In the default instant re-entry configuration these gates are not active, but they remain visible in the status table as a live market environment dashboard.
GateConditionPurpose① 200 SMAClose > 200-day SMAMacro regime filter② 20 EMAClose > 20-day EMAShort-term trend filter③ RSIRSI(14) not in 75–85Not topping out④ VIXVIX < 25Volatility environment⑤ VWAPDisabled on daily chartIntraday execution timing⑥ MacroNot FOMC / CPI / NFP dayScheduled event filter
Emergency Exit
If SPY closes below the 200-day SMA for 3 consecutive days while shares are held, the position is closed at the next open and the strategy moves to cash. Re-entry occurs automatically when SPY closes back above the 200 SMA. This rule protects against prolonged bear market drawdowns where the cost basis trap would prevent meaningful CC income.
A secondary alert (yellow background) fires when SPY closes below the 20 EMA for 2 consecutive days, signaling the trader to consider purchasing a protective put to define downside risk.
Visual Reference
Chart ElementMeaningOrange line200-day SMABlue line20-day EMARed dashed lineCurrent cost basisGreen dashed lineActive CC strikeRed background tintVIX ≥ 25 — high volatility regimeYellow background tint20 EMA breach — hedge alert
Backtest Results (Share P&L Only)
MetricValuePeriodApr 2023 – Mar 2026Starting capital$70,000Total trades11 complete cyclesRealized share P&L$23,393Unrealized (open trade)$5,296Combined$28,689Buy & hold same period$25,595Estimated premium income$1,200 – $2,500
Premium income is estimated based on 637 CC contracts sold at an average of $1.50–2.50 per contract, reflecting 1DTE 1.25% OTM pricing at prevailing IV conditions. Actual results will vary with market volatility.
Known Limitations
Cost basis trap: During extended drawdowns the CC strike constraint (never below cost basis) prevents selling calls near the money. Premium income drops significantly during these periods.
Tail risk: A multi-year bear market will eventually breach the 200 SMA exit rule, realizing a loss. The strategy does not fully hedge equity risk — it reduces it through active cost basis management and daily premium income.
Premium not modeled: The backtest P&L reflects shares only. A complete picture requires adding real options premium data.
Daily bar assignment: TradingView backtests on daily bars. Assignment logic uses close-of-bar price checks to replicate real expiration behavior. Intraday simulation is not possible in this framework.
Settings (Adjustable via ⚙ Settings Cog)
ParameterDefaultDescriptionCC Strike % — Normal VIX1.25%OTM distance for 1DTE CCCC Strike % — High VIX3.00%OTM distance for 0DTE CCVIX Gate Threshold25VIX level triggering high-VIX CC modeRSI Block Zone75–85RSI range blocking CSP (set Lo > Hi to disable)200 SMA Length200Long-term trend MA20 EMA Length20Short-term trend MA200 SMA Breach Days3Consecutive days below 200 SMA to trigger exit20 EMA Breach Days2Consecutive days below 20 EMA to trigger hedge alertRe-entry ModeInstantInstant open re-entry vs CSP waitStart Date2023-04-03Backtest start
Disclaimer
This script is published for educational and research purposes. It does not constitute financial advice. Past backtest performance does not guarantee future results. Options trading involves substantial risk. Always conduct your own due diligence before trading.
Version: 1.0
Instrument: SPY (SPDR S&P 500 ETF)
Timeframe: Daily chart
Backtested: April 2023 – March 2026
Overview
This strategy implements a modified covered call wheel on SPY. The core idea is simple: hold 100 shares, sell a daily covered call slightly above market, collect premium continuously, and re-enter immediately when shares are called away. The strategy is designed as a premium income machine first, with share appreciation as a secondary benefit.
Options premium income is not modeled in the TradingView backtest — the P&L shown reflects share transactions only. Estimated real-world premium income adds approximately $1,500–2,500 over the backtest period on top of reported figures, depending on prevailing IV.
Entry
Buy 100 shares of SPY at market open on the strategy start date. This is the only discretionary entry — all subsequent re-entries are rule-based.
Covered Call Leg (CC)
No gate required. The CC fires every trading day while shares are held.
Normal conditions (VIX < 25): Sell a 1DTE call at the strike price calculated as ceil(close × 1.0125), rounded up to the nearest $1 strike.
Elevated volatility (VIX ≥ 25): Switch to a 0DTE call at ceil(close × 1.03) to eliminate overnight gap risk while maintaining wider strike protection.
Cost basis rule: The CC strike is never set below the current cost basis. On days where the calculated strike would fall below cost basis, no CC is sold and the position is held unchanged. This prevents locking in a loss on assignment.
Assignment trigger: Shares are called away only if the daily close exceeds the strike. Intraday touches do not constitute assignment. This matches real 1DTE options expiration behavior.
Re-entry
After CC assignment, shares are repurchased at the open of the next trading day. No waiting, no conditions. Instant re-entry was chosen over a CSP-based re-entry after backtesting showed that gate-filtered CSP waiting caused the strategy to sit idle during extended bull runs, significantly underperforming buy and hold.
CSP Gate — Six Conditions (Reference Only)
The six-gate framework was developed for an optional CSP re-entry mode and for live trading order discipline. All six must pass before a CSP order is placed. In the default instant re-entry configuration these gates are not active, but they remain visible in the status table as a live market environment dashboard.
GateConditionPurpose① 200 SMAClose > 200-day SMAMacro regime filter② 20 EMAClose > 20-day EMAShort-term trend filter③ RSIRSI(14) not in 75–85Not topping out④ VIXVIX < 25Volatility environment⑤ VWAPDisabled on daily chartIntraday execution timing⑥ MacroNot FOMC / CPI / NFP dayScheduled event filter
Emergency Exit
If SPY closes below the 200-day SMA for 3 consecutive days while shares are held, the position is closed at the next open and the strategy moves to cash. Re-entry occurs automatically when SPY closes back above the 200 SMA. This rule protects against prolonged bear market drawdowns where the cost basis trap would prevent meaningful CC income.
A secondary alert (yellow background) fires when SPY closes below the 20 EMA for 2 consecutive days, signaling the trader to consider purchasing a protective put to define downside risk.
Visual Reference
Chart ElementMeaningOrange line200-day SMABlue line20-day EMARed dashed lineCurrent cost basisGreen dashed lineActive CC strikeRed background tintVIX ≥ 25 — high volatility regimeYellow background tint20 EMA breach — hedge alert
Backtest Results (Share P&L Only)
MetricValuePeriodApr 2023 – Mar 2026Starting capital$70,000Total trades11 complete cyclesRealized share P&L$23,393Unrealized (open trade)$5,296Combined$28,689Buy & hold same period$25,595Estimated premium income$1,200 – $2,500
Premium income is estimated based on 637 CC contracts sold at an average of $1.50–2.50 per contract, reflecting 1DTE 1.25% OTM pricing at prevailing IV conditions. Actual results will vary with market volatility.
Known Limitations
Cost basis trap: During extended drawdowns the CC strike constraint (never below cost basis) prevents selling calls near the money. Premium income drops significantly during these periods.
Tail risk: A multi-year bear market will eventually breach the 200 SMA exit rule, realizing a loss. The strategy does not fully hedge equity risk — it reduces it through active cost basis management and daily premium income.
Premium not modeled: The backtest P&L reflects shares only. A complete picture requires adding real options premium data.
Daily bar assignment: TradingView backtests on daily bars. Assignment logic uses close-of-bar price checks to replicate real expiration behavior. Intraday simulation is not possible in this framework.
Settings (Adjustable via ⚙ Settings Cog)
ParameterDefaultDescriptionCC Strike % — Normal VIX1.25%OTM distance for 1DTE CCCC Strike % — High VIX3.00%OTM distance for 0DTE CCVIX Gate Threshold25VIX level triggering high-VIX CC modeRSI Block Zone75–85RSI range blocking CSP (set Lo > Hi to disable)200 SMA Length200Long-term trend MA20 EMA Length20Short-term trend MA200 SMA Breach Days3Consecutive days below 200 SMA to trigger exit20 EMA Breach Days2Consecutive days below 20 EMA to trigger hedge alertRe-entry ModeInstantInstant open re-entry vs CSP waitStart Date2023-04-03Backtest start
Disclaimer
This script is published for educational and research purposes. It does not constitute financial advice. Past backtest performance does not guarantee future results. Options trading involves substantial risk. Always conduct your own due diligence before trading.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.