Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

RSI of Ultimate Oscillator [SHORT Selling] Strategy

A Pine Script v4 strategy built on SMA (src, length) and RSI (out, 5). It has 3 order rules, 1 entry among them, and trades short only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 20% of equity and pays no commission. 9 settings; defaults include Length1 5, Length2 10 and Length3 15.

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 of Ultimate Oscillator [SHORT Selling] 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 RSI of Ultimate Oscillator [SHORT Selling] Strategy do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings; it opened a short position that was still open on the last bar, so there is no result to report. On ETHUSDT 1D it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Can RSI of Ultimate Oscillator [SHORT Selling] 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 RSI of Ultimate Oscillator [SHORT Selling] Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI of Ultimate Oscillator [SHORT Selling] Strategy run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 66 ms, in the browser.

BTCUSDT · 1D · default settings

  • Middle Line 60 [Short Here]
  • Overbought
  • Oversold
  • rsiUO
  • 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 (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctMiddle Line 60 [Short Here]$4,837$20,253Equity from $10,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. Zeal Terminal's engine currently reads an order side written as long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 56) so the engine trades the way the script says.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
125.93%
−$12,593.00

One run with the author's default settings, $10,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.

  • Likely bug

    crossover(rsiUO, 30) ignores the settings line 61

    Line 61 hard-codes 30 where line 62 uses “Cover at RSIofUO”. Changing those settings moves one band but not this one.

    crossover(rsiUO,30)crossover(rsiUO, coverLine)
  • 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

    3 settings have no label

    In the settings dialog length1 (line 8), length2 (line 8), length3 (line 8) 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 56, 61, 62. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 43

    transp = on line 43, 59. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 56

    long = on line 56. v5 writes it as direction = strategy.long or strategy.short.

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 sum → math.sum, max → math.max, min → math.min, sma → ta.sma, rsi → ta.rsi, crossunder → ta.crossunder, abs → math.abs, crossover → ta.crossover.
  • 3 strategy calls use the when = argument (line 56, 61, 62). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 15: sum → math.sum
  • Line 15: sum → math.sum
  • Line 16: max → math.max
  • Line 17: min → math.min
  • Line 30: sma → ta.sma
11 more edits
  • Line 43: transp = 90 → color.new(color.blue, 90)
  • Line 44: rsi → ta.rsi
  • Line 56: long = false → direction = strategy.short
  • Line 56: crossunder → ta.crossunder
  • Line 58: abs → math.abs
  • Line 59: abs → math.abs
  • Line 59: transp = 70 → color.new(abs(strategy.position_size)>=1 ? color.purple : na, 70)
  • Line 61: abs → math.abs
  • Line 61: crossover → ta.crossover
  • Line 62: abs → math.abs
  • Line 62: crossover → ta.crossover
⋯// © mohanee-//@version=4+//@version=5strategy(title="RSI of Ultimate Oscillator [SHORT Selling] Strategy",  shorttitle="RSIofUO" , overlay=false, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed,⋯showUO=input(false, "show Ultimate Oscialltor")-average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)+average(bp, tr_, length) => math.sum(bp, length) / math.sum(tr_, length)-high_ = max(high, close[1])+high_ = math.max(high, close[1])-low_ = min(low, close[1])+low_ = math.min(low, close[1])bp = close - low_⋯    smma =  0.0-    smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length+    smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length    smma⋯osLevelPlot = hline(25, title="Oversold", color=color.blue, linestyle=hline.style_dashed)-fill(obLevelPlot, osLevelPlot, title="Background", color=color.blue, transp=90)+fill(obLevelPlot, osLevelPlot, title="Background", color=color.new(color.blue, 90))-rsiUO = rsi(out,rsiUOLength)+rsiUO = ta.rsi(out,rsiUOLength)ultPlot=plot(showUO==true? out : na, color=color.green, title="Oscillator")⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="SERSIofUO", long=false,   qty=qty1, when = sma1<=sma2 and sma2 < sma3 and close<sma2 and crossunder(rsiUO,sellLine) )+strategy.entry(id="SERSIofUO", direction = strategy.short,   qty=qty1, when = sma1<=sma2 and sma2 < sma3 and close<sma2 and ta.crossunder(rsiUO,sellLine) )//strategy.entry(id="SERSiofUO", long=false, when = sma1< sma2  and crossunder(rsiUO,60) )-barcolor(abs(strategy.position_size)>=1 ? color.purple : na )+barcolor(math.abs(strategy.position_size)>=1 ? color.purple : na )-bgcolor(abs(strategy.position_size)>=1 ? color.purple : na , transp=70)+bgcolor(color.new(math.abs(strategy.position_size)>=1 ? color.purple : na, 70) )//partial exit-strategy.close(id="SERSIofUO", comment="PExit",  qty=strategy.position_size/3, when=abs(strategy.position_size)>=1 and close< strategy.position_avg_price and crossover(rsiUO,30) )+strategy.close(id="SERSIofUO", comment="PExit",  qty=strategy.position_size/3, when=math.abs(strategy.position_size)>=1 and close< strategy.position_avg_price and ta.crossover(rsiUO,30) )-strategy.close(id="SERSIofUO", comment="CloseAll", when=abs(strategy.position_size)>=1 and crossover(rsiUO,coverLine) )+strategy.close(id="SERSIofUO", comment="CloseAll", when=math.abs(strategy.position_size)>=1 and ta.crossover(rsiUO,coverLine) )//Strategy Logic ⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 8: input() → input.int()
  • Line 8: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
6 more edits
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.bool()
  • Line 56: when = sma1<=sma2 and sma2 < sma3 and close<sma2 and ta.crossunder(rsiUO,sellLine) → if block
  • Line 61: when = math.abs(strategy.position_size)>=1 and close< strategy.position_avg_price and ta.crossover(rsiUO,30) → if block
  • Line 62: when = math.abs(strategy.position_size)>=1 and ta.crossover(rsiUO,coverLine) → if block
⋯/////////////////////////////////////////////////////////////////////////////////-length1 = input(5, minval=1), length2 = input(10, minval=1), length3 = input(15, minval=1)+length1 = input.int(5, minval=1), length2 = input.int(10, minval=1), length3 = input.int(15, minval=1)-rsiUOLength = input(5, title="RSI UO length", minval=1)+rsiUOLength = input.int(5, title="RSI UO length", minval=1)-sellLine = input (60, title="Sell at RSIofUO")+sellLine = input.int (60, title="Sell at RSIofUO")-coverLine = input (75, title="Cover at RSIofUO")+coverLine = input.int (75, title="Cover at RSIofUO")-riskCapital = input(title="Risk % of capital", defval=10, minval=1)+riskCapital = input.int(title="Risk % of capital", defval=10, minval=1)-stopLoss=input(3,title="Stop Loss",minval=1)+stopLoss=input.int(3,title="Stop Loss",minval=1)-showUO=input(false, "show Ultimate Oscialltor")+showUO=input.bool(false, "show Ultimate Oscialltor")average(bp, tr_, length) => math.sum(bp, length) / math.sum(tr_, length)⋯qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1-strategy.entry(id="SERSIofUO", direction = strategy.short,   qty=qty1, when = sma1<=sma2 and sma2 < sma3 and close<sma2 and ta.crossunder(rsiUO,sellLine) )+if sma1<=sma2 and sma2 < sma3 and close<sma2 and ta.crossunder(rsiUO,sellLine)+    strategy.entry(id="SERSIofUO", direction = strategy.short,   qty=qty1 )//strategy.entry(id="SERSiofUO", long=false, when = sma1< sma2  and crossunder(rsiUO,60) )⋯//partial exit-strategy.close(id="SERSIofUO", comment="PExit",  qty=strategy.position_size/3, when=math.abs(strategy.position_size)>=1 and close< strategy.position_avg_price and ta.crossover(rsiUO,30) )+if math.abs(strategy.position_size)>=1 and close< strategy.position_avg_price and ta.crossover(rsiUO,30)+    strategy.close(id="SERSIofUO", comment="PExit",  qty=strategy.position_size/3 )-strategy.close(id="SERSIofUO", comment="CloseAll", when=math.abs(strategy.position_size)>=1 and ta.crossover(rsiUO,coverLine) )+if math.abs(strategy.position_size)>=1 and ta.crossover(rsiUO,coverLine)+    strategy.close(id="SERSIofUO", comment="CloseAll" )//Strategy Logic ⋯

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

⋯// © mohanee-//@version=5+//@version=6strategy(title="RSI of Ultimate Oscillator [SHORT Selling] Strategy",  shorttitle="RSIofUO" , overlay=false, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed,⋯

Settings

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

SettingDefaultType and rangeFeeds
Length1 (no label in the script)5int · min 1avg7
Length2 (no label in the script)10int · min 1avg14
Length3 (no label in the script)15int · min 1avg28
RSI UO length5int · min 1rsiUO
Sell at RSIofUO60intMiddle Line 60 [Short Here] entry SERSIofUO
Cover at RSIofUO75intclose SERSIofUO
Risk % of capital10int · min 1qty1
Stop Loss3int · min 1qty1
show Ultimate OscialltorfalseboolOscillator

What it calculates

  • SMA (sma, ta.sma in v5)src, lengthsmma · line 30
  • RSI (rsi, ta.rsi in v5)out, RSI UO length (5)rsiUO · line 44

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.

rsiUOLengthRSI UO lengthsetting · 5closecloseprice datahighhighprice datalowlowprice datalength1Length1setting · 5length2Length2setting · 10length3Length3setting · 15hl2hl2price datariskCapitalRisk % of capitalsetting · 10stopLossStop Losssetting · 3sellLineSell at RSIofUOsetting · 60coverLineCover at RSIofUOsetting · 75smmaSMA→ smmarsiUORSI→ rsiUOhigh_high_valuelow_low_valuebpbpvaluetr_tr_valueavg7avg7valueavg14avg14valueavg28avg28valueoutoutvaluesma1, sma2, sma3sma1 · sma2 +13 valuesqty1qty1valueentry:SERSIofUOOpen SERSIofUOstrategy.entryclose:SERSIofUOClose SERSIofUOstrategy.closehline:40Middle Line 60 [Short …hlinehline:41Overboughthlinehline:42Oversoldhlinefill:BackgroundBackgroundfillplot:45Oscillatorplotplot:46rsiUOplotbarcolor:58barcolorbarcolorbgcolor:59bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open SERSIofUO shortsma1<=sma2 and sma2 < sma3 and close<sma2 and crossunder(rsiUO,sellLine)On56
Close SERSIofUOabs(strategy.position_size)>=1 and close< strategy.position_avg_price and crossover(rsiUO,30)On61
Close SERSIofUOabs(strategy.position_size)>=1 and crossover(rsiUO,coverLine)On62

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 1D0.0%+102.5%00%—125.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—12.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−29.9%+9.8%1560%0.6348.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−3.8%+8.4%944%0.9027.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−49.6%+16.7%1644%0.5664.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+6.8%+21.5%1050%1.3219.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−36.0%+148.3%1020%0.4036.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−4.1%+17.1%1258%0.7213.5%8 May 2026 – 21 Oct 2026

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

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
RSI of Ultimate Oscillator [SHORT Selling] Strategy this page—v4 strategy0.0%0125.9%
SRJ RSI Outperformer Strategy by Sapt_Jashrsi smav5 strategy+0.6%82.4%
RSI SMA Crossover Strategy by reeesrsi smav5 strategy+39.8%4230.8%
Short In Downtrend Below MA100 (Coinrule) by Coinrulesma rsiv4 strategy−34.5%9945.4%
Simple RSI and SMA Long and Short (by Coinrule) by Coinrulersi smav5 strategy−3.0%217.7%
Maximized Moving Average Crossing (by Coinrule) by Coinrulesma rsiv4 strategy−6.6%913.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msWith a workaround 1,000 bars in 66 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 56) 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/// © mohanee//@version=4strategy(title="RSI of Ultimate Oscillator [SHORT Selling] Strategy",  shorttitle="RSIofUO" , overlay=false, pyramiding=1,     default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed,    //Ultimate Oscillator logic copied from  TradingView   builtin indicator/////////////////////////////////////////////////////////////////////////////////length1 = input(5, minval=1), length2 = input(10, minval=1), length3 = input(15, minval=1)rsiUOLength = input(5, title="RSI UO length", minval=1)sellLine = input (60, title="Sell at RSIofUO")coverLine = input (75, title="Cover at RSIofUO")riskCapital = input(title="Risk % of capital", defval=10, minval=1)stopLoss=input(3,title="Stop Loss",minval=1)showUO=input(false, "show Ultimate Oscialltor")average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)high_ = max(high, close[1])low_ = min(low, close[1])bp = close - low_tr_ = high_ - low_avg7 = average(bp, tr_, length1)avg14 = average(bp, tr_, length2)avg28 = average(bp, tr_, length3)out = 100 * (4*avg7 + 2*avg14 + avg28)/7//Ultimate Oscillator ///////////////////////////////////////////////////////////////////////////////////Willimas Alligator  copied from  TradingView built in Indicator/////////////////////////////////////////////////////////////////////////////////smma(src, length) =>    smma =  0.0    smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length    smma//moving averages logic copied from Willimas Alligator -- builtin indicator in TradingViewsma1=smma(hl2,10)sma2=smma(hl2,20)sma3=smma(hl2,50)//Willimas Alligator///////////////////////////////////////////////////////////////////////////////////drawings/////////////////////////////////////////////////////////////////////////////////hline(sellLine, title="Middle Line 60  [Short Here]", color=color.red , linestyle=hline.style_solid)obLevelPlot = hline(75, title="Overbought",  color=color.blue , linestyle=hline.style_dashed)osLevelPlot = hline(25, title="Oversold", color=color.blue, linestyle=hline.style_dashed)fill(obLevelPlot, osLevelPlot, title="Background", color=color.blue, transp=90)rsiUO = rsi(out,rsiUOLength)ultPlot=plot(showUO==true? out : na, color=color.green, title="Oscillator")plot(rsiUO, title = "rsiUO" ,  color=color.purple)//drawings///////////////////////////////////////////////////////////////////////////////////Strategy Logic ///////////////////////////////////////////////////////////////////////////////////Entry--//Echeck how many units can be purchased based on risk manage ment and stop lossqty1 = (strategy.equity  * riskCapital / 100 ) /  (close*stopLoss/100)  //check if cash is sufficient  to buy qty1  , if capital not available use the available capital onlyqty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1strategy.entry(id="SERSIofUO", long=false,   qty=qty1, when = sma1<=sma2 and sma2 < sma3 and close<sma2 and crossunder(rsiUO,sellLine) )//strategy.entry(id="SERSiofUO", long=false, when = sma1< sma2  and crossunder(rsiUO,60) )barcolor(abs(strategy.position_size)>=1 ? color.purple : na )bgcolor(abs(strategy.position_size)>=1 ? color.purple : na , transp=70)//partial exitstrategy.close(id="SERSIofUO", comment="PExit",  qty=strategy.position_size/3, when=abs(strategy.position_size)>=1 and close< strategy.position_avg_price and crossover(rsiUO,30) )strategy.close(id="SERSIofUO", comment="CloseAll", when=abs(strategy.position_size)>=1 and crossover(rsiUO,coverLine) )//Strategy Logic /////////////////////////////////////////////////////////////////////////////////