Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

RSI_OTT - TP-SL

A Pine Script v5 strategy built on Linreg (src, 1), SMA or EMA or WMA (src, 1) and Crossover (src, OTTlower). It has 12 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.05% commission. 19 settings; defaults include Source close, RSI Length 6 and RSI OverSold 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 RSI_OTT - TP-SL 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_OTT - TP-SL 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, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does RSI_OTT - TP-SL run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does RSI_OTT - TP-SL use a stop loss?
Yes
strategy.exit sets a stop on line 178, 180, 189, 191.
Does RSI_OTT - TP-SL run in Zeal Terminal?
Yes
It compiles in 54 ms and runs 1,000 bars in 124 ms, in the browser.

BTCUSDT · 1D · default settings

  • OTT UPPER
  • OTT MIDDLE
  • OTT LOWER
  • 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 (19)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,000$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. 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
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
0.00%
$0.00

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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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 153, 157, 161, 162, 168, 169. 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
Sourceclosesourcevrsi
RSI Length6intvrsi
RSI OverSold50int · min 1rsiCrossOver
RSI OverBought50int · min 1rsiCrossUnder
OTT Period1int · min 1valpha VAR wwalpha WWMA zxLag ZLEMA lrc lrc1 TSF ma MAvg
OTT Percent5float · min 0.001 · step 0.1fark OTT
OTT MA TypeVARstring · options ["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"]line 55 line 58 line 61 line 64 line 67 line 70 line 73 line 76
OTT Upper Line Coeff0.01float · min 0.001 · step 0.001OTTupper
OTT Lower Line Coeff0.01float · min 0.001 · step 0.001OTTlower
Take Profit:0.0float · min 0.0 · max 100.0 · step 0.1longProfitPrice shortProfitPrice line 176 line 181
Stop Loss: 0.0float · min 0.0 · max 100.0 · step 0.1longStopPrice shortStopPrice line 176 line 187
Long Entrytrueboolentry LONG close LONG line 151 line 160
Short Entrytrueboolentry SHORT close SHORT line 151 line 167
From Day1int · min 1 · max 31start
From Month1int · min 1 · max 12start
From Year2021int · min 2010start
To Day30int · min 1 · max 31finish
To Month12int · min 1 · max 12finish
To Year2022int · min 2010finish

What it calculates

  • Linregsrc, OTT Period (1), 0lrc · line 47
  • Linregsrc, OTT Period (1), 1lrc1 · line 48
  • SMA / EMA / WMAsrc, OTT Period (1)ma · line 56
  • Crossoversrc, OTTlowerbuyEntry · line 102
  • Crossundersrc, OTTuppersellEntry · line 103
  • RSISource (close), RSI Length (6)vrsi · line 133
  • Crossovervrsi, RSI OverSold (50)rsiCrossOver · line 134
  • Crossundervrsi, RSI OverBought (50)rsiCrossUnder · line 135
  • Crossoversrc, OTTlowerOTTCrossOver · line 136
  • Crossundersrc, OTTupperOTTCrossUnder · line 137

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.

The script has 62 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open LONG longbuySignallwindow() and long and (not stoppedOutLong)On153
Open SHORT shortsellSignallwindow() and (not long) and (not stoppedOutShort)On157
Open LONG longbuySignallwindow() and long and (not stoppedOutLong)On161
Close LONGsellSignallwindow() and (not long) and (not stoppedOutShort)On162
Open SHORT shortsellSignallwindow() and (not long) and (not stoppedOutShort)On168
Close SHORTbuySignallwindow() and long and (not stoppedOutLong)On169
Exit LONG stop and limit( strategy.position_size > 0 )On178
Exit SHORT stop and limit( strategy.position_size < 0 )On180
Exit LONG limit( strategy.position_size > 0 )On183
Exit SHORT limit( strategy.position_size < 0 )On185
Exit LONG stop( strategy.position_size > 0 )On189
Exit SHORT stop( strategy.position_size < 0 )On191

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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%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_OTT - TP-SL this page—v5 strategy0.0%00.0%
DRSI DMA Scalping Strategy No Repaint by allenlksma wma ema rsiv4 strategy−99.5%44137.7%
MACD ReLoaded STRATEGY by KivancOzbilgicema linreg wma smav5 strategy+7.8%315.1%
BTC 15 min by RafaelZionisma ema rsi wma linregv4 strategy−25.7%11938.9%
MACD, RSI, & RVOL Strategy by BobBarker42069rsi ema smav4 strategy+32.6%11.5%
IFR2 - RSI2 by jocker.soadrsi sma emav4 strategyNo trades on this market

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.

  • 6 strategy calls use the when = argument (line 153, 157, 161, 162, 168, 169). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 1 setting uses the untyped input() (line 12). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 12: input() → input.source()
  • Line 153: when = buySignall → if block
  • Line 157: when = sellSignall → if block
  • Line 161: when = buySignall → if block
  • Line 162: when = sellSignall → if block
  • Line 168: when = sellSignall → if block
  • Line 169: when = buySignall → if block
