Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Crypto RSI with RVI Strategy

A Pine Script v4 strategy built on Stdev (xPrice, 100). It has 4 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 commits 100% of equity and pays 0.03% commission. 8 settings; defaults include Period 100, Buy Zone 49 and Sell Zone 50.

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 Crypto RSI with RVI 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 Crypto RSI with RVI Strategy do on BTCUSDT 1D with default settings?
+3.99%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Crypto RSI with RVI 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 Crypto RSI with RVI Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 75, 76.
Does Crypto RSI with RVI Strategy run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 48 ms, in the browser.

BTCUSDT · 1D · default settings

  • Stdev
  • 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 (8)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,267$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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 53) so the engine trades the way the script says.
Net profit
+3.99%
$39.91
Buy and hold
+102.5%
same period
Closed trades
2
1 won · 1 lost
Profitable
50.0%
of closed trades
Profit factor
1.29
gross profit ÷ gross loss
Max drawdown
32.08%
−$320.76

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long 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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    7 settings have no label

    In the settings dialog Period (line 5), BuyZone (line 6), SellZone (line 7), risk (line 50), leverage (line 51), sl (line 73), tp (line 74) show an empty name. The labels on this page come from the variable names.

  • 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 53, 54. The upgraded version below moves each call inside an if block.

  • Note

    Uses iff(), which v5 removed line 22

    iff() on line 22, 23, 37, 38, 42, 43, 44, 45. v5 writes it as the ternary c ? a : b.

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 abs → math.abs, stdev → ta.stdev, crossover → ta.crossover, crossunder → ta.crossunder, round → math.round, pow → math.pow.
  • 2 strategy calls use the when = argument (line 53, 54). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 1: //@version=4 → //@version=5
  • Line 22: iff(c, a, b) → (c ? a : b)
  • Line 22: abs → math.abs
  • Line 23: iff(c, a, b) → (c ? a : b)
  • Line 23: abs → math.abs
  • Line 36: stdev → ta.stdev
12 more edits
  • Line 37: iff(c, a, b) → (c ? a : b)
  • Line 38: iff(c, a, b) → (c ? a : b)
  • Line 42: iff(c, a, b) → (c ? a : b)
  • Line 43: iff(c, a, b) → (c ? a : b)
  • Line 44: iff(c, a, b) → (c ? a : b)
  • Line 45: iff(c, a, b) → (c ? a : b)
  • Line 47: crossover → ta.crossover
  • Line 48: crossunder → ta.crossunder
  • Line 49: round → math.round
  • Line 49: pow → math.pow
  • Line 49: pow → math.pow
  • Line 53: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯calc_rsi_volume(fv, length) =>    -    up=iff(fv>fv[1],abs(fv-fv[1])*volume,0)+    up=(fv>fv[1] ? math.abs(fv-fv[1])*volume : 0)-    dn=iff(fv<fv[1],abs(fv-fv[1])*volume,0)+    dn=(fv<fv[1] ? math.abs(fv-fv[1])*volume : 0)    upt=WiMA(up,length)⋯xPrice = close-StdDev = stdev(xPrice, Period)+StdDev = ta.stdev(xPrice, Period)-d = iff(close > close[1], 0, StdDev)+d = (close > close[1] ? 0 : StdDev)-u = iff(close > close[1], StdDev, 0)+u = (close > close[1] ? StdDev : 0)nU := (13 * nz(nU[1],0) + u) / 14⋯nRes := 100 * nU / (nU + nD)-pos := iff(nRes < BuyZone, -1,-       iff(nRes > SellZone, 1, nz(pos[1], 0))) +pos := (nRes < BuyZone ? -1 : (nRes > SellZone ? 1 : nz(pos[1], 0))) -possig := iff(reverse and pos == 1, -1,-          iff(reverse and pos == -1, 1, pos))       +possig := (reverse and pos == 1 ? -1 : (reverse and pos == -1 ? 1 : pos))        -long=crossover (rsi_v,ob) and (possig == 1) +long=ta.crossover (rsi_v,ob) and (possig == 1) -short=crossunder(rsi_v,os) and (possig == -1)+short=ta.crossunder(rsi_v,os) and (possig == -1)-g(v, p) => round(v * (pow(10, p))) / pow(10, p)+g(v, p) => math.round(v * (math.pow(10, p))) / math.pow(10, p)risk     = input(100)⋯c = g((strategy.equity * leverage / open) * (risk / 100), 4)-strategy.entry("long",1,c,when=long)+strategy.entry("long",strategy.long,c,when=long)strategy.close("long",when=short)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 34: input() → input.bool()
  • Line 48: input() → input.int()
  • Line 49: input() → input.float()
