← Library
Pine Script v6 · Indicator · TradingView · NASDAQ:AAPL LEAPS + Swing IBKR Live V1 — AAPL LEAPS & Swing System

AAPL-LSS-V1

AAPL LEAPS & Swing System v1 · Long-Term Options Entry + Swing Stock Trades · VIX-Filtered · Earnings Blackout · IBKR Execution

File: aapl_leaps_signal.pine Type: indicator() — overlay Instruments: NASDAQ:AAPL VIX Feed: CBOE:VIX (daily) LEAPS Budget: $5,000 Swing Budget: $2,000 Created: June 2026

Overview

AAPL-LSS-V1 is a dual-mode position-building system for Apple Inc. (AAPL) built on the thesis that the AI Siri upgrade cycle will drive price to the $320–$500 range over 6–18 months. The system operates two execution channels simultaneously: a LEAPS channel targeting deep in-the-money calls (Δ 0.70–0.80, 12–18mo DTE) for levered upside exposure, and a Swing channel for direct stock accumulation on technical pullbacks.

All signals are VIX-filtered and subject to a 7-day earnings blackout window. LEAPS and Swing signals route live orders to Interactive Brokers via the AAPL_HANDLER service. Accumulation tiers fire TradingView push/SMS alerts only — no IBKR routing.

CHANNEL 1
LEAPS
RSI + 200 EMA — IBKR options
CHANNEL 2
SWING
EMA cross / pullback — IBKR stock
CHANNEL 3
ACCUM
4 tiers — alert only
FILTER
VIX
CBOE:VIX daily feed
EXECUTION
IBKR
aapl_handler.py port 8084
Investment Thesis Apple's AI-enhanced Siri (scheduled for release 2026–2027) is expected to drive a significant re-rating of AAPL. Price targets: $320 (resistance), $350 (base case), $400 (bull), $450 (bull+), $500 (AI supercycle). LEAPS with 12–18mo DTE and delta 0.70–0.80 provide levered exposure without the full capital commitment of shares.

Channel 1 — LEAPS Entry

LEAPS signals identify conditions where AAPL is oversold relative to its long-term trend — an ideal environment for purchasing deep ITM calls with 12–18 months of time value. Three conditions must align simultaneously.

Entry Conditions (all three required)

ConditionThresholdInterpretation
RSI(14)< 40Oversold — momentum exhaustion
Distance from 200 EMAWithin ±5%Price near long-term mean — not extended
Earnings blackoutMust be CLEARNo new entries within 7 days of earnings

Signal Flow — LEAPS

RSI < 40
+
|Δ 200 EMA| ≤ 5%
+
Not Blackout
LEAPS ENTRY
Webhook
IBKR
CALL Order

IBKR Options Execution

On a LEAPS_ENTRY signal, aapl_handler.py queries the IB option chain and selects the optimal contract based on delta and expiration constraints.

ParameterValueNotes
Option typeCALLRight side only — no puts in this model
Delta target0.70 – 0.80Deep ITM — high intrinsic value, tracks stock closely
DTE range365 – 540 days12–18 months — sufficient runway for thesis to play out
Strike selection82–95% of spotEmpirical range for Δ 0.70–0.80 on 12–18mo AAPL calls
Fallback strike88% of spotUsed when no delta match found (≈ Δ 0.75 empirically)
Order typeLimit — midpointBid/ask midpoint, DAY order, transmit=True
Budget$5,000 (configurable)qty = floor($budget / (mid × 100))
Account (paper)DU3317167Port 4002 — IB Paper Gateway
Account (live)U5288143Port 4001 — requires IBKR_MODE=LIVE
clientId20Unique — does not conflict with PHANTOM (0-9) or BTC (10-19)
First Signal is Edge-Triggered The script uses leaps_entry = leaps_cond and not leaps_cond[1] — it fires only on the first bar where all three conditions are true, not on every bar while conditions hold. This prevents duplicate orders from sustained RSI weakness.

Channel 2 — Swing Entries

The swing channel fires stock orders to IBKR on two distinct technical patterns. Both require price to be clear of the earnings blackout window.

Swing Signal A — EMA Crossover

