Pine Script Strategy
EMA Crossover Pine Script for Prop Firm Evaluations
The 9/21 EMA crossover is the most widely used trend-entry signal in futures day trading. This Pine Script adds a VWAP direction filter, bar-close confirmation, and prop-firm-compliant risk management to make it evaluation-ready out of the box.
What EMA crossover is — and why it works for prop firm trading
An exponential moving average crossover uses two EMAs of different lengths to flag a shift in short-term momentum. The fast EMA (9-period) reacts quickly to price; the slow EMA (21-period) tracks the broader trend with less noise. When the fast average closes above the slow one, the shift points up — a potential long. When it closes below, the shift points down — a potential short.
The crossover has stayed relevant for decades because it captures something fundamental: the transition from one short-term price regime to another. When the average of the last nine closes overtakes the average of the last twenty-one, near-term direction has genuinely shifted.
For prop firm trading specifically, the crossover carries a structural advantage: it's completely objective. Either the cross happened on bar close or it didn't — no interpretation required. That makes the condition trivial to define in one line of Pine Script, backtest across years of data, and run through TradingView alerts without a judgment call live.
Why EMA crossover is one of the most popular prop firm setups
Walk into any futures trading community and some version of an EMA crossover strategy is already running in the background. That popularity holds up because the logic is simple enough to fully understand, backtestable enough to verify, and pairs naturally with a clean stop.
That stop placement matters. When the fast EMA crosses above the slow one and the script goes long, the natural stop sits a couple of points below the crossover candle's swing low — defined before entry, sized to the account tier, and respected automatically. There's no "let's see where it goes" discretion quietly eating into a daily loss limit.
Faster variants — 3/8 or 5/13, for example — fire too often for an evaluation account: eight or more signals a day means eight or more chances to breach a daily limit on a rough session. The 9/21 pair produces a handful of signals per session on a 5-minute chart, which is closer to the frequency an evaluation account can comfortably absorb.
The 9/21 crossover vs other EMA periods
8/21: marginally faster than 9/21 — usually a one-bar difference on a 5-minute chart — but it produces slightly more crossovers, and with them slightly more exposure. For an evaluation where keeping the daily trade count low matters, 9/21 is the better default.
9/21: the balance point for 5-minute ES and NQ trading — fast enough to catch a momentum shift early, slow enough to filter out most one-bar whipsaws during low-volume consolidation.
20/50: a different tool entirely — a swing or positional signal meant for hourly or daily charts. On a 5-minute chart it lags so far behind price that by the time it fires, the bulk of the move has often already happened. It isn't a good fit for an intraday evaluation with a short completion window.
How the Pine Script implements the 9/21 crossover
The script calculates both EMAs on every bar close and fires entries exclusively on that close — never on an intrabar level. That removes repainting: the crossover visible in the backtest is the same crossover the live alert fires on, at the same bar.
The VWAP direction filter is the single most valuable addition over a raw crossover. Without it, the 9/21 generates a meaningful share of false signals during the choppy midday stretch when price oscillates around VWAP with no real bias. With it active, longs only qualify when price trades above session VWAP at the moment of the cross, and shorts only qualify below it — cutting a large share of counter-trend false starts.
Stop placement is swing-based: the script looks back a configurable number of bars (5 by default) and places the stop below the lowest low (longs) or above the highest high (shorts) in that window, with a maximum-dollar override so an unusually wide bar can't blow past the per-trade risk cap.
//@version=5
strategy("9/21 EMA Crossover — Illustration", overlay=true)
fastLen = input.int(9, "Fast EMA")
slowLen = input.int(21, "Slow EMA")
lookback = input.int(5, "Swing Stop Lookback")
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
sessVWAP = ta.vwap(hlc3)
longCross = ta.crossover(fastEMA, slowEMA)
shortCross = ta.crossunder(fastEMA, slowEMA)
longOK = longCross and close > sessVWAP
shortOK = shortCross and close < sessVWAP
if longOK
stopLevel = ta.lowest(low, lookback)
strategy.entry("EMA Long", strategy.long)
strategy.exit("Long Stop", "EMA Long", stop=stopLevel)
if shortOK
stopLevel = ta.highest(high, lookback)
strategy.entry("EMA Short", strategy.short)
strategy.exit("Short Stop", "EMA Short", stop=stopLevel) Adding MACD or RSI as a secondary filter
The Pro and Custom plans include optional secondary filters for traders who want additional confirmation beyond the base 9/21 plus VWAP setup, which already performs well on its own.
MACD filter: requires a positive (or rising) MACD histogram for longs and a negative one for shorts, confirming that momentum agrees with the crossover direction rather than fading into it. RSI filter: requires RSI above 45 for longs (not overbought, but leaning upward) and below 55 for shorts, screening out entries after a run that's more likely to consolidate than continue. Both are optional add-ons pre-built into the Custom plan's multi-filter configuration.
Best session times for EMA crossover signals
The New York morning window — roughly 9:30 to 11:30 AM ET — tends to produce the cleanest crossovers. Volume and institutional order flow are both at their strongest, which makes the VWAP filter particularly effective in this stretch.
The 1:30–3:30 PM window can still produce solid signals on trend days but tends toward more false starts on range-bound ones. The session filter is configurable to the morning window only or extended through the afternoon depending on your evaluation timeline.
Best firms and account sizes for EMA crossover
| Firm | Account Size | Why It Fits | Recommended Contract |
|---|---|---|---|
| Apex Trader Funding | 50k | No daily loss limit on the evaluation, so a handful of crossover signals a day — even back-to-back stops — won't trigger a daily breach; the intraday trailing threshold protects capital on winning runs. | MES (1–2 contracts) |
| Topstep | 50k | $1,000 daily limit. Fixed swing-based stops on MES leave room to absorb several consecutive losses, and the eod trailing drawdown doesn't punish an intraday swing before the close. | MES (1 contract) |
| MyFundedFutures | 50k | Static drawdown never moves — a series of crossover winners doesn't raise the floor — and the signal frequency easily satisfies the minimum trading-day requirement. | MES or MNQ |
| Tradeify (Growth path) | 50k | No hard daily limit on the Growth eval; eod trailing drawdown means a few crossover signals a day fit comfortably within the systematic-trading spirit of that path. | MES (1–2 contracts) |
Performance characteristics
Backtest figures for this configuration will replace the placeholders above once a verified TradingView Strategy Tester run is complete.
Backtested results, once published, are based on historical market data only and are not a guarantee of future performance. Evaluation outcomes depend on execution quality, spread, and your specific firm's rules at the time you trade.