PROTECTED SOURCE SCRIPT
Hassi XAUUSD Advanced FVG EMA/BOS/RSI/Volume + Session Filter

What it does:
This strategy automates a popular ICT-style idea on XAUUSD (Gold): trade only when price taps back into a Fair Value Gap (FVG), but filter entries with trend, structure, momentum, volume, and session rules. It manages risk with fixed TP/SL (points) and shows a compact backtest panel on chart.
Core Logic
1) Market Structure (BOS)
Detects recent swing highs/lows and flags a Break of Structure:
BOS Up when price breaks the latest swing high.
BOS Down when price breaks the latest swing low.
2) FVG Detection (3-candle)
Bullish FVG when low[0] > high[2] and low[1] > high[2].
Bearish FVG when high[0] < low[2] and high[1] < low[2].
The most recent qualifying gap is drawn as a shaded box (optional).
3) Bias & Filters
Trend Bias: price vs EMA (default 200). Longs only above EMA; shorts only below.
Momentum: optional RSI filter (default 14); avoid longs in OB & shorts in OS.
Volume: optional filter requiring current volume > SMA(20) × multiplier.
Sessions: optional London / New York (PKT) time windows.
Entries & Exits
Long Entry (all must be true)
Above EMA, RSI bullish, volume ok, session ok, BOS Up.
A recent Bullish FVG exists (within N bars).
Price taps back into the FVG (low ≤ top & close > bottom) with a bullish candle.
Short Entry (mirror)
Below EMA, RSI bearish, volume ok, session ok, BOS Down.
A recent Bearish FVG exists (within N bars).
Price taps (high ≥ bottom & close < top) with a bearish candle.
Risk / R:R
Exits use fixed points on XAUUSD (default TP 100, SL 50).
On many gold feeds 1.0 = 10 points; inputs convert to price automatically.
“One-trade-at-a-time”: a new signal won’t fire until the previous position is flat.
Chart Labels
On entry, the script plots BUY/SELL plus fixed TP/SL lines & labels anchored to the entry bar (they don’t drift with price).
Visuals & Tools
EMA line (green/red by bias).
Swing points (tiny triangles) to see structure.
FVG boxes (green/red, optional).
Session shading (subtle blue overlay).
Stats Panel (top-right):
Total Trades, TP Hits, SL Hits, Win Rate, Profit Factor, Net P&L.
Inputs (quick guide)
EMA Length (default 200)
Swing Lookback for BOS (default 5)
FVG Box Length (how far the zone extends to the right)
TP / SL (points) for XAUUSD + display Risk:Reward
Sessions (PKT): London & New York windows + toggle
Filters: Volume (multiplier), RSI (length, OB/OS)
Visibility: show/hide FVG boxes & TP/SL drawings
Alerts
Buy Signal / Sell Signal on valid entries
Position Opened / Position Closed notifications
Best Practices & Notes
Designed for XAUUSD 15-minute. You can test other timeframes, but retune TP/SL points and filters accordingly.
Broker ticks differ: if your symbol steps are not 0.1, adjust TP/SL points.
Use with a HTF confluence (e.g., D1/4H bias, key S/R, news awareness).
Backtests are approximations; real results vary with spreads, slippage, and execution.
Disclaimer: This tool is for educational purposes. It is not financial advice. Always test before using on live capital.
This strategy automates a popular ICT-style idea on XAUUSD (Gold): trade only when price taps back into a Fair Value Gap (FVG), but filter entries with trend, structure, momentum, volume, and session rules. It manages risk with fixed TP/SL (points) and shows a compact backtest panel on chart.
Core Logic
1) Market Structure (BOS)
Detects recent swing highs/lows and flags a Break of Structure:
BOS Up when price breaks the latest swing high.
BOS Down when price breaks the latest swing low.
2) FVG Detection (3-candle)
Bullish FVG when low[0] > high[2] and low[1] > high[2].
Bearish FVG when high[0] < low[2] and high[1] < low[2].
The most recent qualifying gap is drawn as a shaded box (optional).
3) Bias & Filters
Trend Bias: price vs EMA (default 200). Longs only above EMA; shorts only below.
Momentum: optional RSI filter (default 14); avoid longs in OB & shorts in OS.
Volume: optional filter requiring current volume > SMA(20) × multiplier.
Sessions: optional London / New York (PKT) time windows.
Entries & Exits
Long Entry (all must be true)
Above EMA, RSI bullish, volume ok, session ok, BOS Up.
A recent Bullish FVG exists (within N bars).
Price taps back into the FVG (low ≤ top & close > bottom) with a bullish candle.
Short Entry (mirror)
Below EMA, RSI bearish, volume ok, session ok, BOS Down.
A recent Bearish FVG exists (within N bars).
Price taps (high ≥ bottom & close < top) with a bearish candle.
Risk / R:R
Exits use fixed points on XAUUSD (default TP 100, SL 50).
On many gold feeds 1.0 = 10 points; inputs convert to price automatically.
“One-trade-at-a-time”: a new signal won’t fire until the previous position is flat.
Chart Labels
On entry, the script plots BUY/SELL plus fixed TP/SL lines & labels anchored to the entry bar (they don’t drift with price).
Visuals & Tools
EMA line (green/red by bias).
Swing points (tiny triangles) to see structure.
FVG boxes (green/red, optional).
Session shading (subtle blue overlay).
Stats Panel (top-right):
Total Trades, TP Hits, SL Hits, Win Rate, Profit Factor, Net P&L.
Inputs (quick guide)
EMA Length (default 200)
Swing Lookback for BOS (default 5)
FVG Box Length (how far the zone extends to the right)
TP / SL (points) for XAUUSD + display Risk:Reward
Sessions (PKT): London & New York windows + toggle
Filters: Volume (multiplier), RSI (length, OB/OS)
Visibility: show/hide FVG boxes & TP/SL drawings
Alerts
Buy Signal / Sell Signal on valid entries
Position Opened / Position Closed notifications
Best Practices & Notes
Designed for XAUUSD 15-minute. You can test other timeframes, but retune TP/SL points and filters accordingly.
Broker ticks differ: if your symbol steps are not 0.1, adjust TP/SL points.
Use with a HTF confluence (e.g., D1/4H bias, key S/R, news awareness).
Backtests are approximations; real results vary with spreads, slippage, and execution.
Disclaimer: This tool is for educational purposes. It is not financial advice. Always test before using on live capital.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể tự do sử dụng tập lệnh mà không có bất kỳ hạn chế nào – tìm hiểu thêm tại đây.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.