Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

M0PB (Momentum Pullback)

A Pine Script v5 strategy built on RSI (close, 6), EMA (high, 5) and Highest (12). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a profit target and no stop loss. Each trade is one contract and pays 0.0004 commission. 1 setting; defaults include atr stop 2.75.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does M0PB (Momentum Pullback) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did M0PB (Momentum Pullback) do on BTCUSDT 1D with default settings?
+51.26%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does M0PB (Momentum Pullback) run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L29:C8: cannot use 'float' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download.
Does M0PB (Momentum Pullback) use a stop loss?
No
Its exits set a profit target but no stop.
Does M0PB (Momentum Pullback) run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 29 ms, in the browser.

BTCUSDT · 1D · default settings

  • l_entry
  • s_entry
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (1)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctl_entry$45,379$60,758Equity from $30,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
+51.26%
$15,377.40
Buy and hold
+102.5%
same period
Closed trades
3
3 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
17.46%
−$7,332.83

One run with the author's default settings, $30,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Note

    Uses an argument v6 removed

    when = on line 75, 77, 83, 88. The upgraded version below moves each call inside an if block.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
atr stop2.75float · min 0.1 · max 6.0stop_l stop_s

What it calculates

  • RSIclose, 6r · line 15
  • EMAhigh, 5es · line 33
  • EMAlow, 5el · line 35
  • Highest12ph · line 66
  • Lowest12pl · line 68
  • ATR10atr · line 71

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

closecloseprice datahighhighprice datalowlowprice datahigh · low · closehigh · low · closeprice dataatr_inpatr stopsetting · 2.75rRSI→ resEMA→ eselEMA→ elphHighest→ phplLowest→ platrATR→ atrtrade_ptrade_pvaluestop_l, stop_sstop_l · stop_s2 valuesentry:ELOpen ELstrategy.entryentry:ESOpen ESstrategy.entryexit:phexit phstrategy.exitclose_all:close_all strategy.close_allexit:plexit plstrategy.exitbgcolor:29bgcolorbgcolorbgcolor:30bgcolorbgcolorplot:54l_entryplotplot:61s_entryplot

Order rules

OrderFires whenBy defaultLine
Open EL longtrade_l == 1.0On75
Open ES shorttrade_s == -1.0On77
Exit ph limitstrategy.position_size == 2On81
Close low[1] > stop_l[1] and low <= stop_lOn83
Exit pl limitstrategy.position_size == -2On86
Close high[1] < stop_s[1] and high >= stop_sOn88

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

1/1trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+51.3%+102.5%3100%—17.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−14.1%+5.5%333%0.2717.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+7.8%+9.8%4100%—0.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.9%+8.4%540%0.291.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.3%+16.7%580%6.230.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%580%1.510.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%560%0.841.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.2%+17.1%250%0.290.4%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market2100%$12,002.40
Sideways market1100%$3,374.98
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

0.0%

The 95th percentile of the worst drawdown when the same 3 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.

0%1%
All 3 trades
SideEntryExitBarsP&L
long21 Feb 2024 52,258.8026 Feb 2024 52,985.005$1,451.50
long6 Mar 2024 63,724.008 Mar 2024 69,000.002$10,550.90
short12 Jun 2026 63,626.0024 Jun 2026 61,938.0012$3,374.98

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
M0PB (Momentum Pullback) this page—v5 strategy+51.3%317.5%
R19 STRATEGY by SenatorVonShaftatr ema highest lowest rsiv4 strategyNo trades on this market
Richard's Strategy by Deepak8369highest lowest atr emav4 strategy+34.6%7026.3%
STRATEGY R18-F-BTC by SenatorVonShaftema highest lowest rsiv4 strategy−8.6%1114.4%
Classic Long Term Trend Following System by Robrecht99ema highest lowest atrv5 strategy+2.9%51.1%
Dynamic Stop Loss Demo by Tindtilyhighest lowest rsi atrv5 strategydoes not run in Zeal Terminal

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 4 strategy calls use the when = argument (line 75, 77, 83, 88). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 75: when = trade_l == 1.0 → if block
  • Line 77: when = trade_s == -1.0 → if block
  • Line 83: when = low[1] > stop_l[1] and low <= stop_l → if block
  • Line 88: when = high[1] < stop_s[1] and high >= stop_s → if block
