Pine Script v4 · Strategy
EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy
A Pine Script v4 strategy built on EMA (close, 50), RSI (close, 25) and Crossover (emaVal, high). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 17 settings; defaults include EMA Length 50, EMA+RSI Source close and Long+Short Condition Source high.
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 EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy do on BTCUSDT 1D with default settings?
- −4.12%
- From 26 Jan 2024 to 21 Oct 2026, over 18 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 45.
- Does EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 47 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −4.12%
- −$4,119.92
- Buy and hold
- +102.5%
- same period
- Closed trades
- 18
- 6 won · 12 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 0.89
- gross profit ÷ gross loss
- Max drawdown
- 13.53%
- −$13,533.00
One run with the author's default settings, $100,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
1 setting does nothing
“Show Date Range” is declared but never read.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 43, 44. The upgraded version below moves each call inside an if block.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames ema → ta.ema, rsi → ta.rsi, crossover → ta.crossover, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 43, 44). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 18 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 5: input(type = input.integer) → input.int()
- Line 8: ema → ta.ema
- Line 9: input(type = input.integer) → input.int()
- Line 10: rsi → ta.rsi
- Line 12: input(type = input.integer) → input.int()
5 more edits
- Line 14: ema → ta.ema
- Line 24: input(type = input.bool) → input.bool()
- Line 29: crossover → ta.crossover
- Line 30: crossunder → ta.crossunder
- Line 43: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © mmoiwgg-//@version=4+//@version=5strategy(title="EMA+RSI Pump & Drop Swing Sniper (With Alerts & SL+TP) - Strategy", shorttitle="EMA+RSI Swing Strategy", overlay=true)-emaLength = input(title="EMA Length", type=input.integer, defval=50, minval=0)+emaLength = input.int(title="EMA Length", defval=50, minval=0)emarsiSource = input(close, title="EMA+RSI Source")condSource = input(high, title="Long+Short Condition Source")-emaVal = ema(emarsiSource, emaLength)+emaVal = ta.ema(emarsiSource, emaLength)-rsiLength = input(title="RSI Length", type=input.integer, defval=25, minval=0)+rsiLength = input.int(title="RSI Length", defval=25, minval=0)-rsiVal = rsi(emarsiSource, rsiLength)+rsiVal = ta.rsi(emarsiSource, rsiLength)//Safety -emaLength2 = input(title="Safety EMA Length", type=input.integer, defval=70, minval=0)+emaLength2 = input.int(title="Safety EMA Length", defval=70, minval=0)emaSource2 = input(close, title="Safety EMA Source")-ema = ema(emaSource2, emaLength2)+ema = ta.ema(emaSource2, emaLength2)emaColorSource2 = close⋯ToYear = input(defval = 9999, title = "To Year", minval = 2017)-showDate = input(defval = true, title = "Show Date Range", type = input.bool)+showDate = input.bool(defval = true, title = "Show Date Range")start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window⋯// Conditions-exit_long = crossover(emaVal, condSource)+exit_long = ta.crossover(emaVal, condSource)-longCond = crossunder(emaVal, condSource) and close > ema+longCond = ta.crossunder(emaVal, condSource) and close > ema//Stoploss + TakeProfit⋯//Strategy Entry+Exits-strategy.entry("long",1,when=window() and longCond)+strategy.entry("long",strategy.long,when=window() and longCond)strategy.close("long",when=window() and exit_long)⋯Same 18 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.source()
- Line 7: input() → input.source()
- Line 13: input() → input.source()
- Line 18: input() → input.int()
- Line 19: input() → input.int()
- Line 20: input() → input.int()
9 more edits
- Line 21: input() → input.int()
- Line 22: input() → input.int()
- Line 23: input() → input.int()
- Line 32: input() → input.float()
- Line 33: input() → input.float()
- Line 36: input() → input.source()
- Line 37: input() → input.source()
- Line 43: when = window() and longCond → if block
- Line 44: when = window() and exit_long → if block
⋯emaLength = input.int(title="EMA Length", defval=50, minval=0)-emarsiSource = input(close, title="EMA+RSI Source")+emarsiSource = input.source(close, title="EMA+RSI Source")-condSource = input(high, title="Long+Short Condition Source")+condSource = input.source(high, title="Long+Short Condition Source")emaVal = ta.ema(emarsiSource, emaLength)⋯emaLength2 = input.int(title="Safety EMA Length", defval=70, minval=0)-emaSource2 = input(close, title="Safety EMA Source")+emaSource2 = input.source(close, title="Safety EMA Source")ema = ta.ema(emaSource2, emaLength2)⋯// Backtest+Dates-FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+FromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+FromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-FromYear = input(defval = 2019, title = "From Year", minval = 2017)+FromYear = input.int(defval = 2019, title = "From Year", minval = 2017)-ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)+ToMonth = input.int(defval = 1, title = "To Month", minval = 1, maxval = 12)-ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+ToDay = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-ToYear = input(defval = 9999, title = "To Year", minval = 2017)+ToYear = input.int(defval = 9999, title = "To Year", minval = 2017)showDate = input.bool(defval = true, title = "Show Date Range")⋯//Stoploss + TakeProfit-sl = input(0.051, step=0.001, title="Stop Loss")+sl = input.float(0.051, step=0.001, title="Stop Loss")-tp = input(0.096, step=0.001, title="Take Profit")+tp = input.float(0.096, step=0.001, title="Take Profit")// Plots Colorscolors = emarsiSource > emaVal and rsiVal > 14 ? color.green : color.red-emaColorSource = input(close, title="Line Color Source")+emaColorSource = input.source(close, title="Line Color Source")-emaBSource = input(close, title="Line Color B Source")+emaBSource = input.source(close, title="Line Color B Source")// Plots⋯//Strategy Entry+Exits-strategy.entry("long",strategy.long,when=window() and longCond)+if window() and longCond+ strategy.entry("long",strategy.long)-strategy.close("long",when=window() and exit_long)+if window() and exit_long+ strategy.close("long")strategy.exit("long tp/sl", "long", profit = close * tp / syminfo.mintick, loss = close * sl / syminfo.mintick)Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 18 before, 11 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © mmoiwgg-//@version=5+//@version=6strategy(title="EMA+RSI Pump & Drop Swing Sniper (With Alerts & SL+TP) - Strategy", shorttitle="EMA+RSI Swing Strategy", overlay=true)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| EMA Length | 50 | int (written input.integer) · min 0 | emaVal |
| EMA+RSI Source | close | source | emaVal rsiVal colors |
| Long+Short Condition Source | high | source | exit_long longCond |
| RSI Length | 25 | int (written input.integer) · min 0 | rsiVal |
| Safety EMA Length | 70 | int (written input.integer) · min 0 | ema |
| Safety EMA Source | close | source | ema |
| From Month | 1 | int · min 1 · max 12 | start |
| From Day | 1 | int · min 1 · max 31 | start |
| From Year | 2019 | int · min 2017 | start |
| To Month | 1 | int · min 1 · max 12 | finish |
| To Day | 1 | int · min 1 · max 31 | finish |
| To Year | 9999 | int · min 2017 | finish |
| Show Date Range | true | bool | unused |
| Stop Loss | 0.051 | float · step 0.001 | exit long tp/sl |
| Take Profit | 0.096 | float · step 0.001 | exit long tp/sl |
| Line Color Source | close | source | plot |
| Line Color B Source | close | source | plot |
What it calculates
- EMA (
ema,ta.emain v5)EMA+RSI Source (close), EMA Length (50)emaVal · line 8 - RSI (
rsi,ta.rsiin v5)EMA+RSI Source (close), RSI Length (25)rsiVal · line 10 - EMA (
ema,ta.emain v5)Safety EMA Source (close), Safety EMA Length (70)ema · line 14 - Crossover (
crossover,ta.crossoverin v5)emaVal, Long+Short Condition Source (high)exit_long · line 29
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | window() and longCond | On | 43 |
| Close long | window() and exit_long | On | 44 |
| Exit long tp/sl stop and limit | every bar | On | 45 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −4.1% | +102.5% | 18 | 33% | 0.89 | 13.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +2.2% | +5.5% | 12 | 33% | 1.27 | 5.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.3% | +9.8% | 16 | 25% | 0.78 | 0.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.1% | +8.4% | 14 | 14% | 0.80 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 14 | 36% | 1.31 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 11 | 27% | 2.28 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 8 | 50% | 2.28 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.3% | +17.1% | 18 | 44% | 8.19 | 0.0% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 25% | −$1,841.87 |
| Sideways market | 14 | 36% | −$2,278.05 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
27.2%
The 95th percentile of the worst drawdown when the same 18 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 12.9% to 27.2%; the tick is what actually happened, 12.2%. Order luck alone moves it this much.
All 18 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 29 Apr 2024 63,118.60 | 30 Apr 2024 59,861.40 | 1 | −$3,257.17 |
| long | 5 May 2024 63,892.00 | 9 May 2024 61,193.00 | 4 | −$2,699.00 |
| long | 10 May 2024 63,074.00 | 12 May 2024 60,826.00 | 2 | −$2,248.01 |
| long | 14 May 2024 62,940.10 | 20 May 2024 69,302.40 | 6 | $6,362.31 |
| long | 17 Jun 2024 66,676.90 | 19 Jun 2024 65,175.30 | 2 | −$1,501.54 |
| long | 16 Jul 2024 64,724.10 | 2 Aug 2024 61,391.00 | 17 | −$3,333.06 |
| long | 24 Aug 2024 64,037.20 | 27 Aug 2024 60,832.70 | 3 | −$3,204.54 |
| long | 14 Sep 2024 60,498.00 | 17 Sep 2024 58,214.00 | 3 | −$2,284.00 |
| long | 18 Sep 2024 60,314.00 | 11 Oct 2024 60,326.40 | 23 | $12.41 |
| long | 12 Oct 2024 62,540.00 | 20 Oct 2024 69,104.30 | 8 | $6,564.29 |
| long | 15 Feb 2025 97,500.50 | 16 Feb 2025 97,569.70 | 1 | $69.20 |
| long | 21 Feb 2025 98,305.00 | 23 Feb 2025 96,551.00 | 2 | −$1,754.00 |
| long | 22 Apr 2025 87,516.20 | 1 May 2025 96,556.70 | 9 | $9,040.52 |
| long | 23 Aug 2025 116,936.00 | 24 Aug 2025 111,049.00 | 1 | −$5,887.35 |
| long | 25 Sep 2025 113,307.00 | 26 Sep 2025 108,994.00 | 1 | −$4,312.52 |
| long | 30 Sep 2025 114,312.00 | 6 Oct 2025 126,166.00 | 6 | $11,854.30 |
| long | 13 Oct 2025 114,959.00 | 15 Oct 2025 113,028.00 | 2 | −$1,930.68 |
| long | 27 Oct 2025 114,559.00 | 30 Oct 2025 108,948.00 | 3 | −$5,611.09 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| EMA+RSI Pump & Drop Swing Sniper (SL+TP) - Strategy this page | — | v4 strategy | −4.1% | 18 | 13.5% |
| RSI Cross [xaurr] by livetrend | rsi ema | v4 strategy | +24.4% | 53 | 35.3% |
| Bitpanda Coinrule Template by joshuajcoop01 | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrule | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI of VWAP by mohanee | rsi ema | v4 strategy | No trades on this market | ||
| EMA SCALPEUR + RSi - SHORT by YukalMoon | rsi ema | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | With a workaround 1,000 bars in 47 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 43) so the engine trades the way the script says.
“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. PineTS runs Pine Script v5 and v6 only.
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/// © mmoiwgg//@version=4strategy(title="EMA+RSI Pump & Drop Swing Sniper (With Alerts & SL+TP) - Strategy", shorttitle="EMA+RSI Swing Strategy", overlay=true)emaLength = input(title="EMA Length", type=input.integer, defval=50, minval=0)emarsiSource = input(close, title="EMA+RSI Source")condSource = input(high, title="Long+Short Condition Source")emaVal = ema(emarsiSource, emaLength)rsiLength = input(title="RSI Length", type=input.integer, defval=25, minval=0)rsiVal = rsi(emarsiSource, rsiLength)//Safety emaLength2 = input(title="Safety EMA Length", type=input.integer, defval=70, minval=0)emaSource2 = input(close, title="Safety EMA Source")ema = ema(emaSource2, emaLength2)emaColorSource2 = closeemaBSource2 = close// Backtest+DatesFromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)FromYear = input(defval = 2019, title = "From Year", minval = 2017)ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)ToYear = input(defval = 9999, title = "To Year", minval = 2017)showDate = input(defval = true, title = "Show Date Range", type = input.bool)start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start windowfinish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest end windowwindow() => time >= start and time <= finish ? true : false // create function - add window() to entry/exit/close// Conditionsexit_long = crossover(emaVal, condSource)longCond = crossunder(emaVal, condSource) and close > ema//Stoploss + TakeProfitsl = input(0.051, step=0.001, title="Stop Loss")tp = input(0.096, step=0.001, title="Take Profit")// Plots Colorscolors = emarsiSource > emaVal and rsiVal > 14 ? color.green : color.redemaColorSource = input(close, title="Line Color Source")emaBSource = input(close, title="Line Color B Source")// Plotsplot(ema, color=emaColorSource2[1] > ema and emaBSource2 > ema ? color.green : color.red, linewidth=1)plot(emaVal, color=emaColorSource[1] > emaVal and emaBSource > emaVal ? color.green : color.red, linewidth=3)plotcandle(open, high, low, close, color=colors)//Strategy Entry+Exitsstrategy.entry("long",1,when=window() and longCond)strategy.close("long",when=window() and exit_long)strategy.exit("long tp/sl", "long", profit = close * tp / syminfo.mintick, loss = close * sl / syminfo.mintick)