Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

RSI Average Swing Bot

A Pine Script v5 strategy built on RSI (ohlc4, 50). It has 4 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. 4 settings; defaults include Longexit 0.65 and Shortexit 0.35.

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 Average Swing Bot repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 10 of 10 trades.
How did RSI Average Swing Bot do on BTCUSDT 1D with default settings?
+2.21%
From 26 Jan 2024 to 21 Oct 2026, over 37 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does RSI Average Swing Bot 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: 37 before, 43 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does RSI Average Swing Bot use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI Average Swing Bot run in Zeal Terminal?
Yes
It compiles in 12 ms and runs 1,000 bars in 31 ms, in the browser.

BTCUSDT · 1D · default settings

  • HLine
  • HLine
  • HLine
  • Plot
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctHLine$1,037,520$2,025,273Equity from $1,000,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.
Net profit
+2.21%
$22,146.50
Buy and hold
+102.5%
same period
Closed trades
37
7 won · 30 lost
Profitable
18.9%
of closed trades
Profit factor
1.29
gross profit ÷ gross loss
Max drawdown
3.54%
−$35,963.30

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

    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

    2 settings have no label

    In the settings dialog longexit (line 20), shortexit (line 22) 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 24, 25, 27, 28. 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
Entries Type
Allow Long entriestrueboolentry long close long line 23
Allow Short entriestrueboolentry short close short line 26
Longexit (no label in the script)0.65float · step 0.05close long
Shortexit (no label in the script)0.35float · step 0.05close short

What it calculates

  • RSIohlc4, 50rsiohlc4 · line 7
  • RSIclose, 50rsiclose · line 8
  • RSIopen, 50rsiopen · line 9
  • RSIhigh, 50rsihigh · line 10
  • RSIhlc3, 50rsihlc3 · line 11
  • RSIhl2, 50rsihl2 · line 12

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.

ohlc4ohlc4price dataclosecloseprice dataopenopenprice datahighhighprice datahlc3hlc3price datahl2hl2price datalongexitLongexitsetting · 0.65shortexitShortexitsetting · 0.35rsiohlc4RSI→ rsiohlc4rsicloseRSI→ rsiclosersiopenRSI→ rsiopenrsihighRSI→ rsihighrsihlc3RSI→ rsihlc3rsihl2RSI→ rsihl2rsi_avgrsi_avgvaluelonglongconditionshortshortconditionculoareColourculoareentry:longOpen longstrategy.entryclose:longClose longstrategy.closeentry:shortOpen shortstrategy.entryclose:shortClose shortstrategy.closehline:13hlinehlinehline:14hlinehlinehline:15hlinehlineplot:18plotplot

Order rules

OrderFires whenBy defaultLine
Open long longlongrsi_avg > 0.5 and rsi_avg[1]< 0.5On24
Close longlongexit or shortOn25
Open short shortshortrsi_avg < 0.5 and rsi_avg[1] >0.5On27
Close shortshortexit or longOn28

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.

10/10trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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+2.2%+102.5%3719%1.293.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.7%+5.5%3816%0.681.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%4120%1.060.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%2030%1.640.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%4817%0.730.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3622%1.600.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%3514%0.500.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%4326%1.380.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 barsTradesWonP&L
Rising market10%−$717.88
Sideways market3520%$26,134.60
Falling market10%−$3,270.21

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

5.1%

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

