Pine Script v4 · Strategy
RSI Centered Pivots
A Pine Script v4 strategy built on RSI (close, 19), Pivotlow (rsi, 2) and Pivothigh (rsi, 2). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade is one contract and pays 0.1% commission. 1 setting; defaults include Length 19.
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 Centered Pivots 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 Centered Pivots do on BTCUSDT 1D with default settings?
- +98.02%
- From 26 Jan 2024 to 21 Oct 2026, over 4 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can RSI Centered Pivots 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 RSI Centered Pivots use a stop loss?
- Yes
- strategy.exit sets a stop on line 17.
- Does RSI Centered Pivots run in Zeal Terminal?
- Yes
- It compiles in 8 ms and runs 1,000 bars in 22 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- HLine
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +98.02%
- $9,802.23
- Buy and hold
- +102.5%
- same period
- Closed trades
- 4
- 2 won · 2 lost
- Profitable
- 50.0%
- of closed trades
- Profit factor
- 1.75
- gross profit ÷ gross loss
- Max drawdown
- 160.20%
- −$32,878.40
One run with the author's default settings, $10,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.
-
Note
Uses an argument v6 removed
when = on line 14, 15. 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 rsi → ta.rsi, pivotlow → ta.pivotlow, pivothigh → ta.pivothigh.
- 2 strategy calls use the when = argument (line 14, 15). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 4 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: rsi → ta.rsi
- Line 8: pivotlow → ta.pivotlow
- Line 9: pivothigh → ta.pivothigh
- Line 14: strategy.entry(…, true) → strategy.entry(…, strategy.long)
⋯// © OztheWoz-//@version=4+//@version=5strategy("RSI Fractals", initial_capital=10000, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)⋯len = input(19, "Length")-rsi = rsi(close, len)+rsi = ta.rsi(close, len)-fractup = pivotlow(rsi, 2, 2)+fractup = ta.pivotlow(rsi, 2, 2)-fractdn = pivothigh(rsi, 2, 2)+fractdn = ta.pivothigh(rsi, 2, 2)plot(rsi)⋯plotshape(fractup, style=shape.triangleup, location=location.bottom, color=color.green, offset=-2)-strategy.entry("Long", true, 1, when=fractup)+strategy.entry("Long", strategy.long, 1, when=fractup)strategy.close("Long", when=(rsi >= 80))⋯Same 4 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 14: when = fractup → if block
- Line 15: when = (rsi >= 80) → if block
⋯// study("RSI Fractals")-len = input(19, "Length")+len = input.int(19, "Length")rsi = ta.rsi(close, len)⋯plotshape(fractup, style=shape.triangleup, location=location.bottom, color=color.green, offset=-2)-strategy.entry("Long", strategy.long, 1, when=fractup)+if fractup+ strategy.entry("Long", strategy.long, 1)-strategy.close("Long", when=(rsi >= 80))+if (rsi >= 80)+ strategy.close("Long")stoploss = close[1] - (close[1] * 0.5/100)⋯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: 4 before, 0 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.
⋯// © OztheWoz-//@version=5+//@version=6strategy("RSI Fractals", initial_capital=10000, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)⋯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 |
|---|---|---|---|
| Length | 19 | int | rsi |
What it calculates
- RSI (
rsi,ta.rsiin v5)close, Length (19)rsi · line 7 - Pivotlow (
pivotlow,ta.pivotlowin v5)rsi, 2, 2fractup · line 8 - Pivothigh (
pivothigh,ta.pivothighin v5)rsi, 2, 2fractdn · line 9
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 | fractup | On | 14 |
| Close Long | (rsi >= 80) | On | 15 |
| Exit Long stop | every bar | 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.
- 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 | +98.0% | +102.5% | 4 | 50% | 1.75 | 160.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −61.0% | +5.5% | 3 | 33% | 0.59 | 240.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −9.4% | +9.8% | 6 | 83% | 0.23 | 21.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −2.6% | +8.4% | 1 | 0% | 0.00 | 8.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.3% | +16.7% | 2 | 50% | 0.72 | 1.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.1% | +21.5% | 3 | 33% | 0.11 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +3.8% | +148.3% | 4 | 75% | 6.73 | 2.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.1% | +17.1% | 3 | 67% | 1.14 | 1.6% | 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 | 4 | 50% | $9,882.48 |
| Sideways market | 0 | — | $0.00 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
42.0%
The 95th percentile of the worst drawdown when the same 4 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 38.4% to 42.0%; the tick is what actually happened, 38.4%. Order luck alone moves it this much.
All 4 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 17 Feb 2024 52,124.10 | 18 Feb 2024 51,642.60 | 1 | −$585.29 |
| long | 26 Feb 2024 51,728.90 | 27 Feb 2024 54,476.40 | 1 | $2,641.36 |
| long | 5 Mar 2024 68,245.70 | 12 Nov 2024 88,648.00 | 252 | $20,245.30 |
| long | 17 Nov 2024 90,588.00 | 22 Aug 2026 78,338.00 | 643 | −$12,418.90 |
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 |
|---|---|---|---|---|---|
| RSI Centered Pivots this page | — | v4 strategy | +98.0% | 4 | 160.2% |
| RSI5_50 with Divergence by mohanee | rsi pivotlow pivothigh | v4 strategy | +443.3% | 25 | 411.3% |
| RSI Divergence X Ichimoku Cloud X 200EMA by tradethrills | rsi pivotlow pivothigh | v4 strategy | −196,793.0% | 7 | 1,854.6% |
| Pivot Point Breakout by EduardoMattje | pivotlow pivothigh | v5 strategy | +93.0% | 25 | 32.3% |
| Monthly Returns of a Strategy in a Chart by QuantNomad | pivothigh pivotlow | v5 strategy | +21.0% | 76 | 13.0% |
| ZigZag by Zeal Terminal | pivothigh pivotlow | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 8 ms | With a workaround 1,000 bars in 22 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 14) 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/// © OztheWoz//@version=4strategy("RSI Fractals", initial_capital=10000, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)// study("RSI Fractals")len = input(19, "Length")rsi = rsi(close, len)fractup = pivotlow(rsi, 2, 2)fractdn = pivothigh(rsi, 2, 2)plot(rsi)hline(80, color=color.gray)hline(20, color=color.gray)plotshape(fractup, style=shape.triangleup, location=location.bottom, color=color.green, offset=-2)strategy.entry("Long", true, 1, when=fractup)strategy.close("Long", when=(rsi >= 80))stoploss = close[1] - (close[1] * 0.5/100)strategy.exit("Long", "Exit Long", stop=stoploss)// alertcondition(fractup, "RSI Fractal Up", "RSI Fractal V \nExpect Reversal Bearish")// alertcondition(fractdn, "RSI Fractal Down", "RSI Fractal ^ \nExpect Reversal Bullish")// alertcondition((rsi >= 80), "RSI Overbought", "RSI Overbought \nSell Before Bearish Reversal")// alertcondition((rsi <= 20), "RSI Underbought", "RSI Underbought \nSell Before Bullish Reversal")