OPEN-SOURCE SCRIPT

Vegas ema 過濾

105
Vegas Channel with EMA-Filter — Trading Rules

Components

Tunnel: EMA 144 & 169 (upper = max, lower = min).

Base: EMA 576 & 676 (upper = max, lower = min).

Fast filter: EMA12.

Touch threshold: ATR-based or % of the reference line.

Long touch = low ≤ line + thr; Short touch = high ≥ line − thr.

Trend gate

LongTrendOK: EMA144 > EMA576 and EMA169 > EMA676 and close > BaseUpper.

ShortTrendOK: EMA144 < EMA576 and EMA169 < EMA676 and close < BaseLower.

Price-action pattern (either one)

Pin40: bullish pin = close>open & lower wick ≥ 40% of range; bearish pin = close<open & upper wick ≥ 40%.

Eng60: bullish engulf = current green & previous red & body ≥ 60% of prev body; bearish symmetrical.

Touch logic (with auto switching)

LONG: require a lower-edge touch of the active band.

If EMA12 < 169 → use Base (576/676).

Else → use Tunnel (144/169).

SHORT: require an upper-edge touch of the active band.

If EMA12 > 169 → use Base.

Else → use Tunnel.

EMA12 hard locks (coarse filter)

Lock longs if EMA12 < 676 (no long signals at all).

Lock shorts if EMA12 > 676 (no short signals at all).

(Optional) Tunnel lock/unlock (fine filter)

Lock longs when EMA12 drops below TunnelLower; unlock when
A) EMA12 crosses back above 144/169/TunnelUpper, or
B) a bullish Pin/Eng appears at BaseUpper and EMA12 is back ≥ TunnelLower.

Lock shorts when EMA12 breaks above TunnelUpper; unlock when
A) EMA12 crosses back below 144/169/TunnelLower, or
B) a bearish Pin/Eng appears at BaseLower and EMA12 is ≤ TunnelUpper.

Final signal

LONG fires when: Close-bar confirmed ∧ Cooldown passed ∧ LongTrendOK ∧ ActiveBand lower touch ∧ Pin40 or Eng60 ∧ not hard-locked ∧ (not tunnel-locked if enabled).

SHORT symmetrical with upper touch.

Quality-of-life

Close-bar confirmation to avoid repaint.

Cooldown (e.g., 10 bars) to prevent signal clusters.

Alerts include a compact lock status string (LckL/LckS/HardL/HardS).

Optional “BLOCK:” labels show why a bar didn’t trigger (noTouch, EMA12<676/>676, TunnelLock, cooldown, notClose).

Suggested defaults

ATR(14), ATR multiplier 0.35 (or 0.20% if using Percent mode).

autoSwitchByEMA12_* = ON, hardLockBelow676/Above676 = ON, useTunnelLock* = OFF.

useCloseBar = ON, signalCooldown = 10.

Design intent

Tunnel (144/169) captures the working trend; Base (576/676) defines the structural bias.

EMA12 drives regime selection (Tunnel vs Base) and hard locks to keep signals sparse and aligned with momentum.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.