OPEN-SOURCE SCRIPT

EEI Strategy — Greedy/Guarded v1.2

423
Purpose

Day‑trading strategy (5‑min focus) that hunts “armed” setups (PRE) and confirms them (GO) with greedy-but‑guarded execution. It adapts to symbol type, trend strength, and how long it’s been since the last signal.

Core signals & regime

Trend/Regime: EMA‑200 (intraday bias), VWAP, and a non‑repainting HTF EMA (via request.security(...)[1]).

Momentum/Structure: Manual Wilder DMI/ADX, micro‑ribbon (EMA 8/21), Bollinger‑Keltner squeeze + “squeeze fire,” BOS (break of swing high/low), pullback to band.

Liquidity/Vol: RVOL vs SMA(volume) + a latch (keeps eligibility a few bars after the first spike).

Volatility: ATR + ATR EMA (expansion).

PRE / GO engine

Score (0–100) aggregates trend, momentum, RVOL, squeeze, OBV slope, ribbon, pullback, BOS, and an Opening‑Range (OR) proximity penalty.

PRE arms when the adjusted score ≥ threshold and basic hygiene passes (ATR%, cooldown, etc.).

GO confirms within a dynamic window (1–3 bars):

Wick‑break mode on hot momentum (trend‑day / high ADX+RVOL): stop orders above/below the PRE high/low with a tick buffer.

Close‑through mode otherwise: close must push through PRE high/low plus ATR buffer.

Chase guard: entry cannot be too far from PRE price (ATR‑based), with a tiny extra allowance when the 8/21 ribbon aligns.

Multiple PREs per squeeze (capped) + per‑entry cooldown.

Adaptive behavior

Presets (Conservative/Balanced/Aggressive/Turbo) shift score/ADX/RVOL/ATR gates, GO window, cooldown, and max chase.

Profiles / Auto by Symbol:

Mega Trend (e.g., AMD/NVDA/TSLA/AAPL): looser chase, ATR stop, chandelier trail.

Mid Guarded (e.g., TTD/COIN/SOFI): swing stop, EMA trail, moderate gates.

Small Safe (e.g., BTAI/BBAI class): tighter gates, more guardrails.

BBAI micro‑override: easier arming (lower score/ADX/RVOL), multi‑PRE=3, swing stop + EMA trail, lighter OR penalty.

Trend‑day detector: if ADX hot + RVOL strong + ATR expanding + distance from day‑open large → GO window = 1 and wick‑break mode.

Mid‑day relaxers: mild score bonus between 10:30–14:30 to keep signals flowing in quieter tape.

Auto‑Relaxer (no‑signal fallback): after N bars without PRE/GO, gradually lowers score/ADX/RVOL/ATR% gates and raises max chase so the engine doesn’t stall on sleepy symbols.

Auto‑Session fallback: if RTH session isn’t detected (some tickers/premarket), it falls back to daily boundaries so Opening Range and day‑open logic still work.

Risk & exits

Initial stop per side chosen by ATR, Swing, or OR (computed every bar; no conditional calls).

Scaled targets: TP1/TP2 (R‑based) + runner with optional Chandelier or EMA trailing.

BE logic: optional move to breakeven after TP1; trailing can start after TP1 if configured.

Opening Range (OR)

Computes day open, OR high/low over configurable minutes; applies a penalty when entries are too close to OR boundary (lighter for small caps/BBAI). Protects against boundary whips.

Alerts & visuals

Alertconditions: PRE Long/Short Armed, GO Long/Short + explicit alert() calls for once‑per‑bar automation.

Plots: EMA‑200, HTF EMA, BB/KC bands, OR lines, squeeze shading, and PRE markers.

Why it’s robust

Non‑repainting HTF technique, all series precomputed every bar, no function calls hidden in conditionals that could break history dependence, and consistent state handling (var + sentinels).

Tuning cheat‑sheet (fast wins)

More trades: lower scoreBase, adxHot, or rvolMinBase a notch; reduce cooldownBase; increase maxPREperSqueeze.

Fewer whips: increase closeBufferATR, wickBufferTicks, or atrMinPct; reduce maxChaseATRBase.

Trend capture: use trailType="Chandelier", smaller trailLen, slightly larger trailMult; set preset="Aggressive".

Choppy names: prefer stopMode="Swing", enable EMA trail, keep OR penalty on.

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.