OPEN-SOURCE SCRIPT
FP - SMA Crossover + Regime + Hold Filter

This indicator is the visual implementation of Strategy 270, one of the top-performing systems from my quantitative backtesting pipeline (XAUUSD H1, walk-forward OOS validation).
What it does
It identifies high-probability long entries using a three-layer confirmation system, and manages exits with a dual grace period that prevents premature closes during pullbacks within a healthy trend.
Entry conditions (all must be true):
SMA Fast (15) crosses above SMA Slow (200) — trend shift confirmed
Price is above the Regime SMA (200) — macro structure is bullish
Price is at least 0.61% above EMA200 — minimum distance from the mean, filters low-conviction setups near the line
Exit logic — two layers:
Layer 1: SMA15 crosses below SMA200, OR price has been below the Regime SMA for N consecutive bars (grace_bars = 8)
Layer 2: If the exit trigger is caused by being below the regime (not a clean crossunder), the system waits for a second confirmation window (grace_bars_2 = 12) before closing. This eliminates false exits on brief pullbacks.
Minimum hold filter:
No exit is allowed during the first 96 bars after entry (4 days on H1). This comes directly from trade analysis: in backtesting, trades closed before 96 bars had a win rate near 0% and destroyed net P&L. Trades held between 8 and 20 days showed 73% win rate. The yellow dot marks the moment the hold lock is released — from that bar onward, exits are active.
Visual elements:
🟢 Green triangle below bar — long entry signal
🔴 Red triangle above bar — exit signal
🟡 Yellow dot — hold period unlocked (exits now active)
Green background — position is open
Lines: SMA15 (orange), SMA200 (blue), EMA200 (purple dashed), Regime SMA (gray)
Three built-in alerts: entry, exit, and hold unlock.
Recommended timeframe: H1. All parameters are adjustable from the inputs panel — the defaults match the optimized backtest configuration.
This indicator does not repaint. Entry and exit signals are generated on bar close.
What it does
It identifies high-probability long entries using a three-layer confirmation system, and manages exits with a dual grace period that prevents premature closes during pullbacks within a healthy trend.
Entry conditions (all must be true):
SMA Fast (15) crosses above SMA Slow (200) — trend shift confirmed
Price is above the Regime SMA (200) — macro structure is bullish
Price is at least 0.61% above EMA200 — minimum distance from the mean, filters low-conviction setups near the line
Exit logic — two layers:
Layer 1: SMA15 crosses below SMA200, OR price has been below the Regime SMA for N consecutive bars (grace_bars = 8)
Layer 2: If the exit trigger is caused by being below the regime (not a clean crossunder), the system waits for a second confirmation window (grace_bars_2 = 12) before closing. This eliminates false exits on brief pullbacks.
Minimum hold filter:
No exit is allowed during the first 96 bars after entry (4 days on H1). This comes directly from trade analysis: in backtesting, trades closed before 96 bars had a win rate near 0% and destroyed net P&L. Trades held between 8 and 20 days showed 73% win rate. The yellow dot marks the moment the hold lock is released — from that bar onward, exits are active.
Visual elements:
🟢 Green triangle below bar — long entry signal
🔴 Red triangle above bar — exit signal
🟡 Yellow dot — hold period unlocked (exits now active)
Green background — position is open
Lines: SMA15 (orange), SMA200 (blue), EMA200 (purple dashed), Regime SMA (gray)
Three built-in alerts: entry, exit, and hold unlock.
Recommended timeframe: H1. All parameters are adjustable from the inputs panel — the defaults match the optimized backtest configuration.
This indicator does not repaint. Entry and exit signals are generated on bar close.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน