OPEN-SOURCE SCRIPT
Aggiornato

SMA + Heiken Ashi Signals with BB Width Filter (Toggle + Label)

82
🎯 Purpose
This script gives Buy, Sell, Exit Buy, and Exit Sell signals based on:

SMA crossovers

Heiken Ashi candle trend reversal

Bollinger Band Width filter to avoid trades in sideways markets

It’s designed for clean signal-only trading, with no actual order execution — ideal for discretionary or alert-based traders.

🧠 Logic Explained
✅ 1. Entry Signals (Buy/Sell)
Based on a fast SMA crossing a slow SMA
→ Uses 1-minute data (via request.security) for faster signal generation even on higher timeframes.

Only triggers if:

✅ Price is trending in the direction of the trade (above or below a 50-period SMA)

✅ Bollinger Band width is wide enough, indicating a strong trend

✅ You're not already in that direction (prevents duplicate signals)

❌ 2. Exit Signals (Exit Buy / Exit Sell)
Based on 3-minute Heiken Ashi candles

Exit Buy when: Heiken Ashi candle turns red (bearish)

Exit Sell when: Heiken Ashi candle turns green (bullish)

This smooths out the exit and prevents premature exits from short-term noise.

📊 3. Bollinger Band Width Filter
Measures distance between BB upper & lower bands

Normalized by dividing by the midline (basis) → bbWidth

If bbWidth < minWidth, signals are blocked to avoid consolidating markets

You can toggle this filter on/off and adjust the minWidth input.

🔁 4. Trade State Tracking
Uses two var bool flags:

inLong: True if in a long position

inShort: True if in a short position

Prevents the script from repeating signals until an exit occurs

Note di rilascio
Just a Small Change
Note di rilascio
Color Update

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.