Pine Script v5 · Strategy
Hobbiecode - RSI + Close previous day
A Pine Script v5 strategy built on RSI (close, rsi_period). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. It has no settings.
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 Hobbiecode - RSI + Close previous day repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 19 of 19 trades.
- How did Hobbiecode - RSI + Close previous day do on BTCUSDT 1D with default settings?
- +1.18%
- From 26 Jan 2024 to 21 Oct 2026, over 63 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Hobbiecode - RSI + Close previous day 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: 63 before, 58 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 Hobbiecode - RSI + Close previous day use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Hobbiecode - RSI + Close previous day run in Zeal Terminal?
- Yes
- It compiles in 8 ms and runs 1,000 bars in 15 ms, in the browser.
BTCUSDT · 1D · default settings
- RSI
- Oversold Level
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +1.18%
- $11,771.10
- Buy and hold
- +102.5%
- same period
- Closed trades
- 63
- 43 won · 20 lost
- Profitable
- 68.3%
- of closed trades
- Profit factor
- 1.15
- gross profit ÷ gross loss
- Max drawdown
- 4.19%
- −$43,503.20
One run with the author's default settings, $1,000,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
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.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
- RSIclose, rsi_period
rsi_val · line 11
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 Buy long | (rsi_val < rsi_lower) | On | 14 |
| Close Buy | (strategy.position_size > 0 and close > ta.highest(high[1], 1)) | On | 17 |
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 | +1.2% | +102.5% | 63 | 68% | 1.15 | 4.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.2% | +5.5% | 58 | 71% | 1.10 | 1.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.1% | +9.8% | 58 | 67% | 1.19 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 56 | 71% | 0.96 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 61 | 57% | 0.68 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 65 | 66% | 1.47 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 65 | 71% | 1.79 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 62 | 65% | 0.93 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 23 | 70% | $31,042.20 |
| Sideways market | 24 | 58% | −$14,551.10 |
| Falling market | 16 | 81% | −$4,720.11 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
4.1%
The 95th percentile of the worst drawdown when the same 63 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.8% to 4.1%; the tick is what actually happened, 3.5%. Order luck alone moves it this much.
All 63 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 24 Feb 2024 50,744.20 | 25 Feb 2024 51,568.20 | 1 | $824.06 |
| long | 17 Mar 2024 65,300.60 | 25 Mar 2024 67,210.00 | 8 | $1,909.36 |
| long | 3 Apr 2024 65,464.00 | 5 Apr 2024 68,487.80 | 2 | $3,023.81 |
| long | 13 Apr 2024 67,116.50 | 23 Apr 2024 66,819.30 | 10 | −$297.20 |
| long | 28 Apr 2024 63,462.00 | 4 May 2024 62,882.00 | 6 | −$579.97 |
| long | 9 May 2024 61,193.00 | 10 May 2024 63,074.00 | 1 | $1,880.97 |
| long | 12 Jun 2024 67,314.20 | 17 Jun 2024 66,676.90 | 5 | −$637.37 |
| long | 19 Jun 2024 65,175.30 | 1 Jul 2024 62,772.00 | 12 | −$2,403.31 |
| long | 4 Jul 2024 60,208.60 | 7 Jul 2024 58,230.10 | 3 | −$1,978.44 |
| long | 25 Jul 2024 65,376.00 | 27 Jul 2024 67,908.00 | 2 | $2,531.99 |
| long | 31 Jul 2024 66,188.00 | 9 Aug 2024 61,686.00 | 9 | −$4,502.00 |
| long | 28 Aug 2024 59,415.00 | 3 Sep 2024 59,132.10 | 6 | −$282.88 |
| long | 7 Sep 2024 53,963.00 | 9 Sep 2024 54,869.90 | 2 | $906.98 |
| long | 1 Oct 2024 63,327.60 | 5 Oct 2024 62,086.00 | 4 | −$1,241.60 |
| long | 10 Oct 2024 60,636.00 | 12 Oct 2024 62,540.00 | 2 | $1,903.98 |
| long | 24 Oct 2024 66,668.60 | 25 Oct 2024 68,198.30 | 1 | $1,529.62 |
| long | 4 Nov 2024 68,776.00 | 7 Nov 2024 75,572.00 | 3 | $6,796.00 |
| long | 26 Nov 2024 93,010.00 | 28 Nov 2024 95,863.10 | 2 | $2,853.10 |
| long | 19 Dec 2024 100,204.00 | 25 Dec 2024 98,663.60 | 6 | −$1,540.43 |
| long | 31 Dec 2024 92,792.10 | 3 Jan 2025 96,984.80 | 3 | $4,192.74 |
| long | 10 Jan 2025 92,552.50 | 15 Jan 2025 96,560.90 | 5 | $4,008.36 |
| long | 27 Jan 2025 102,620.00 | 11 Feb 2025 97,430.80 | 15 | −$5,189.19 |
| long | 18 Feb 2025 95,780.00 | 21 Feb 2025 98,305.00 | 3 | $2,525.00 |
| long | 25 Feb 2025 91,552.90 | 2 Mar 2025 86,064.50 | 5 | −$5,488.34 |
| long | 10 Mar 2025 80,734.50 | 13 Mar 2025 83,680.10 | 3 | $2,945.64 |
| long | 29 Mar 2025 84,424.40 | 2 Apr 2025 85,158.40 | 4 | $733.97 |
| long | 7 Apr 2025 78,430.00 | 10 Apr 2025 82,615.20 | 3 | $4,185.22 |
| long | 30 May 2025 105,590.00 | 2 Jun 2025 105,643.00 | 3 | $53.18 |
| long | 6 Jun 2025 101,509.00 | 8 Jun 2025 105,552.00 | 2 | $4,043.46 |
| long | 13 Jun 2025 105,672.00 | 17 Jun 2025 106,795.00 | 4 | $1,122.79 |
| long | 21 Jun 2025 103,298.00 | 24 Jun 2025 105,334.00 | 3 | $2,035.96 |
| long | 2 Jul 2025 105,681.00 | 3 Jul 2025 108,850.00 | 1 | $3,168.46 |
| long | 21 Jul 2025 117,265.00 | 23 Jul 2025 119,954.00 | 2 | $2,689.32 |
| long | 1 Aug 2025 115,764.00 | 4 Aug 2025 114,209.00 | 3 | −$1,555.26 |
| long | 19 Aug 2025 116,227.00 | 23 Aug 2025 116,936.00 | 4 | $708.95 |
| long | 26 Aug 2025 110,112.00 | 3 Sep 2025 111,240.00 | 8 | $1,128.03 |
| long | 23 Sep 2025 112,651.00 | 25 Sep 2025 113,307.00 | 2 | $656.02 |
| long | 26 Sep 2025 108,994.00 | 29 Sep 2025 112,164.00 | 3 | $3,169.47 |
| long | 11 Oct 2025 112,774.00 | 13 Oct 2025 114,959.00 | 2 | $2,184.32 |
| long | 16 Oct 2025 110,763.00 | 20 Oct 2025 108,643.00 | 4 | −$2,120.51 |
| long | 30 Oct 2025 110,021.00 | 10 Nov 2025 104,723.00 | 11 | −$5,298.35 |
| long | 14 Nov 2025 99,692.00 | 24 Nov 2025 86,830.00 | 10 | −$12,862.00 |
| long | 2 Dec 2025 86,286.00 | 3 Dec 2025 91,277.90 | 1 | $4,991.87 |
| long | 15 Dec 2025 88,172.20 | 22 Dec 2025 88,658.90 | 7 | $486.71 |
| long | 10 Jan 2026 90,641.30 | 12 Jan 2026 91,013.70 | 2 | $372.39 |
| long | 19 Jan 2026 93,673.10 | 28 Jan 2026 89,250.00 | 9 | −$4,423.15 |
| long | 30 Jan 2026 84,650.20 | 14 Feb 2026 68,854.00 | 15 | −$15,796.20 |
| long | 19 Feb 2026 66,461.00 | 21 Feb 2026 68,020.00 | 2 | $1,559.00 |
| long | 24 Feb 2026 64,656.00 | 26 Feb 2026 67,988.00 | 2 | $3,332.03 |
| long | 9 Mar 2026 65,971.20 | 10 Mar 2026 68,432.20 | 1 | $2,460.96 |
| long | 20 Mar 2026 69,930.00 | 24 Mar 2026 70,906.40 | 4 | $976.44 |
| long | 28 Mar 2026 66,407.30 | 1 Apr 2026 68,284.50 | 4 | $1,877.21 |
| long | 30 Apr 2026 75,780.00 | 2 May 2026 78,231.10 | 2 | $2,451.13 |
| long | 14 May 2026 79,313.60 | 21 May 2026 77,552.20 | 7 | −$1,761.37 |
| long | 23 May 2026 75,539.50 | 8 Jun 2026 63,332.00 | 16 | −$12,207.50 |
| long | 19 Jun 2026 62,958.00 | 21 Jun 2026 64,298.00 | 2 | $1,340.00 |
| long | 25 Jun 2026 61,078.00 | 3 Jul 2026 61,560.00 | 8 | $482.00 |
| long | 14 Jul 2026 62,334.50 | 15 Jul 2026 65,044.00 | 1 | $2,709.47 |
| long | 25 Jul 2026 64,140.00 | 27 Jul 2026 65,400.00 | 2 | $1,260.00 |
| long | 11 Aug 2026 63,970.00 | 18 Aug 2026 64,532.10 | 7 | $562.10 |
| long | 10 Sep 2026 78,306.40 | 15 Sep 2026 78,189.20 | 5 | −$117.23 |
| long | 29 Sep 2026 83,500.00 | 5 Oct 2026 86,530.00 | 6 | $3,029.99 |
| long | 8 Oct 2026 83,321.80 | 12 Oct 2026 83,773.10 | 4 | $451.31 |
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 |
|---|---|---|---|---|---|
| Hobbiecode - RSI + Close previous day this page | — | v5 strategy | +1.2% | 63 | 4.2% |
| Triple RSI strategy by Trade_by_DB | rsi | v5 strategy | +3.2% | 2 | 3.3% |
| dirt cheap yet elegant RSI Strategy by SparkyFlary | rsi | v4 strategy | −11.4% | 8 | 20.5% |
| RSI Classic Strategy (by Coinrule) by Coinrule | rsi | v4 strategy | +7.5% | 6 | 7.2% |
| RSITrendStrategy by email_analysts | rsi | v4 strategy | +69.2% | 22 | 38.6% |
| Cheat Code- Example 1; Short-Term; Follow the Trend by CheatCode1 | rsi | v5 strategy | −1.0% | 2 | 5.7% |
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.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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: 63 before, 58 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.
⋯// Exit on close if today’s close is higher than yesterday’s high.-//@version=5+//@version=6strategy("Hobbiecode - RSI + Close previous day", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 8 ms | Yes 1,000 bars in 15 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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/// © hobbiecode// If RSI(2) is less than 15, then enter at the close.// Exit on close if today’s close is higher than yesterday’s high.//@version=5strategy("Hobbiecode - RSI + Close previous day", overlay=true)// RSI parametersrsi_period = 2rsi_lower = 15// Calculate RSIrsi_val = ta.rsi(close, rsi_period)// Check if RSI is lower than the defined thresholdif (rsi_val < rsi_lower) strategy.entry("Buy", strategy.long)// Check if today's close is higher than yesterday's highif (strategy.position_size > 0 and close > ta.highest(high[1], 1)) strategy.close("Buy")// Plot RSI on chartplot(rsi_val, title="RSI", color=color.red)hline(rsi_lower, title="Oversold Level", color=color.blue)