Pine Script v4 · Strategy
RSI Cross [xaurr]
A Pine Script v4 strategy built on RSI (close, 5), EMA (rsi, 20) and Crossover (fast, slow). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 6 settings; defaults include Source close, RSI Period 5 and RSI Oversold 30.
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 RSI Cross [xaurr] repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 14 of 14 trades.
- How did RSI Cross [xaurr] do on BTCUSDT 1D with default settings?
- +24.35%
- From 26 Jan 2024 to 21 Oct 2026, over 53 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can RSI Cross [xaurr] 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 RSI Cross [xaurr] use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does RSI Cross [xaurr] run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- RSI Oversold
- RSI Overbought
- RSI Line
- RSI Fast Line
- RSI Slow Line
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +24.35%
- $24,354.50
- Buy and hold
- +102.5%
- same period
- Closed trades
- 53
- 18 won · 35 lost
- Profitable
- 34.0%
- of closed trades
- Profit factor
- 1.18
- gross profit ÷ gross loss
- Max drawdown
- 35.33%
- −$40,170.80
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short position was still open at the last bar. 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
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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.
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 rsi → ta.rsi, ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
VerifiedSame 53 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.source) → input.source()
- Line 12: rsi → ta.rsi
- Line 13: ema → ta.ema
- Line 14: ema → ta.ema
- Line 15: crossover → ta.crossover
- Line 16: crossunder → ta.crossunder
⋯// © xaurr-//@version=4+//@version=5strategy("RSI Cross [xaurr]", shorttitle="RSIC",overlay=false)-src = input(title="Source", type=input.source, defval=close)+src = input.source(title="Source", defval=close)//RSI Strategy⋯slowPeriod = input(50,"Smooth Slow Period")-rsi = rsi(src, period)+rsi = ta.rsi(src, period)-fast = ema(rsi,fastPeriod)+fast = ta.ema(rsi,fastPeriod)-slow = ema(rsi,slowPeriod)+slow = ta.ema(rsi,slowPeriod)-long = crossover(fast,slow)+long = ta.crossover(fast,slow)-short = crossunder(fast,slow)+short = ta.crossunder(fast,slow)pos = 0⋯Same 53 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
⋯//RSI Strategy-period = input(5,"RSI Period", minval=1)+period = input.int(5,"RSI Period", minval=1)-overSold = input(30,"RSI Oversold", minval=1)+overSold = input.int(30,"RSI Oversold", minval=1)-overBought = input(70, "RSI Overbought", minval=1)+overBought = input.int(70, "RSI Overbought", minval=1)-fastPeriod = input(20,"Smooth Fast Period")+fastPeriod = input.int(20,"Smooth Fast Period")-slowPeriod = input(50,"Smooth Slow Period")+slowPeriod = input.int(50,"Smooth Slow Period")rsi = ta.rsi(src, period)⋯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: 53 before, 267 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.
⋯// © xaurr-//@version=5+//@version=6strategy("RSI Cross [xaurr]", shorttitle="RSIC",overlay=false)⋯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 |
|---|---|---|---|
| Source | close | source | rsi |
| RSI Period | 5 | int · min 1 | rsi |
| RSI Oversold | 30 | int · min 1 | RSI Oversold |
| RSI Overbought | 70 | int · min 1 | RSI Overbought |
| Smooth Fast Period | 20 | int | fast |
| Smooth Slow Period | 50 | int | slow |
What it calculates
- RSI (
rsi,ta.rsiin v5)Source (close), RSI Period (5)rsi · line 12 - EMA (
ema,ta.emain v5)rsi, Smooth Fast Period (20)fast · line 13 - EMA (
ema,ta.emain v5)rsi, Smooth Slow Period (50)slow · line 14 - Crossover (
crossover,ta.crossoverin v5)fast, slowlong · line 15 - Crossunder (
crossunder,ta.crossunderin v5)fast, slowshort · line 16
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 | pos == 1 | On | 26 |
| Open short short | pos == -1 | On | 28 |
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.
- 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 | +24.4% | +102.5% | 53 | 34% | 1.18 | 35.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +16.6% | +5.5% | 50 | 30% | 1.45 | 9.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +1.5% | +9.8% | 55 | 36% | 1.23 | 2.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.4% | +8.4% | 50 | 30% | 1.28 | 0.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 60 | 33% | 1.04 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 56 | 27% | 0.85 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.4% | +148.3% | 59 | 27% | 0.76 | 1.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.2% | +17.1% | 48 | 35% | 1.72 | 0.1% | 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 | 17 | 24% | −$16,517.70 |
| Sideways market | 24 | 46% | $35,270.40 |
| Falling market | 12 | 25% | $5,601.88 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
48.7%
The 95th percentile of the worst drawdown when the same 53 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 24.3% to 48.7%; the tick is what actually happened, 24.3%. Order luck alone moves it this much.
All 53 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 18 May 2024 67,024.00 | 3 Jun 2024 67,765.60 | 16 | $741.62 |
| short | 3 Jun 2024 67,765.60 | 4 Jun 2024 68,809.90 | 1 | −$1,044.27 |
| long | 4 Jun 2024 68,809.90 | 12 Jun 2024 67,314.20 | 8 | −$1,495.66 |
| short | 12 Jun 2024 67,314.20 | 15 Jul 2024 60,797.90 | 33 | $6,516.32 |
| long | 15 Jul 2024 60,797.90 | 4 Aug 2024 60,698.00 | 20 | −$99.92 |
| short | 4 Aug 2024 60,698.00 | 22 Aug 2024 61,156.00 | 18 | −$458.04 |
| long | 22 Aug 2024 61,156.00 | 1 Sep 2024 58,974.00 | 10 | −$2,182.03 |
| short | 1 Sep 2024 58,974.00 | 14 Sep 2024 60,498.00 | 13 | −$1,523.99 |
| long | 14 Sep 2024 60,498.00 | 5 Oct 2024 62,086.00 | 21 | $1,588.01 |
| short | 5 Oct 2024 62,086.00 | 15 Oct 2024 66,084.00 | 10 | −$3,998.00 |
| long | 15 Oct 2024 66,084.00 | 5 Nov 2024 67,850.00 | 21 | $1,766.01 |
| short | 5 Nov 2024 67,850.00 | 7 Nov 2024 75,572.00 | 2 | −$7,721.98 |
| long | 7 Nov 2024 75,572.00 | 2 Dec 2024 97,185.20 | 25 | $21,613.20 |
| short | 2 Dec 2024 97,185.20 | 18 Dec 2024 106,134.00 | 16 | −$8,948.57 |
| long | 18 Dec 2024 106,134.00 | 19 Dec 2024 100,204.00 | 1 | −$5,929.73 |
| short | 19 Dec 2024 100,204.00 | 18 Jan 2025 104,077.00 | 30 | −$3,873.46 |
| long | 18 Jan 2025 104,077.00 | 29 Jan 2025 101,336.00 | 11 | −$2,741.95 |
| short | 29 Jan 2025 101,336.00 | 31 Jan 2025 104,723.00 | 2 | −$3,387.42 |
| long | 31 Jan 2025 104,723.00 | 1 Feb 2025 102,430.00 | 1 | −$2,293.38 |
| short | 1 Feb 2025 102,430.00 | 20 Mar 2025 86,845.90 | 47 | $15,583.60 |
| long | 20 Mar 2025 86,845.90 | 7 Apr 2025 78,430.00 | 18 | −$8,415.93 |
| short | 7 Apr 2025 78,430.00 | 13 Apr 2025 85,276.90 | 6 | −$6,846.91 |
| long | 13 Apr 2025 85,276.90 | 30 May 2025 105,590.00 | 47 | $20,312.80 |
| short | 30 May 2025 105,590.00 | 30 Jun 2025 108,357.00 | 31 | −$2,767.18 |
| long | 30 Jun 2025 108,357.00 | 2 Jul 2025 105,681.00 | 2 | −$2,675.80 |
| short | 2 Jul 2025 105,681.00 | 3 Jul 2025 108,850.00 | 1 | −$3,168.46 |
| long | 3 Jul 2025 108,850.00 | 29 Jul 2025 118,062.00 | 26 | $9,212.73 |
| short | 29 Jul 2025 118,062.00 | 14 Aug 2025 123,306.00 | 16 | −$5,244.12 |
| long | 14 Aug 2025 123,306.00 | 16 Aug 2025 117,342.00 | 2 | −$5,964.40 |
| short | 16 Aug 2025 117,342.00 | 11 Sep 2025 113,960.00 | 26 | $3,382.04 |
| long | 11 Sep 2025 113,960.00 | 25 Sep 2025 113,307.00 | 14 | −$652.99 |
| short | 25 Sep 2025 113,307.00 | 3 Oct 2025 120,529.00 | 8 | −$7,222.34 |
| long | 3 Oct 2025 120,529.00 | 14 Oct 2025 115,166.00 | 11 | −$5,363.35 |
| short | 14 Oct 2025 115,166.00 | 29 Oct 2025 112,898.00 | 15 | $2,267.56 |
| long | 29 Oct 2025 112,898.00 | 30 Oct 2025 110,021.00 | 1 | −$2,877.14 |
| short | 30 Oct 2025 110,021.00 | 3 Dec 2025 91,277.90 | 34 | $18,743.40 |
| long | 3 Dec 2025 91,277.90 | 18 Dec 2025 86,243.20 | 15 | −$5,034.65 |
| short | 18 Dec 2025 86,243.20 | 21 Dec 2025 88,360.90 | 3 | −$2,117.68 |
| long | 21 Dec 2025 88,360.90 | 23 Jan 2026 89,559.70 | 33 | $1,198.77 |
| short | 23 Jan 2026 89,559.70 | 1 Mar 2026 66,973.30 | 37 | $22,586.40 |
| long | 1 Mar 2026 66,973.30 | 29 Mar 2026 66,377.00 | 28 | −$596.22 |
| short | 29 Mar 2026 66,377.00 | 7 Apr 2026 68,853.70 | 9 | −$2,476.62 |
| long | 7 Apr 2026 68,853.70 | 17 May 2026 78,148.10 | 40 | $9,294.39 |
| short | 17 May 2026 78,148.10 | 23 Jun 2026 64,020.00 | 37 | $14,128.00 |
| long | 23 Jun 2026 64,020.00 | 24 Jun 2026 62,734.60 | 1 | −$1,285.44 |
| short | 24 Jun 2026 62,734.60 | 4 Jul 2026 62,583.30 | 10 | $151.31 |
| long | 4 Jul 2026 62,583.30 | 2 Aug 2026 62,823.70 | 29 | $240.39 |
| short | 2 Aug 2026 62,823.70 | 6 Aug 2026 64,665.20 | 4 | −$1,841.59 |
| long | 6 Aug 2026 64,665.20 | 13 Aug 2026 63,480.00 | 7 | −$1,185.25 |
| short | 13 Aug 2026 63,480.00 | 20 Aug 2026 69,334.80 | 7 | −$5,854.79 |
| long | 20 Aug 2026 69,334.80 | 11 Sep 2026 76,568.70 | 22 | $7,233.95 |
| short | 11 Sep 2026 76,568.70 | 22 Sep 2026 86,620.00 | 11 | −$10,051.30 |
| long | 22 Sep 2026 86,620.00 | 9 Oct 2026 81,754.50 | 17 | −$4,865.55 |
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 |
|---|---|---|---|---|---|
| RSI Cross [xaurr] this page | — | 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 | ||
| BTC Sentiment analysis RSI 2xEMA by exlux99 | rsi ema | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | With a workaround 1,000 bars in 38 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not 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. 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/// © xaurr//@version=4strategy("RSI Cross [xaurr]", shorttitle="RSIC",overlay=false)src = input(title="Source", type=input.source, defval=close)//RSI Strategyperiod = input(5,"RSI Period", minval=1)overSold = input(30,"RSI Oversold", minval=1)overBought = input(70, "RSI Overbought", minval=1)fastPeriod = input(20,"Smooth Fast Period")slowPeriod = input(50,"Smooth Slow Period")rsi = rsi(src, period)fast = ema(rsi,fastPeriod)slow = ema(rsi,slowPeriod)long = crossover(fast,slow)short = crossunder(fast,slow)pos = 0pos:= long ?1:short ?-1 : nz(pos[1])plot(overSold,"RSI Oversold",color=color.green)plot(overBought, "RSI Overbought",color=color.red)plot(rsi, linewidth = 1, color = color.blue, title="RSI Line")plot(fast, linewidth = 2, color = color.green, title="RSI Fast Line")plot(slow, linewidth = 2, color = color.red, title="RSI Slow Line")bgcolor(pos == 1 ? color.green : pos == -1 ? color.red : na)if pos == 1 strategy.entry("long",strategy.long)if pos == -1 strategy.entry("short",strategy.short)