Pine Script v5 · Strategy
Hobbiecode - SP500 IBS + Higher
A Pine Script v5 strategy with no technical-analysis calculation. 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 - SP500 IBS + Higher repaint?
- Yes
- In a live replay, it did not match history on 4 of 11 trades, and it produced 7 trades that history does not have.
- How did Hobbiecode - SP500 IBS + Higher do on BTCUSDT 1D with default settings?
- +0.47%
- From 26 Jan 2024 to 21 Oct 2026, over 34 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Hobbiecode - SP500 IBS + Higher 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: 34 before, 24 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 - SP500 IBS + Higher use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Hobbiecode - SP500 IBS + Higher run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 22 ms, in the browser.
BTCUSDT · 1D · default settings
- Close
- Previous Friday Close
- Enter
- Exit
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.47%
- $4,728.69
- Buy and hold
- +102.5%
- same period
- Closed trades
- 34
- 22 won · 12 lost
- Profitable
- 64.7%
- of closed trades
- Profit factor
- 1.09
- gross profit ÷ gross loss
- Max drawdown
- 1.94%
- −$19,578.70
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
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
No technical-analysis calculation: the script works on prices and settings directly.
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 | enterCondition | On | 22 |
| Close Buy | exitCondition | On | 25 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
The live replay did not match history.
- ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
- 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 | +0.5% | +102.5% | 34 | 65% | 1.09 | 1.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.2% | +5.5% | 19 | 53% | 0.72 | 0.5% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.1% | +9.8% | 35 | 51% | 0.77 | 0.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 22 | 68% | 3.11 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 38 | 47% | 1.08 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 17 | 59% | 0.54 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 36 | 56% | 1.10 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 20 | 60% | 1.08 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Higher-timeframe data for request.security(): BINANCE:BTCUSDT W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.
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 | 8 | 75% | $16,557.10 |
| Sideways market | 18 | 50% | −$25,125.00 |
| Falling market | 8 | 88% | $13,296.60 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
3.2%
The 95th percentile of the worst drawdown when the same 34 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.4% to 3.2%; the tick is what actually happened, 1.7%. Order luck alone moves it this much.
All 34 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 19 Mar 2024 67,610.00 | 23 Mar 2024 63,796.60 | 4 | −$3,813.36 |
| long | 16 Apr 2024 63,420.00 | 20 Apr 2024 63,818.00 | 4 | $398.02 |
| long | 25 Jun 2024 60,293.30 | 29 Jun 2024 60,427.80 | 4 | $134.54 |
| long | 2 Jul 2024 62,900.00 | 6 Jul 2024 56,628.80 | 4 | −$6,271.21 |
| long | 30 Jul 2024 66,784.70 | 3 Aug 2024 61,498.30 | 4 | −$5,286.34 |
| long | 1 Oct 2024 63,327.60 | 5 Oct 2024 62,086.00 | 4 | −$1,241.60 |
| long | 8 Oct 2024 62,224.00 | 12 Oct 2024 62,540.00 | 4 | $315.98 |
| long | 5 Nov 2024 67,850.00 | 7 Nov 2024 75,572.00 | 2 | $7,721.98 |
| long | 3 Dec 2024 95,840.60 | 5 Dec 2024 98,587.30 | 2 | $2,746.71 |
| long | 31 Dec 2024 92,792.10 | 3 Jan 2025 96,984.80 | 3 | $4,192.74 |
| long | 18 Feb 2025 95,780.00 | 21 Feb 2025 98,305.00 | 3 | $2,525.00 |
| long | 25 Feb 2025 91,552.90 | 1 Mar 2025 84,349.90 | 4 | −$7,202.93 |
| long | 4 Mar 2025 86,221.20 | 6 Mar 2025 90,606.00 | 2 | $4,384.84 |
| long | 11 Mar 2025 78,595.90 | 13 Mar 2025 83,680.10 | 2 | $5,084.26 |
| long | 1 Apr 2025 82,550.00 | 2 Apr 2025 85,158.40 | 1 | $2,608.35 |
| long | 8 Jul 2025 108,263.00 | 10 Jul 2025 111,234.00 | 2 | $2,971.06 |
| long | 22 Jul 2025 117,380.00 | 23 Jul 2025 119,954.00 | 1 | $2,574.07 |
| long | 26 Aug 2025 110,112.00 | 30 Aug 2025 108,377.00 | 4 | −$1,734.58 |
| long | 23 Sep 2025 112,651.00 | 25 Sep 2025 113,307.00 | 2 | $656.02 |
| long | 4 Nov 2025 106,583.00 | 8 Nov 2025 103,339.00 | 4 | −$3,243.96 |
| long | 18 Nov 2025 92,215.10 | 22 Nov 2025 85,129.40 | 4 | −$7,085.72 |
| long | 2 Dec 2025 86,286.00 | 3 Dec 2025 91,277.90 | 1 | $4,991.87 |
| long | 16 Dec 2025 86,432.10 | 20 Dec 2025 88,136.90 | 4 | $1,704.87 |
| long | 30 Dec 2025 87,237.10 | 3 Jan 2026 89,995.10 | 4 | $2,758.01 |
| long | 13 Jan 2026 91,296.20 | 14 Jan 2026 95,414.00 | 1 | $4,117.79 |
| long | 24 Feb 2026 64,656.00 | 26 Feb 2026 67,988.00 | 2 | $3,332.03 |
| long | 31 Mar 2026 66,797.40 | 1 Apr 2026 68,284.50 | 1 | $1,487.11 |
| long | 26 May 2026 77,322.00 | 30 May 2026 73,460.80 | 4 | −$3,861.23 |
| long | 2 Jun 2026 71,408.90 | 6 Jun 2026 61,056.50 | 4 | −$10,352.40 |
| long | 9 Jun 2026 63,086.00 | 12 Jun 2026 63,626.00 | 3 | $540.00 |
| long | 23 Jun 2026 64,020.00 | 27 Jun 2026 60,097.30 | 4 | −$3,922.74 |
| long | 14 Jul 2026 62,334.50 | 15 Jul 2026 65,044.00 | 1 | $2,709.47 |
| long | 28 Jul 2026 63,755.90 | 31 Jul 2026 64,780.00 | 3 | $1,024.17 |
| long | 13 Oct 2026 81,850.00 | 17 Oct 2026 81,615.90 | 4 | −$234.10 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
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: 34 before, 24 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.
⋯// Sell 5 trading days later (at the close).-//@version=5+//@version=6strategy("Hobbiecode - SP500 IBS + Higher", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | With a workaround 1,000 bars in 22 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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/// © hobbiecode// Today is Monday.// The close must be lower than the close on Friday.// The IBS must be below 0.5.// If 1-3 are true, then enter at the close.// Sell 5 trading days later (at the close).//@version=5strategy("Hobbiecode - SP500 IBS + Higher", overlay=true)// Check if it's MondayisMonday = dayofweek(time) == dayofweek.monday// Calculate the IBS (Intraday Breadth Strength) indicatoribs = (close - low) / (high - low)// Calculate the close on the previous FridayprevFridayClose = request.security(syminfo.tickerid, "W", close[1])// Entry conditionsenterCondition = isMonday and close < prevFridayClose and ibs < 0.5 and strategy.position_size < 1 // Exit conditionsexitCondition = (close > high[1] or ta.barssince(enterCondition) == 4) and strategy.position_size > 0 // Entry signalif enterCondition strategy.entry("Buy", strategy.long)// Exit signalif exitCondition strategy.close("Buy")// Plotting the close, previous Friday's close, and entry/exit points on the chartplot(close, title="Close", color=color.blue)plot(prevFridayClose, title="Previous Friday Close", color=color.orange)plotshape(enterCondition, title="Enter", location=location.belowbar, color=color.green, style=shape.labelup, text="Enter")plotshape(exitCondition, title="Exit", location=location.abovebar, color=color.red, style=shape.labeldown, text="Exit")