OPEN-SOURCE SCRIPT
AS PRO Trendline Engine (SMC Style)

🧠 1. Trend Detection (SMA 9 + Candle Coloring)
The script calculates a 9-period Simple Moving Average (SMA 9).
Candles are colored based on price position:
Green → price above SMA (bullish trend)
Red → price below SMA (bearish trend)
👉 This acts as a basic trend filter.
⚡ 2. SMA 9 Cross Alerts
Generates signals when price:
Crosses above SMA 9 → potential bullish signal
Crosses below SMA 9 → potential bearish signal
👉 These are fast signals, but can be noisy without confirmation.
🧱 3. Market Structure (Pivots + Trendlines)
Detects:
Swing highs (pivot highs)
Swing lows (pivot lows)
Connects them to form:
Downtrend lines (high → high)
Uptrend lines (low → low)
Optionally draws parallel channels
👉 This represents market structure / price action geometry.
💥 4. Breakout Detection
Checks whether price breaks:
Above a trendline → bullish breakout
Below a trendline → bearish breakout
👉 Used for trend continuation or reversal signals.
📊 5. RSI Momentum Logic
Uses RSI (14) to detect:
Overbought → potential bearish reversal
Oversold → potential bullish reversal
👉 Mainly used for exit signals or momentum filtering.
🧬 6. EMA + SMA 200 (Higher-Timeframe Bias)
Includes:
EMA (short-term trend)
SMA 200 (long-term trend)
Generates signals when they cross.
👉 This acts as a macro trend filter.
🟩 7. Fair Value Gaps (FVG – SMC Core)
Detects inefficiencies between candles:
Bullish FVG → potential support zone
Bearish FVG → potential resistance zone
Tracks:
Creation of FVGs
Mitigation (when price fills the gap)
👉 This is the Smart Money / liquidity component of the script.
🚨 8. Alert System
The script includes alerts for:
SMA crosses
Trendline breakouts
RSI signals
EMA/SMA cross signals
FVG creation and mitigation
👉 However, each alert works independently, without a unified decision system.
🧩 What the Script Does Overall
It combines four key layers of analysis:
1. Trend
SMA 9
SMA 200
2. Momentum
RSI
3. Structure
Pivot-based trendlines
4. Liquidity
Fair Value Gaps (FVG)
⚠️ Key Limitation
The script produces many individual signals, but:
It does not prioritize them
It does not combine them
It does not generate a single high-quality trade decision
👉 In other words:
It’s a signal generator, not a decision engine.
The script calculates a 9-period Simple Moving Average (SMA 9).
Candles are colored based on price position:
Green → price above SMA (bullish trend)
Red → price below SMA (bearish trend)
👉 This acts as a basic trend filter.
⚡ 2. SMA 9 Cross Alerts
Generates signals when price:
Crosses above SMA 9 → potential bullish signal
Crosses below SMA 9 → potential bearish signal
👉 These are fast signals, but can be noisy without confirmation.
🧱 3. Market Structure (Pivots + Trendlines)
Detects:
Swing highs (pivot highs)
Swing lows (pivot lows)
Connects them to form:
Downtrend lines (high → high)
Uptrend lines (low → low)
Optionally draws parallel channels
👉 This represents market structure / price action geometry.
💥 4. Breakout Detection
Checks whether price breaks:
Above a trendline → bullish breakout
Below a trendline → bearish breakout
👉 Used for trend continuation or reversal signals.
📊 5. RSI Momentum Logic
Uses RSI (14) to detect:
Overbought → potential bearish reversal
Oversold → potential bullish reversal
👉 Mainly used for exit signals or momentum filtering.
🧬 6. EMA + SMA 200 (Higher-Timeframe Bias)
Includes:
EMA (short-term trend)
SMA 200 (long-term trend)
Generates signals when they cross.
👉 This acts as a macro trend filter.
🟩 7. Fair Value Gaps (FVG – SMC Core)
Detects inefficiencies between candles:
Bullish FVG → potential support zone
Bearish FVG → potential resistance zone
Tracks:
Creation of FVGs
Mitigation (when price fills the gap)
👉 This is the Smart Money / liquidity component of the script.
🚨 8. Alert System
The script includes alerts for:
SMA crosses
Trendline breakouts
RSI signals
EMA/SMA cross signals
FVG creation and mitigation
👉 However, each alert works independently, without a unified decision system.
🧩 What the Script Does Overall
It combines four key layers of analysis:
1. Trend
SMA 9
SMA 200
2. Momentum
RSI
3. Structure
Pivot-based trendlines
4. Liquidity
Fair Value Gaps (FVG)
⚠️ Key Limitation
The script produces many individual signals, but:
It does not prioritize them
It does not combine them
It does not generate a single high-quality trade decision
👉 In other words:
It’s a signal generator, not a decision engine.
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.