0%6%
All 37 trades
SideEntryExitBarsP&L
short25 Jun 2024 60,293.302 Jul 2024 62,900.007−$2,606.70
long2 Jul 2024 62,900.003 Jul 2024 62,135.501−$764.54
short3 Jul 2024 62,135.5016 Jul 2024 64,724.1013−$2,588.60
long16 Jul 2024 64,724.104 Aug 2024 60,698.0019−$4,026.07
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$3,339.25
long24 Aug 2024 64,037.2028 Aug 2024 59,415.004−$4,622.24
short28 Aug 2024 59,415.0019 Sep 2024 61,760.0022−$2,344.98
long19 Sep 2024 61,760.003 Oct 2024 60,649.3014−$1,110.71
short3 Oct 2024 60,649.305 Oct 2024 62,086.002−$1,436.73
long5 Oct 2024 62,086.0010 Oct 2024 60,636.005−$1,449.99
short10 Oct 2024 60,636.0012 Oct 2024 62,540.002−$1,903.98
long12 Oct 2024 62,540.0012 Nov 2024 88,648.0031$26,108.00
short25 Feb 2025 91,552.9023 Apr 2025 93,443.0057−$1,890.11
long23 Apr 2025 93,443.0027 Aug 2025 111,763.00126$18,320.20
short27 Aug 2025 111,763.0028 Aug 2025 111,262.001$501.21
long28 Aug 2025 111,262.0030 Aug 2025 108,377.002−$2,884.61
short30 Aug 2025 108,377.004 Sep 2025 111,706.005−$3,328.32
long4 Sep 2025 111,706.007 Sep 2025 110,188.003−$1,517.74
short7 Sep 2025 110,188.009 Sep 2025 112,065.002−$1,877.25
long9 Sep 2025 112,065.0026 Sep 2025 108,994.0017−$3,070.74
short26 Sep 2025 108,994.0030 Sep 2025 114,312.004−$5,317.48
long30 Sep 2025 114,312.0012 Oct 2025 110,644.0012−$3,667.57
short12 Oct 2025 110,644.0014 Oct 2025 115,166.002−$4,521.60
long14 Oct 2025 115,166.0015 Oct 2025 113,028.001−$2,137.87
short15 Oct 2025 113,028.0027 Oct 2025 114,559.0012−$1,531.28
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$4,538.11
short30 Oct 2025 110,021.0015 Jan 2026 96,951.8077$13,069.50
long15 Jan 2026 96,951.8017 Jan 2026 95,550.902−$1,400.84
short17 Jan 2026 95,550.906 Feb 2026 62,909.9020$32,641.10
long18 Apr 2026 77,072.0020 Apr 2026 73,801.802−$3,270.21
short20 Apr 2026 73,801.8022 Apr 2026 76,336.102−$2,534.34
long22 Apr 2026 76,336.1020 May 2026 76,834.4028$498.22
short20 May 2026 76,834.4021 May 2026 77,552.201−$717.88
long21 May 2026 77,552.2023 May 2026 75,539.502−$2,012.74
short23 May 2026 75,539.5026 May 2026 77,322.003−$1,782.51
long26 May 2026 77,322.0027 May 2026 75,930.001−$1,392.00
short27 May 2026 75,930.0020 Aug 2026 69,334.8085$6,595.23

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 Average Swing Bot this page—v5 strategy+2.2%373.5%
Triple RSI strategy by Trade_by_DBrsiv5 strategy+3.2%23.3%
Hobbiecode - RSI + Close previous day by hobbiecodersiv5 strategy+1.2%634.2%
dirt cheap yet elegant RSI Strategy by SparkyFlaryrsiv4 strategy−11.4%820.5%
RSI Classic Strategy (by Coinrule) by Coinrulersiv4 strategy+7.5%67.2%
RSITrendStrategy by email_analystsrsiv4 strategy+69.2%2238.6%

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.

  • 4 strategy calls use the when = argument (line 24, 25, 27, 28). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 24: when = long → if block
  • Line 25: when = longexit or short → if block
  • Line 27: when = short → if block
  • Line 28: when = shortexit or long → if block
⋯if(long_only)-    strategy.entry("long",strategy.long,when=long)+    if long+        strategy.entry("long",strategy.long)-    strategy.close("long",when=longexit or short)+    if longexit or short+        strategy.close("long")if(short_only)-    strategy.entry("short",strategy.short,when=short)+    if short+        strategy.entry("short",strategy.short)-    strategy.close("short",when=shortexit or long)+    if shortexit or long+        strategy.close("short")

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: 37 before, 43 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.

⋯// © exlux99-//@version=5+//@version=6strategy("RSI Average Swing Bot")⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 12 msYes 1,000 bars in 31 msNot measured
PineTSNot testedNot testedNot measured

“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/// © exlux99//@version=5strategy("RSI Average Swing Bot")long_only=input.bool(true, title="Allow Long entries", group="Entries Type")short_only=input.bool(true, title="Allow Short entries", group="Entries Type")rsiohlc4= ta.rsi(ohlc4,50)/100rsiclose= ta.rsi(close,50)/100rsiopen= ta.rsi(open,50)/100rsihigh= ta.rsi(high,50)/100rsihlc3= ta.rsi(hlc3,50)/100rsihl2= ta.rsi(hl2,50)/100hline(0.3, color=color.white, linestyle=hline.style_dashed, linewidth=2)hline(0.5, color=color.white, linestyle=hline.style_dotted, linewidth=2)hline(0.7, color=color.white, linestyle=hline.style_dashed, linewidth=2)rsi_avg = (rsiohlc4+rsiclose+rsiopen+rsihigh+rsihl2+rsihlc3)/6culoare = rsi_avg > 0.50? color.green : rsi_avg<0.50 ? color.red : color.yellowplot(rsi_avg,color=culoare )long = rsi_avg > 0.5 and rsi_avg[1]< 0.5longexit = rsi_avg >= input.float(0.65, step=0.05)short = rsi_avg < 0.5 and rsi_avg[1] >0.5shortexit=rsi_avg<=input.float(0.35, step=0.05)if(long_only)    strategy.entry("long",strategy.long,when=long)    strategy.close("long",when=longexit or short)if(short_only)    strategy.entry("short",strategy.short,when=short)    strategy.close("short",when=shortexit or long)