4 more edits
  • Line 51: when = long → if block
  • Line 52: when = short → if block
  • Line 71: input() → input.float()
  • Line 72: input() → input.float()
⋯strategy(title="Crypto RSI + RVI Strategy", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.03, pyramiding=1  )-Period = input(100, minval=1)+Period = input.int(100, minval=1)-BuyZone = input(49, minval=1)+BuyZone = input.int(49, minval=1)-SellZone = input(50, minval=1)+SellZone = input.int(50, minval=1)length=Period⋯ -reverse = input(false, title="Trade reverse")+reverse = input.bool(false, title="Trade reverse")xPrice = close⋯g(v, p) => math.round(v * (math.pow(10, p))) / math.pow(10, p)-risk     = input(100)+risk     = input.int(100)-leverage = input(2.5)+leverage = input.float(2.5)c = g((strategy.equity * leverage / open) * (risk / 100), 4)-strategy.entry("long",strategy.long,c,when=long)+if long+    strategy.entry("long",strategy.long,c)-strategy.close("long",when=short)+if short+    strategy.close("long")//strategy.entry("short",0,when=short)⋯//plotshape(exitLongCondition, style=shape.labeldown, location=location.abovebar, color=color.color.red, size=size.tiny, title="SELL", text="SELL", textcolor=color.color.white)-sl=input(0.2)+sl=input.float(0.2)-tp=input(1.0)+tp=input.float(1.0)strategy.exit("long_tp/sl", "long", profit=close * tp / syminfo.mintick, loss=close * sl / syminfo.mintick, comment='long_tp/sl', alert_message = 'closelong')⋯

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: 2 before, 0 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.

-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Settings

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

SettingDefaultType and rangeFeeds
Period (no label in the script)100int · min 1length StdDev
Buy Zone (no label in the script)49int · min 1pos os
Sell Zone (no label in the script)50int · min 1pos ob
Trade reversefalseboolpossig
Risk (no label in the script)100intc
Leverage (no label in the script)2.5floatc
Sl (no label in the script)0.2floatexit long_tp/sl exit short_tp/sl
Tp (no label in the script)1.0floatexit long_tp/sl exit short_tp/sl

What it calculates

  • Stdev (stdev, ta.stdev in v5)xPrice, Period (100)StdDev · line 36

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.

PeriodPeriodsetting · 100SellZoneSell Zonesetting · 50BuyZoneBuy Zonesetting · 49closecloseprice dataopenopenprice dataleverageLeveragesetting · 2.5riskRisksetting · 100timetimeprice datavolumevolumeprice dataStdDevStdev→ StdDevlengthlengthvalueMA_sMA_svaluenUnUvaluenDnDvaluenResnResvalueobobvalueososvalueuptuptvaluedntdntvaluersi_vrsi_vvaluexPricexPricevalueccvaluetimeOfBuyatimeOfBuyavaluelongExitSignalalongExitSignalavaluelonglongconditionshortshortconditionposposconditionpossigpossigconditionup, dnup · dn2 conditionsd, ud · u2 conditionslongConditionlongConditionconditionexitLongConditionexitLongConditionconditionentry:longOpen longstrategy.entryclose:longClose longstrategy.closeexit:long_tp/slexit long_tp/slstrategy.exitexit:short_tp/slexit short_tp/slstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open long longlongcrossover (rsi_v,ob) and (possig == 1)On53
Close longshortcrossunder(rsi_v,os) and (possig == -1)On54
Exit long_tp/sl stop and limitevery barOn75
Exit short_tp/sl stop and limitevery barOn76

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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+4.0%+102.5%250%1.2932.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+48.2%+5.5%333%5.7212.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−50.3%+9.8%333%0.1854.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.1%+8.4%00%0.009.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−71.2%+16.7%425%0.1077.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+74.7%+21.5%333%3.9311.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−85.6%+148.3%60%0.0086.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+18.6%+17.1%333%1.6232.6%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 market0—$0.00
Sideways market250%$40.74
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?

