Pine Script v5 · Strategy
Pivot Point Breakout
A Pine Script v5 strategy built on Pivotlow (3, 3) and Pivothigh (3, 3). 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 commits 100% of equity and pays no commission. 7 settings; defaults include Order direction LONG, Left 3 and Right 3.
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 Pivot Point Breakout repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
- How did Pivot Point Breakout do on BTCUSDT 1D with default settings?
- +93.01%
- From 26 Jan 2024 to 21 Oct 2026, over 25 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Pivot Point Breakout 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: 25 before, 25 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 Pivot Point Breakout use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Pivot Point Breakout run in Zeal Terminal?
- Yes
- It compiles in 17 ms and runs 1,000 bars in 38 ms, in the browser.
BTCUSDT · 1D · default settings
- Last pivot low
- Last pivot high
- Pivot low
- Pivot high
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +93.01%
- $930,115.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 25
- 9 won · 16 lost
- Profitable
- 36.0%
- of closed trades
- Profit factor
- 1.72
- gross profit ÷ gross loss
- Max drawdown
- 32.29%
- −$663,151.00
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.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
2 settings have no label
In the settings dialog startDate (line 21), endDate (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 43, 44, 46, 47. 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Order direction | LONG | string · options [BOTH, LONG, SHORT] | entry Long close Short entry Short close Long |
| Pivot high | |||
| Left | 3 | int · min 0 | highPivot |
| Right | 3 | int · min 0 | highPivot plotshape |
| Pivot low | |||
| Left | 3 | int · min 0 | lowPivot |
| Right | 3 | int · min 0 | lowPivot plotshape |
| Date selection | |||
| Start Date (no label in the script) | 0 | time | validTrade |
| End Date (no label in the script) | 0 | time | validTrade |
What it calculates
- PivotlowLeft (3), Right (3)
lowPivot · line 26 - PivothighLeft (3), Right (3)
highPivot · line 27
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 | orderDirection != SHORT and validTrade | On | 43 |
| Close Short | orderDirection == SHORT | On | 44 |
| Open Short short | orderDirection != LONG and validTrade | On | 46 |
| Close Long | orderDirection == LONG | On | 47 |
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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.
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 | +93.0% | +102.5% | 25 | 36% | 1.72 | 32.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +2.3% | +5.5% | 25 | 24% | 1.07 | 10.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +15.1% | +9.8% | 25 | 36% | 1.10 | 50.1% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +12.4% | +8.4% | 21 | 33% | 1.34 | 15.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +25.1% | +16.7% | 24 | 46% | 1.12 | 61.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +13.9% | +21.5% | 25 | 32% | 1.31 | 16.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +28.7% | +148.3% | 23 | 39% | 1.22 | 43.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +19.1% | +17.1% | 23 | 48% | 1.97 | 6.3% | 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 | 8 | 38% | −$227,589.00 |
| Sideways market | 12 | 33% | $770,129.00 |
| Falling market | 5 | 40% | $387,575.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
39.6%
The 95th percentile of the worst drawdown when the same 25 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 18.3% to 39.6%; the tick is what actually happened, 28.7%. Order luck alone moves it this much.
All 25 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 7 Feb 2024 44,349.60 | 13 Apr 2024 63,924.50 | 66 | $441,377.00 |
| long | 6 May 2024 63,165.20 | 11 Jun 2024 67,314.20 | 36 | $94,677.90 |
| long | 15 Jul 2024 64,724.10 | 1 Aug 2024 65,354.00 | 17 | $14,948.50 |
| long | 23 Aug 2024 64,037.20 | 4 Sep 2024 57,970.90 | 12 | −$146,929.00 |
| long | 13 Sep 2024 60,498.00 | 10 Oct 2024 60,326.40 | 27 | −$3,982.83 |
| long | 14 Oct 2024 66,084.00 | 5 Dec 2024 96,945.60 | 52 | $653,852.00 |
| long | 6 Dec 2024 99,740.80 | 20 Dec 2024 97,805.40 | 14 | −$39,855.30 |
| long | 6 Jan 2025 102,236.00 | 9 Jan 2025 92,552.50 | 3 | −$190,762.00 |
| long | 17 Jan 2025 104,077.00 | 27 Jan 2025 102,083.00 | 10 | −$34,944.10 |
| long | 21 Feb 2025 96,182.00 | 24 Feb 2025 91,552.90 | 3 | −$86,072.30 |
| long | 19 Mar 2025 86,845.90 | 6 Apr 2025 78,430.00 | 18 | −$164,965.00 |
| long | 21 Apr 2025 87,516.20 | 29 May 2025 105,590.00 | 38 | $317,487.00 |
| long | 9 Jun 2025 110,263.00 | 20 Jun 2025 103,298.00 | 11 | −$117,165.00 |
| long | 2 Jul 2025 108,850.00 | 25 Jul 2025 117,614.00 | 23 | $139,919.00 |
| long | 11 Aug 2025 118,686.00 | 22 Aug 2025 116,936.00 | 11 | −$27,684.80 |
| long | 10 Sep 2025 113,960.00 | 22 Sep 2025 112,651.00 | 12 | −$21,249.00 |
| long | 1 Oct 2025 118,595.00 | 10 Oct 2025 112,775.00 | 9 | −$89,747.90 |
| long | 26 Oct 2025 114,559.00 | 3 Nov 2025 106,583.00 | 8 | −$121,074.00 |
| long | 3 Dec 2025 93,429.90 | 14 Dec 2025 88,172.20 | 11 | −$91,043.60 |
| long | 2 Jan 2026 89,995.10 | 20 Jan 2026 88,427.70 | 18 | −$26,592.50 |
| long | 25 Feb 2026 67,988.00 | 27 Mar 2026 66,407.30 | 30 | −$34,880.40 |
| long | 6 Apr 2026 68,853.70 | 13 May 2026 79,313.60 | 37 | $222,604.00 |
| long | 14 Jul 2026 65,044.00 | 1 Sep 2026 77,439.00 | 49 | $321,656.00 |
| long | 3 Sep 2026 81,270.40 | 11 Sep 2026 77,225.70 | 8 | −$100,013.00 |
| long | 18 Sep 2026 80,883.90 | 8 Oct 2026 81,754.40 | 20 | $20,553.30 |
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 |
|---|---|---|---|---|---|
| Pivot Point Breakout this page | — | 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 | ||
| RSI Centered Pivots by OztheWoz | pivotlow pivothigh | v4 strategy | +98.0% | 4 | 160.2% |
| ABCD Strategy by kerok3g | pivothigh pivotlow | v5 strategy | −2.7% | 4 | 3.0% |
| Steven Primo's bollinger bands strategy by EduardoMattje | pivothigh pivotlow | v5 strategy | −17.7% | 15 | 28.2% |
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 43, 44, 46, 47). 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.
Same 25 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 43: when = orderDirection != SHORT and validTrade → if block
- Line 44: when = orderDirection == SHORT → if block
- Line 46: when = orderDirection != LONG and validTrade → if block
- Line 47: when = orderDirection == LONG → if block
⋯if high > lastHigh- strategy.entry("Long", strategy.long, when=orderDirection != SHORT and validTrade)+ if orderDirection != SHORT and validTrade+ strategy.entry("Long", strategy.long)- strategy.close("Short", when=orderDirection == SHORT)+ if orderDirection == SHORT+ strategy.close("Short")if low < lastLow- strategy.entry("Short", strategy.short, when=orderDirection != LONG and validTrade)+ if orderDirection != LONG and validTrade+ strategy.entry("Short", strategy.short)- strategy.close("Long", when=orderDirection == LONG)+ if orderDirection == LONG+ strategy.close("Long") ⋯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: 25 before, 25 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.
⋯// © EduardoMattje-//@version=5+//@version=6strategy("Pivot Point Breakout", "PPB", true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | With a workaround 1,000 bars in 38 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/// © EduardoMattje//@version=5strategy("Pivot Point Breakout", "PPB", true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true)// Constantsvar L_PIVOT_HIGH = "Pivot high"var L_PIVOT_LOW = "Pivot low"var LEFT = "Left"var RIGHT = "Right"var BOTH = "Both"var LONG = "Long"var SHORT = "Short"var DATES = "Date selection"var DATES_TOOLTIP = "Change it to limit the trades for the given time interval.\n\nLeave it to disable this behaviour."// Inputsvar orderDirection = input.string(LONG, "Order direction", options=[BOTH, LONG, SHORT])var leftHigh = input.int(3, LEFT, minval=0, inline=L_PIVOT_HIGH, group=L_PIVOT_HIGH)var rightHigh = input.int(3, RIGHT, minval=0, inline=L_PIVOT_HIGH, group=L_PIVOT_HIGH)var leftLow = input.int(3, LEFT, minval=0, inline=L_PIVOT_LOW, group=L_PIVOT_LOW)var rightLow = input.int(3, RIGHT, minval=0, inline=L_PIVOT_LOW, group=L_PIVOT_LOW)var startDate = input.time(0, "Starting date", group=DATES)var endDate = input.time(0, "Final date", group=DATES)//var float lastHigh = navar float lastLow = nalowPivot = ta.pivotlow(leftLow, rightLow)highPivot = ta.pivothigh(leftHigh, rightHigh)f_updateLevels(pivot_) => var float pastLevel = na if not na(pivot_) pastLevel := pivot_ pastLevel lastLow := f_updateLevels(lowPivot)lastHigh := f_updateLevels(highPivot)// Validates the time intervalvalidTrade = (startDate == 0 ? true : time >= startDate) and (endDate == 0 ? true : time <= endDate)// Ordersif high > lastHigh strategy.entry("Long", strategy.long, when=orderDirection != SHORT and validTrade) strategy.close("Short", when=orderDirection == SHORT)if low < lastLow strategy.entry("Short", strategy.short, when=orderDirection != LONG and validTrade) strategy.close("Long", when=orderDirection == LONG) // Plotsplot(lastLow, "Last pivot low", color.red, offset=1)plot(lastHigh, "Last pivot high", color.teal, offset=1)plotshape(lowPivot, "Pivot low", location=location.belowbar, color=color.red, offset=-rightLow)plotshape(highPivot, "Pivot high", color=color.teal, offset=-rightHigh)