⋯//strat entry long-strategy.entry("EL", strategy.long, 2, when = trade_l == 1.0)+if trade_l == 1.0+    strategy.entry("EL", strategy.long, 2)//strat entry short-strategy.entry("ES", strategy.short, 2, when = trade_s == -1.0)   +if trade_s == -1.0+    strategy.entry("ES", strategy.short, 2)       ⋯    if strategy.position_size == 2-        strategy.close_all(when = low[1] > stop_l[1] and low <= stop_l)+        if low[1] > stop_l[1] and low <= stop_l+            strategy.close_all()// strat short exit⋯    if strategy.position_size == -2-        strategy.close_all(when = high[1] < stop_s[1] and high >= stop_s)+        if high[1] < stop_s[1] and high >= stop_s+            strategy.close_all()// code below to trail remaining 50% of position //⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L29:C8: cannot use 'float' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Marcns_-//@version=5+//@version=6strategy("M0PB", commission_value = 0.0004, slippage = 1, initial_capital=30000)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msWith a workaround 1,000 bars in 29 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Marcns_//@version=5strategy("M0PB", commission_value = 0.0004, slippage = 1, initial_capital=30000)// commision is equal to approx $3.8 per round trip which is accurate for ES1! futures and slippage per trade is conservatively 1 tick in and 1 tick out. // *momentum pull back* //// long / short strategy that identifies extreme readings on the rsi as a *momentum signal*//Strategy buys/ sells a pullback to the 5ema(low)/ 5ema(high) and exits at rolling 12 bar high/ low. The rolling high/ low feature means that //if price enters into a pronlonged consolidation the profit target will begin to reduce with each new bar. The best trades tend to work within 2-6 bars// hard stop is X atr's from postion average price. This can be adjusted in user inputs.// built for use on 5 min & 1min intervals on: FX, Indexes, Crypto// there is a lot of slack left in entries and exits but the overall strategy is fairly robust across timeframes and markets and has between 60%-70% winrate with larger winners.// signals that occur from economic news volatility are best avoided.  // define rsir = ta.rsi(close,6) // find rsi > 90b = 0.0if r >= 90    b := 1.0else    na// find rsi < 10s = 0.0if r <= 10    s := -1.0else    na// plot rsi extreme as painted background colorbgcolor(b ? color.rgb(255, 82, 82, 49): na)bgcolor(s? color.rgb(76, 175, 79, 51): na)// exponential moving averages for entries. note that source is high and low (normally close is def input) this creates entry bands//entry short price using high as a source ta.ema(high,5)es = ta.ema(high,5)//entry long price using low as a source ta.ema(low,5)el = ta.ema(low,5)// long pullback entry trigger: last period above ema and current low below target ema entry let = 0.0if low[1] > el[1] and low <= el    let := 1.0else    na//short entry trigger ""set = 0.0if high[1] < es[1] and high >= es    set := -1.0else    na// create signal "trade_l" if RSI > 90 and price pulls back to 5ema(low) within 6 barstrade_l = 0.0if ta.barssince(b == 1.0) < 6 and let == 1.0    trade_l := 1.0else    naplot(trade_l, "l_entry", color.green)//create short signal "trade_s" if rsi < 10 and prices pullback to 5em(high) wihthin 6 barstrade_s = 0.0if ta.barssince(s == -1.0) < 6 and set == -1.0    trade_s := -1.0else    naplot(trade_s, "s_entry", color.purple)// define price at time of trade_l signal and input value into trade_p to use for stop parems latertrade_p = strategy.position_avg_price//indentify previous 12 bar high as part of long exit strat// this creates a rolling 12 bar high target... a quick move back up will exit at previous swing high but if a consolidation occurs system will exit on a new 12 bar high which may be below prev local highph = ta.highest(12)// inverse of above for short exit strat - previous lowest low of 12 bars as exit (rolling)pl = ta.lowest(12)// 1.5 atr stop below entry price (trade_p defined earlier) as part of exit stratatr_inp = input.float(2.75, "atr stop", minval = 0.1, maxval = 6.0)atr = ta.atr(10)stop_l = trade_p - (atr* atr_inp)stop_s = trade_p + (atr* atr_inp)//strat entry longstrategy.entry("EL", strategy.long, 2, when = trade_l == 1.0)//strat entry shortstrategy.entry("ES", strategy.short, 2, when = trade_s == -1.0)       //strat long exitif strategy.position_size == 2    strategy.exit(id = "ph", from_entry = "EL", qty = 2, limit = ph)    if strategy.position_size == 2        strategy.close_all(when = low[1] > stop_l[1] and low <= stop_l)// strat short exitif strategy.position_size == -2    strategy.exit(id = "pl", from_entry = "ES", qty = 2, limit =pl)    if strategy.position_size == -2        strategy.close_all(when = high[1] < stop_s[1] and high >= stop_s)// code below to trail remaining 50% of position // //if strategy.position_size == 1         //strategy.exit(id ="trail", from_entry = "EL", qty = 1, stop = el)