ConditionThresholdInterpretation
EMA 20 crosses above EMA 50ta.crossover(e20, e50)Short-term momentum turning up
RSI> 50Confirming bullish momentum — not fading
Volume> 1.3× 20-period SMAInstitutional participation on the cross
Earnings blackoutMust be CLEARNo new entries within 7 days of earnings

model_id: AAPL_SWING_v1 · signal_type: SWING_EMA_CROSS

Swing Signal B — Pullback + Engulfing

ConditionThresholdInterpretation
Price above 200 EMAclose > e200Long-term uptrend intact
Price near EMA 20Within ±1% of EMA 20Pulled back to short-term mean
Bullish engulfing candleCurrent bar engulfs prior bear barBuyers absorbing the pullback
Earnings blackoutMust be CLEARNo new entries within 7 days of earnings

model_id: AAPL_SWING_v1 · signal_type: SWING_PULLBACK

Signal Flow — Swing Stock Order

EMA Cross or
Pullback + Engulf
+
Not Blackout
SWING Webhook
IBKR
STOCK Order

Swing IBKR Execution

ParameterValue
InstrumentAAPL stock (SMART routing)
Order typeLimit — spot × 1.001 (0.1% above signal price)
Budget$2,000 (configurable)
Sharesfloor($2,000 / signal_price)
TIFDAY — expires if not filled by close

Channel 3 — Accumulation Tiers (Alert Only)

Four tiered accumulation signals provide a systematic buying protocol for adding to long-term AAPL positions as price dislocates from fair value. These fire TradingView push/SMS alerts only — they do not route to NIGHTHAWK or IBKR. Manual execution required.

TIER 1
25%
RSI < 40
above 200 EMA
TIER 2
+25%
RSI < 35
at lower BB
TIER 3
+25%
Price 10% below
52-week high
TIER 4
+25%
VIX > 30
RSI < 30 — Panic
TierAlert NameTriggerDeploy
T1Accum Tier 1 — 25% BuyRSI < 40 and above 200 EMA (first bar)25% of accumulation budget
T2Accum Tier 2 — +25%RSI < 35 and price ≤ lower Bollinger Band (first bar)Add 25%
T3Accum Tier 3 — +25%Price ≤ 90% of 52-week high (first bar)Add 25%
T4Accum Tier 4 — Final 25%VIX > 30 AND RSI < 30 — panic conditions (first bar)Deploy final 25%
SMS / Push Only Accumulation tiers use alertcondition(), not alert() — static text payload sent via TradingView push notification and SMS. No JSON webhook is generated. These must be acted on manually in your IBKR account.

VIX Integration

The live CBOE VIX is pulled via request.security("CBOE:VIX", "D", close) and used in two ways: the dashboard table displays the current reading, and Tier 4 accumulation uses it as a panic-buy trigger.

VIX LevelDashboard ColorMeaning
< 25Lime (green)Low fear — normal market conditions
25 – 30OrangeElevated fear — VIX green light threshold (configurable)
> 30RedHigh fear — Tier 4 accumulation trigger active
VIX in LEAPS Payload Every LEAPS and Swing webhook includes the current VIX reading in metadata.vix. This gives NIGHTHAWK and the execution log a snapshot of market fear at signal time — useful for post-trade analysis and future model training.

Earnings Blackout

A configurable blackout window (default 7 days) suppresses all LEAPS and Swing signals in the period leading up to each Apple earnings release. The earnings dates are stored as input.int(timestamp(...)) values and must be updated each quarter.

Earnings EventDateBlackout Starts
Q3 FY20262026-07-312026-07-24
Q4 FY20262026-10-302026-10-23
Q1 FY20272027-01-292027-01-22
Q2 FY20272027-04-302027-04-23

A separate earn_warn condition fires on the first bar of the blackout window — triggering an alertcondition() SMS: "AAPL EARNINGS in 7 days — BLACKOUT ACTIVE." The chart background turns orange during the entire blackout period.

Quarterly Maintenance Required Update earn_1 through earn_4 in the Earnings input group after each quarterly release. The model will continue suppressing signals around the old dates if not updated. Rotate: remove the oldest date and add the next confirmed earnings date.

Chart Visuals