13.8%

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

0%16%
All 2 trades
SideEntryExitBarsP&L
long17 Jul 2024 65,044.003 Aug 2024 61,498.3017−$138.33
long30 Oct 2024 72,736.4011 Mar 2025 78,595.90132$179.07

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
Crypto RSI with RVI Strategy this page—v4 strategy+4.0%232.1%
Simple way to BEAT the market [STRATEGY] by TraderHalaistdevv4 strategy+193.5%1539.2%
Portfolio Performance - 2 Assets by Skywalking2874stdevv5 strategyNo trades on this market
Historical Volatility by Zeal Terminalstdevv5 indicatorindicator
Double Bollinger Binary Options by Trade_by_DBstdevv5 strategyNo trades on this market
Improved Bollinger Swing Strategy Stock Nasdaq by exlux99stdevv4 strategy−20.4%722.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msWith a workaround 1,000 bars in 48 msNot measured
PineTSNo 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 53) 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.

//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © exlux99strategy(title="Crypto RSI + RVI Strategy", overlay=true, initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.03, pyramiding=1  )Period = input(100, minval=1)BuyZone = input(49, minval=1)SellZone = input(50, minval=1)length=PeriodMA_s=0.0pos=0.0possig=0.0nU=0.0nD=0.0nRes=0.0ob=SellZoneos=BuyZoneWiMA(src, length) =>     MA_s=0.0    MA_s:=(src + nz(MA_s[1] * (length-1)))/length    MA_scalc_rsi_volume(fv, length) =>        up=iff(fv>fv[1],abs(fv-fv[1])*volume,0)    dn=iff(fv<fv[1],abs(fv-fv[1])*volume,0)    upt=WiMA(up,length)    dnt=WiMA(dn,length)    100*(upt/(upt+dnt))rsi_v = calc_rsi_volume(close, length)// u=plot(ob)// l=plot(os)// fill(u,l,color.red)// plot(50)// plot(rsi_v, color=color.red, linewidth=1) reverse = input(false, title="Trade reverse")xPrice = closeStdDev = stdev(xPrice, Period)d = iff(close > close[1], 0, StdDev)u = iff(close > close[1], StdDev, 0)nU := (13 * nz(nU[1],0) + u) / 14nD := (13 * nz(nD[1],0) + d) / 14nRes := 100 * nU / (nU + nD)pos := iff(nRes < BuyZone, -1,       iff(nRes > SellZone, 1, nz(pos[1], 0))) possig := iff(reverse and pos == 1, -1,          iff(reverse and pos == -1, 1, pos))        long=crossover (rsi_v,ob) and (possig == 1) short=crossunder(rsi_v,os) and (possig == -1)g(v, p) => round(v * (pow(10, p))) / pow(10, p)risk     = input(100)leverage = input(2.5)c = g((strategy.equity * leverage / open) * (risk / 100), 4)strategy.entry("long",1,c,when=long)strategy.close("long",when=short)//strategy.entry("short",0,when=short) // ------------------------- Strategy Logic --------------------------------- //var longOpeneda = falsevar shortOpeneda = falsevar int timeOfBuya = na longCondition= long and not longOpeneda if longCondition    longOpeneda := true    timeOfBuya := timelongExitSignala = shortexitLongCondition = longOpeneda[1] and longExitSignalaif exitLongCondition    longOpeneda := false    timeOfBuya := na//plotshape(longCondition, style=shape.labelup, location=location.belowbar, color=color.color.green, size=size.tiny, title="BUY", text="BUY", textcolor=color.color.white)//plotshape(exitLongCondition, style=shape.labeldown, location=location.abovebar, color=color.color.red, size=size.tiny, title="SELL", text="SELL", textcolor=color.color.white)sl=input(0.2)tp=input(1.0)strategy.exit("long_tp/sl", "long", profit=close * tp / syminfo.mintick, loss=close * sl / syminfo.mintick, comment='long_tp/sl', alert_message = 'closelong')strategy.exit("short_tp/sl", "short", profit=close * tp / syminfo.mintick, loss=close * sl / syminfo.mintick, comment='short_tp/sl',  alert_message = 'closeshort')