⋯//---------- RSI --------------price = input(close, title="Source")+price = input.source(close, title="Source")RSIlength = input.int(defval=6,title="RSI Length") ⋯    if long -        strategy.entry("LONG", strategy.long, when = buySignall, comment = "ENTER LONG")+        if buySignall+            strategy.entry("LONG", strategy.long, comment = "ENTER LONG")        stoppedOutLong := true⋯    else -        strategy.entry("SHORT", strategy.short, when = sellSignall, comment = "ENTER SHORT")+        if sellSignall+            strategy.entry("SHORT", strategy.short, comment = "ENTER SHORT")        stoppedOutLong  := false⋯else if(isEntryLong)-    strategy.entry("LONG", strategy.long,  when = buySignall)+    if buySignall+        strategy.entry("LONG", strategy.long)-    strategy.close("LONG", when = sellSignall)+    if sellSignall+        strategy.close("LONG")    if long ⋯else if(isEntryShort)-    strategy.entry("SHORT", strategy.short, when = sellSignall)+    if sellSignall+        strategy.entry("SHORT", strategy.short)-    strategy.close("SHORT", when = buySignall)+    if buySignall+        strategy.close("SHORT")    if not long⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © BigCoinHunter-//@version=5+//@version=6strategy(title="RSI_OTT-TP/SL", overlay=true, ⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 54 msWith a workaround 1,000 bars in 124 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/// © BigCoinHunter//@version=5strategy(title="RSI_OTT-TP/SL", overlay=true,      pyramiding=0, default_qty_type=strategy.percent_of_equity,      default_qty_value=100, initial_capital=1000,      currency=currency.USD, commission_value=0.05,      commission_type=strategy.commission.percent,      process_orders_on_close=true)//----------- get the user inputs --------------//---------- RSI -------------price = input(close, title="Source")RSIlength = input.int(defval=6,title="RSI Length") RSIoverSold = input.int(defval=50, title="RSI OverSold", minval=1)RSIoverBought = input.int(defval=50, title="RSI OverBought", minval=1)//------- OTT Bands ----------------src = closelength=input.int(defval=1, title="OTT Period", minval=1)percent=input.float(defval=5, title="OTT Percent", step=0.1, minval=0.001)mav = input.string(title="OTT MA Type", defval="VAR", options=["SMA", "EMA", "WMA", "TMA", "VAR", "WWMA", "ZLEMA", "TSF"])ottUpperPercent = input.float(title="OTT Upper Line Coeff", defval=0.01, minval = 0.001, step=0.001)ottLowerPercent = input.float(title="OTT Lower Line Coeff", defval=0.01, minval = 0.001, step=0.001)Var_Func(src,length)=>    valpha=2/(length+1)    vud1=src>src[1] ? src-src[1] : 0    vdd1=src<src[1] ? src[1]-src : 0    vUD=math.sum(vud1,9)    vDD=math.sum(vdd1,9)    vCMO=nz((vUD-vDD)/(vUD+vDD))    VAR=0.0    VAR:=nz(valpha*math.abs(vCMO)*src)+(1-valpha*math.abs(vCMO))*nz(VAR[1])    VAR=Var_Func(src,length)Wwma_Func(src,length)=>    wwalpha = 1/ length    WWMA = 0.0    WWMA := wwalpha*src + (1-wwalpha)*nz(WWMA[1])    WWMA=Wwma_Func(src,length)Zlema_Func(src,length)=>    zxLag = length/2==math.round(length/2) ? length/2 : (length - 1) / 2    zxEMAData = (src + (src - src[zxLag]))    ZLEMA = ta.ema(zxEMAData, length)    ZLEMA=Zlema_Func(src,length)Tsf_Func(src,length)=>    lrc = ta.linreg(src, length, 0)    lrc1 = ta.linreg(src,length,1)    lrs = (lrc-lrc1)    TSF = ta.linreg(src, length, 0)+lrs    TSF=Tsf_Func(src,length)getMA(src, length) =>    ma = 0.0    if mav == "SMA"        ma := ta.sma(src, length)        ma    if mav == "EMA"        ma := ta.ema(src, length)        ma    if mav == "WMA"        ma := ta.wma(src, length)        ma    if mav == "TMA"        ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)        ma    if mav == "VAR"        ma := VAR        ma    if mav == "WWMA"        ma := WWMA        ma    if mav == "ZLEMA"        ma := ZLEMA        ma    if mav == "TSF"        ma := TSF        ma    ma    MAvg=getMA(src, length)fark=MAvg*percent*0.01longStop = MAvg - farklongStopPrev = nz(longStop[1], longStop)longStop := MAvg > longStopPrev ? math.max(longStop, longStopPrev) : longStopshortStop =  MAvg + farkshortStopPrev = nz(shortStop[1], shortStop)shortStop := MAvg < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStopdir = 1dir := nz(dir[1], dir)dir := dir == -1 and MAvg > shortStopPrev ? 1 : dir == 1 and MAvg < longStopPrev ? -1 : dirMT = dir==1 ? longStop: shortStopOTT=MAvg>MT ? MT*(200+percent)/200 : MT*(200-percent)/200light_green=#08ff12light_red=#fe0808OTTupper = nz(OTT[2])*(1+ottUpperPercent)OTTlower = nz(OTT[2])*(1-ottLowerPercent)p1 = plot(OTTupper, color=light_green, linewidth=1, title="OTT UPPER")p2 = plot(nz(OTT[2]), color=color.new(color.yellow,0), linewidth=1, title="OTT MIDDLE")p3 = plot(OTTlower, color=light_red, linewidth=1, title="OTT LOWER")fill(plot1=p1, plot2=p3, title="OTT Background", color=color.new(color.aqua,90), fillgaps=false, editable=true)buyEntry = ta.crossover(src, OTTlower)sellEntry = ta.crossunder(src, OTTupper)//---------- input TP/SL ---------------tp = input.float(title="Take Profit:", defval=0.0, minval=0.0, maxval=100.0, step=0.1) * 0.01sl = input.float(title="Stop Loss:  ", defval=0.0, minval=0.0, maxval=100.0, step=0.1) * 0.01isEntryLong = input.bool(defval=true, title= 'Long Entry', inline="11")isEntryShort = input.bool(defval=true, title='Short Entry', inline="11")//---------- backtest range setup ------------fromDay   = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)fromYear  = input.int(defval = 2021, title = "From Year", minval = 2010)toDay     = input.int(defval = 30, title = "To Day", minval = 1, maxval = 31)toMonth   = input.int(defval = 12, title = "To Month", minval = 1, maxval = 12)toYear    = input.int(defval = 2022, title = "To Year", minval = 2010)//------------ time interval setup -----------start     = timestamp(fromYear, fromMonth, fromDay, 00, 00)  // backtest start windowfinish    = timestamp(toYear, toMonth, toDay, 23, 59)        // backtest finish windowwindow()  => time >= start and time <= finish ? true : false // create function "within window of time"//------- define the global variables ------var bool long = truevar bool stoppedOutLong = falsevar bool stoppedOutShort = false//--------- Colors ---------------//TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? color.red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? color.green : na//bgcolor(switch2?(color.new(TrendColor,50)):na)//--------- calculate the input/output points -----------longProfitPrice  = strategy.position_avg_price * (1 + tp)     // tp -> take profit percentagelongStopPrice = strategy.position_avg_price * (1 - sl)        // sl -> stop loss percentageshortProfitPrice  = strategy.position_avg_price * (1 - tp)shortStopPrice = strategy.position_avg_price * (1 + sl)//---------- RSI + Bollinger Bands Strategy -------------vrsi = ta.rsi(price, RSIlength)rsiCrossOver = ta.crossover(vrsi, RSIoverSold)rsiCrossUnder = ta.crossunder(vrsi, RSIoverBought)OTTCrossOver = ta.crossover(src, OTTlower)OTTCrossUnder = ta.crossunder(src, OTTupper)if (not na(vrsi))    if rsiCrossOver and OTTCrossOver        long := true            if rsiCrossUnder and OTTCrossUnder        long := false//------- define the global variables ------buySignall = falsesellSignall = false//------------------- determine buy and sell points ---------------------buySignall := window() and long  and (not stoppedOutLong)sellSignall := window() and (not long)  and (not stoppedOutShort)//---------- execute the strategy -----------------if(isEntryLong and isEntryShort)    if long         strategy.entry("LONG", strategy.long, when = buySignall, comment = "ENTER LONG")        stoppedOutLong := true        stoppedOutShort := false    else         strategy.entry("SHORT", strategy.short, when = sellSignall, comment = "ENTER SHORT")        stoppedOutLong  := false        stoppedOutShort := trueelse if(isEntryLong)    strategy.entry("LONG", strategy.long,  when = buySignall)    strategy.close("LONG", when = sellSignall)    if long         stoppedOutLong := true    else        stoppedOutLong  := falseelse if(isEntryShort)    strategy.entry("SHORT", strategy.short, when = sellSignall)    strategy.close("SHORT", when = buySignall)    if not long        stoppedOutShort := true    else        stoppedOutShort := false    //----------------- take profit and stop loss -----------------if(tp>0.0 and sl>0.0)    if ( strategy.position_size > 0 )        strategy.exit(id="LONG", limit=longProfitPrice, stop=longStopPrice, comment="Long TP/SL Trigger")    else if ( strategy.position_size < 0 )        strategy.exit(id="SHORT", limit=shortProfitPrice, stop=shortStopPrice, comment="Short TP/SL Trigger")else if(tp>0.0)    if ( strategy.position_size > 0 )        strategy.exit(id="LONG", limit=longProfitPrice, comment="Long TP Trigger")    else if ( strategy.position_size < 0 )        strategy.exit(id="SHORT", limit=shortProfitPrice, comment="Short TP Trigger")        else if(sl>0.0)    if ( strategy.position_size > 0 )        strategy.exit(id="LONG",  stop=longStopPrice, comment="Long SL Trigger")    else if ( strategy.position_size < 0 )        strategy.exit(id="SHORT",  stop=shortStopPrice, comment="Short SL Trigger")