EMA 20 (aqua)
EMA 50 (yellow)
EMA 200 (white)
Bollinger Bands (gray, 50% transparent)
Zone background — Green (RSI < 35, ±5% 200 EMA, VIX > 25)
Zone background — Red (RSI > 70 or 15%+ above 200 EMA)
Zone background — Orange (earnings blackout active)
ElementStyleDescription
LEAPS ENTRY labelGreen triangle (below bar)Shows RSI value and delta range — fires on edge trigger
SWING EMA CROSS labelAqua triangle (below bar)EMA 20/50 crossover confirmed
SWING PULLBACK labelBlue triangle (below bar)Pullback to EMA 20 with engulfing
T1–T4 accumulation labelsLime/orange/red (above bar)Manual accumulation tier triggers
EARNINGS BLACKOUT labelOrange (above bar)First bar of 7-day blackout window
$320 lineYellow dashedResistance / first target
$350 lineGreen dashedBase case 12-18mo target
$400 lineLime dashedBull case
$450 lineTeal dottedBull+ extended target
$500 linePurple dottedAI supercycle target

Live Dashboard Table (Top Right)

A 2-column × 9-row table updates on every bar, showing real-time model state.

RowWhen Lime (✓)When Gray / Other
RSI(14)< 40 (lime)> 70 (red), otherwise white
200 EMA Δ%|distance| ≤ 5% (lime)White otherwise
VIX< 25 (lime)25–30 orange, > 30 red
ZONEGREEN ✓ (RSI < 35, ±5% EMA, VIX > 25)RED ✗ or YELLOW —
LEAPSARMED ✓ (all conditions met)WAITING — (gray)
EARNINGSCLEAR (lime)BLACKOUT ⚠ (orange)
LEAPS $Configured budget in dollars
SWING $Configured budget in dollars

All Configurable Inputs

GroupParameterDefaultNotes
Signal LayersLEAPS SignalstrueToggle LEAPS entry labels and webhooks
Signal LayersSwing SignalstrueToggle swing entry labels and webhooks
Signal LayersAccumulation Tier LabelstrueToggle T1–T4 labels (alertcondition still fires)
DisplayZone Background ColorstrueGreen / red / orange background tints
DisplayPrice Target Linestrue$320 / $350 / $400 / $450 / $500 dashed lines
DisplayDashboard TabletrueTop-right status table
DisplayBollinger Bandstrue20-period BB overlay (gray, 50% transparent)
Position SizingLEAPS Budget ($)5000Max capital deployed per LEAPS signal
Position SizingSwing Budget ($)2000Max capital deployed per swing signal
IndicatorsRSI Length14Standard RSI lookback
IndicatorsEMA Fast / Mid / Long20 / 50 / 200Three-EMA system
IndicatorsBB Length / Multiplier20 / 2.0Standard Bollinger Bands
IndicatorsVolume Multiplier1.3Minimum volume for EMA cross confirmation
VIXVIX Green Light25.0VIX above this = low fear, green zone threshold
VIXVIX Tier 4 Fear30.0VIX above this = T4 accumulation trigger eligible
EarningsBlackout Days Before Earnings7Days before each earnings date to suppress signals
EarningsEarnings 1–4Jul/Oct 2026, Jan/Apr 2027Update each quarter — use input.int(timestamp(...))

Alert Messages — JSON Payload

alert() with alert.freq_once_per_bar_close is used for all three webhook signals. Accumulation tiers use alertcondition() (static text, push/SMS only).

LEAPS Entry (model_id: AAPL_LEAPS_v1)

{ "secret": "tac_com_alpha_9", "model_id": "AAPL_LEAPS_v1", "ticker": "AAPL", "action": "BUY", "price": 198.42, "signal_type": "LEAPS_ENTRY", "metadata": { "rsi": 38.7, "vix": 24.1, "dist_200ema": -2.14, "delta_min": 0.70, "delta_max": 0.80, "dte_min": 365, "dte_max": 540, "budget": 5000 } }

Swing EMA Cross (model_id: AAPL_SWING_v1)

{ "secret": "tac_com_alpha_9", "model_id": "AAPL_SWING_v1", "ticker": "AAPL", "action": "BUY", "price": 212.18, "signal_type": "SWING_EMA_CROSS", "metadata": { "rsi": 53.2, "vix": 18.4, "budget": 2000 } }

Swing Pullback (model_id: AAPL_SWING_v1)

