ROC 14 + EMA 200 Filter — Pine Script v5 strategy
This script buys price acceleration only in a long-term uptrend: the 14-bar rate of change must cross 5% while the close is above the 200 EMA. It exits as soon as the rate of change turns negative or price drops back below the 200 EMA.
Full code (free to copy)
//@version=5
strategy("ROC 14 + EMA 200 Momentum", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)
rocLen = input.int(14, "ROC Length", minval=5, maxval=40)
trig = input.float(5.0, "ROC Trigger %", minval=1.0, maxval=15.0, step=1.0)
rocVal = ta.roc(close, rocLen)
ema200 = ta.ema(close, 200)
if close > ema200 and ta.crossover(rocVal, trig)
strategy.entry("Long", strategy.long)
if rocVal < 0 or close < ema200
strategy.close("Long")
plot(rocVal, "ROC %", color=color.aqua)Judge this code on BTCUSDT 1D →Free, in your browser, on the same candles as the table below.
Online judge verdict on BTCUSDT (measured 29 November 2026)
| Timeframe | Sealed period | Trades | Return | Buy & hold | Verdict |
|---|---|---|---|---|---|
| 1d | 2024-12-17 → 2026-10-16 | 8 | 12.89 % | -23.25 % | Not enough trades to judge yet |
| 4h | 2026-03-12 → 2026-10-17 | 8 | 4.76 % | 15.83 % | Not enough trades to judge yet |
| 1h | The judge does not open the sealed period: 9 trades on the training part, at least 10 are needed. No return is shown. | Not enough trades to judge yet | |||
Past data, 10 bps per fill, last 20% of the bars sealed. Windows: full history on 1d, last 3 years on 4h, last year on 1h. Research, not advice: no result is promised.
This reading has not been compared with a real TradingView run.
Measured on 29 November 2026 with the online judge’s Pine v5 engine (sa-pine-vm 0.2.0), on Binance BTCUSDT candles up to 16/10/2026 on 1D and up to 17/10/2026 on 4h and 1h. Differences with TradingView’s Strategy Tester remain possible. Binance data, CC BY-NC-SA 4.0.
Open this code in the free judge (1 click) →
Replay each verdict yourself, in your browser: 1d · 4h · 1h. The script is filled in; nothing runs until you click “Judge”.
How the script works
rocVal = ta.roc(close, rocLen) with rocLen = 14 gives the percentage change over 14 bars; trig is 5.0 by default. ema200 = ta.ema(close, 200).
The entry requires close > ema200 and ta.crossover(rocVal, trig). The exit happens if rocVal < 0 or close < ema200: either condition is enough.
Parameters in the code
| Parameter | Value | Role |
|---|---|---|
rocLen | 14 | Input "ROC Length" created with input.int, from 5 to 40. |
trig | 5.0 | Input "ROC Trigger %" created with input.float, from 1.0 to 15.0. |
initial_capital | 10000 | Starting capital declared in strategy(). |
default_qty_type | percent_of_equity, 100 | Each entry commits 100% of available equity. |
commission_value | 0.1 (%) | 0.10% commission per order declared in the script; the judge applies it (10 bps per fill). |
process_orders_on_close | not set | Orders fill at the open of the next bar, the Pine default. |
Known limits of this rule
- A fixed 5% trigger does not mean the same thing on 1H and 1D: on 1H it is rarely reached, hence very few trades.
- ROC turns negative at the slightest pullback, which can cut a trend early.
- The 200 EMA needs 200 bars of history before the first signal.
Before you trust it: test it on data it never saw
A backtest in TradingView's Strategy Tester shows one past path with the settings you picked. Strategy Arena Lab (free, Windows and Linux) replays this Pine on your PC, compares its trades one by one with TradingView's for supported Pine, counts the variants you try, then judges the rule on a period kept sealed during the search: survives, no evidence of an edge or inconclusive.
FAQ
What does the online judge say about this script?
On BTCUSDT, with 10 bps fees per fill, measured on 29 November 2026: 1D: "Not enough trades to judge yet" (8 trades, 12.89% on the sealed period); 4h: "Not enough trades to judge yet" (8 trades, 4.76% on the sealed period); 1h: "Not enough trades to judge yet" (sealed period not opened, 9 training trades). No timeframe reaches "Survives". These verdicts concern past data and say nothing certain about the future.
Why does the judge show no return on 1H?
On 1H, the rule makes only 9 trades on the training part. With fewer than 10 trades, the judge does not open the sealed period and shows no return.
Can I change the script's settings?
Yes, the settings are inputs you can edit in TradingView. Each setting you try is one more trial: a setting chosen after seeing the sealed period is no longer a test on unseen data. The judge and the Lab count trials for this reason.
Other free Pine Script v5 strategies
More TradingView paths
Educational code on past data. No investment advice; no result is promised.