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.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน