Pine Script v4 · Strategy
Bottom catch strategy
A Pine Script v4 strategy built on SMA (v, 20), Stdev (v, 20) and RSI (close, 20). 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. 5 settings; defaults include Volume SMA Length 20, Mult 2 and RSI Length 20.
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 Bottom catch strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
- How did Bottom catch strategy do on BTCUSDT 1D with default settings?
- +3.90%
- From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Bottom catch 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 Bottom catch strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Bottom catch strategy run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 25 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- Stdev
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +3.90%
- $3,898.47
- Buy and hold
- +102.5%
- same period
- Closed trades
- 3
- 2 won · 1 lost
- Profitable
- 66.7%
- of closed trades
- Profit factor
- 2.23
- gross profit ÷ gross loss
- Max drawdown
- 7.13%
- −$7,629.93
One run with the author's default settings, $100,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
1 setting has no label
In the settings dialog mult (line 6) shows 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 16. The upgraded version below moves each call inside an if block.
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 sma → ta.sma, stdev → ta.stdev, rsi → ta.rsi.
- 1 strategy call uses the when = argument (line 16). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 11: sma → ta.sma
- Line 12: stdev → ta.stdev
- Line 14: rsi → ta.rsi
- Line 16: strategy.entry(…, true) → strategy.entry(…, strategy.long)
⋯// © footlz-//@version=4+//@version=5strategy("Bottom catch strategy", overlay=true)⋯v = volume-basis = sma(v, v_len)+basis = ta.sma(v, v_len)-dev = mult * stdev(v, v_len)+dev = mult * ta.stdev(v, v_len)upper_volume = basis + dev-rsi = rsi(close, rsi_len)+rsi = ta.rsi(close, rsi_len)long = v > upper_volume and rsi < oversold-strategy.entry("Long", true, when=long)+strategy.entry("Long", strategy.long, when=long)passed_time = 0.0⋯Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 16: when = long → if block
⋯strategy("Bottom catch strategy", overlay=true)-v_len = input(20, title="Volume SMA Length")+v_len = input.int(20, title="Volume SMA Length")-mult = input(2)+mult = input.int(2)-rsi_len = input(20, title="RSI Length")+rsi_len = input.int(20, title="RSI Length")-oversold = input(30, title="Oversold")+oversold = input.int(30, title="Oversold")-close_time = input(10, title="Close After")+close_time = input.int(10, title="Close After")v = volume⋯long = v > upper_volume and rsi < oversold-strategy.entry("Long", strategy.long, when=long)+if long+ strategy.entry("Long", strategy.long)passed_time = 0.0⋯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: 3 before, 2 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.
⋯// © footlz-//@version=5+//@version=6strategy("Bottom catch strategy", overlay=true)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Volume SMA Length | 20 | int | basis dev |
| Mult (no label in the script) | 2 | int | dev |
| RSI Length | 20 | int | rsi |
| Oversold | 30 | int | long |
| Close After | 10 | int | close_all line 24 |
What it calculates
- SMA (
sma,ta.smain v5)v, Volume SMA Length (20)basis · line 11 - Stdev (
stdev,ta.stdevin v5)v, Volume SMA Length (20)dev · line 12 - RSI (
rsi,ta.rsiin v5)close, RSI Length (20)rsi · line 14
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 Long long | longv > upper_volume and rsi < oversold | On | 16 |
| Close | passed_time >= close_time | On | 25 |
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 | +3.9% | +102.5% | 3 | 67% | 2.23 | 7.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −6.5% | +5.5% | 5 | 40% | 0.24 | 9.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.4% | +9.8% | 3 | 33% | 0.29 | 0.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 6 | 67% | 0.98 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 2 | 50% | 2.93 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 3 | 33% | 0.13 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 1 | 0% | 0.00 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 2 | 100% | — | 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 | 0 | — | $0.00 |
| Sideways market | 1 | 0% | −$3,180.84 |
| Falling market | 2 | 100% | $7,079.31 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
3.0%
The 95th percentile of the worst drawdown when the same 3 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 3.0% to 3.0%; the tick is what actually happened, 3.0%. Order luck alone moves it this much.
All 3 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 22 Nov 2025 85,129.40 | 2 Dec 2025 86,286.00 | 10 | $1,156.59 |
| long | 6 Feb 2026 62,909.90 | 16 Feb 2026 68,832.60 | 10 | $5,922.72 |
| long | 3 Jun 2026 66,760.80 | 13 Jun 2026 63,580.00 | 10 | −$3,180.84 |
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 |
|---|---|---|---|---|---|
| Bottom catch strategy this page | — | v4 strategy | +3.9% | 3 | 7.1% |
| Madri by Mdemoio | rsi sma stdev | v4 strategy | +25.0% | 4 | 36.4% |
| Bollinger Bands and RSI Short Selling (by Coinrule) by Coinrule | sma stdev rsi | v5 strategy | +7.6% | 3 | 4.3% |
| Shorting when Bollinger Band Above Price with RSI (by Coinrule) by Coinrule | sma stdev rsi | v5 strategy | No trades on this market | ||
| RSI_Boll-TP-SL by BigCoinHunter | sma stdev rsi | v5 strategy | No trades on this market | ||
| FMC by oliverbadaoui | sma rsi stdev | v4 strategy | +139.5% | 44 | 111.9% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | With a workaround 1,000 bars in 25 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 16) 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/// © footlz//@version=4strategy("Bottom catch strategy", overlay=true)v_len = input(20, title="Volume SMA Length")mult = input(2)rsi_len = input(20, title="RSI Length")oversold = input(30, title="Oversold")close_time = input(10, title="Close After")v = volumebasis = sma(v, v_len)dev = mult * stdev(v, v_len)upper_volume = basis + devrsi = rsi(close, rsi_len)long = v > upper_volume and rsi < oversoldstrategy.entry("Long", true, when=long)passed_time = 0.0if strategy.position_size != 0 passed_time := 1else passed_time := 0if strategy.position_size != 0 and strategy.position_size[1] != 0 passed_time := passed_time[1] + 1if passed_time >= close_time strategy.close_all()// If want to enable plot, change overlay=false.v_color = close >= close[1] ? color.new(#3eb370, 0) : color.new(#e9546b, 0)// plot(v, title="volume", color=v_color, style=plot.style_columns)// plot(upper_volume, title="Threshold", color=color.aqua)