{ "secret": "tac_com_alpha_9", "model_id": "AAPL_SWING_v1", "ticker": "AAPL", "action": "BUY", "price": 208.55, "signal_type": "SWING_PULLBACK", "metadata": { "rsi": 44.6, "vix": 21.0, "budget": 2000 } }

Alert Conditions (5 total — push/SMS only)

Alert NameEventPayload
Accum Tier 1 — 25% BuyRSI < 40 above 200 EMA (first bar)SMS text — no JSON
Accum Tier 2 — +25%RSI < 35 at lower Bollinger Band (first bar)SMS text — no JSON
Accum Tier 3 — +25%Price 10% below 52-week high (first bar)SMS text — no JSON
Accum Tier 4 — Final 25%VIX > 30 AND RSI < 30 (first bar)SMS text — no JSON
Earnings Blackout StartFirst bar of 7-day blackout windowSMS text — no JSON

NIGHTHAWK Signal Routing

All three webhook signals (LEAPS_ENTRY, SWING_EMA_CROSS, SWING_PULLBACK) arrive at http://35.221.12.143/webhook (port 80, iptables → 8080) and are processed by nighthawk/app.js. The model_id prefix AAPL_ triggers the IBKR forward block.

TradingView
Webhook
NIGHTHAWK
:8080
SENTINEL
PostgreSQL
+
Twilio
SMS
+
AAPL_HANDLER
:8084
IBKR
Order
model_id prefixForward TargetPortTimeout
AAPL_aapl_handler.py (FastAPI)808445,000ms (option chain lookup)
MNQ / MNQ tickerPHANTOM orchestration80815,000ms
BTC-ACCUM-v1btc_accumulator80825,000ms
Sentinel DB — Model Registration Required Register both model IDs in the models table before signals will execute live orders. Status OBSERVATION = logs and SMS only. Status LIVE = full execution.

INSERT INTO models (model_id, status) VALUES ('AAPL_LEAPS_v1', 'OBSERVATION');
INSERT INTO models (model_id, status) VALUES ('AAPL_SWING_v1', 'OBSERVATION');

TradingView Setup

  1. Open NASDAQ:AAPL on your preferred timeframe (daily recommended for LEAPS signals; 4H/daily for swing).
  2. Open Pine Editor (Alt+P), paste aapl_leaps_signal.pine, click Add to chart. The script is an indicator — not a strategy — so no Strategy Tester is available.
  3. Verify the three EMA lines (aqua=20, yellow=50, white=200), Bollinger Bands, and price target dashed lines appear correctly on the chart.
  4. Confirm the dashboard table appears top-right showing RSI, 200 EMA Δ, VIX, Zone, LEAPS status, Earnings, and budgets.
  5. Right-click the indicator → Add alert. For LEAPS and Swing webhooks, select "Any alert() function call" → set Webhook URL to http://35.221.12.143/webhook.
  6. For accumulation tiers, create 5 additional alerts selecting each individual alertcondition() by name. These can route to TradingView email, push, and SMS — no webhook needed.
  7. AAPL_HANDLER must be running on the GCP VM: pm2 status AAPL_HANDLER. Confirm /health returns {"status":"ok","mode":"PAPER","account":"DU3317167"}.
  8. When IBKR deposit clears and you are ready to go live: set IBKR_MODE=LIVE in .envpm2 restart AAPL_HANDLER --update-env. Then update both model records in Sentinel to LIVE.
Paper Trade First The system defaults to paper account DU3317167. Run at least 2–4 weeks of paper trading to validate the full webhook → NIGHTHAWK → AAPL_HANDLER → IB Gateway execution chain before switching to live account U5288143. Check AAPL_HANDLER PM2 logs for order confirmation details.

Sentinel DB Registration

FieldLEAPS ModelSwing Model
model_idAAPL_LEAPS_v1AAPL_SWING_v1
statusOBSERVATIONOBSERVATION
Signal typeLEAPS_ENTRYSWING_EMA_CROSS / SWING_PULLBACK
ExecutionIBKR CALL option — find_leaps()IBKR STOCK — limit order
DeployedJune 2026June 2026
OBSERVATION Status Both models are in OBSERVATION mode. Signals are logged to Sentinel and SMS is dispatched, but the AAPL_HANDLER still places orders on the paper account (IBKR_MODE=PAPER). Promote to LIVE only after IBKR deposit clears and paper trading validates execution chain.