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.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.