Zeal Terminal Open in Zeal Terminal

Pine Script v3 · Strategy

Legacy

Pivots strategy XN

A Pine Script v3 strategy built on SMA (close, 20) and ATR (10). 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 is one contract and pays no commission. 11 settings; defaults include Pivot Type Daily, Trading Session 0800-1600 and Factor 2.

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 Pivots strategy XN repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data.
How did Pivots strategy XN do on BTCUSDT 1D with default settings?
−5.72%
From 26 Jan 2024 to 21 Oct 2026, over 86 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Pivots strategy XN be converted to Pine Script v5?
Yes
The upgrade takes 2 steps, from v3; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
What alerts does Pivots strategy XN have?
9
Pivot S3 Cross; Pivot S2 Cross; Pivot S1 Cross; Pivot TC Cross; and more.
Does Pivots strategy XN use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • R3
  • R2
  • R1
  • TC
  • PP
  • BC
  • S1
  • S2
  • S3
  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
50,00075,000100,000125,000AprJulOct2025AprJulOct2026AprJulOct$91,257$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 197, 202) so the engine trades the way the script says. 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. The live re-run is not offered here: the script requests BINANCE:BTCUSDT W, which this page cannot load in your browser.
Net profit
−5.72%
−$5,723.82
Buy and hold
+102.5%
same period
Closed trades
86
28 won · 58 lost
Profitable
32.6%
of closed trades
Profit factor
0.96
gross profit ÷ gross loss
Max drawdown
61.22%
−$69,290.00

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short 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

    2 settings have no label

    In the settings dialog Factor (line 181), Pd (line 182) 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 204, 205. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v3. The upgrade to v5 takes 2 steps, 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 security → request.security, max → math.max, min → math.min, cross → ta.cross, sma → ta.sma, atr → ta.atr.
  • Colours are bare names (orange, red, blue); v4 spells them color.orange, color.red, color.blue.
  • 2 strategy calls use the when = argument (line 204, 205). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v3 → v4

Verified

Same 86 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=3 → //@version=4
  • Line 10: bool → input.bool
  • Line 11: bool → input.bool
  • Line 12: bool → input.bool
  • Line 13: bool → input.bool
  • Line 14: bool → input.bool
19 more edits
  • Line 16: session → input.session
  • Line 17: bool → input.bool
  • Line 19: bool → input.bool
  • Line 23: tickerid → syminfo.tickerid
  • Line 35: period → timeframe.period
  • Line 90: circles → plot.style_circles
  • Line 92: circles → plot.style_circles
  • Line 94: circles → plot.style_circles
  • Line 96: circles → plot.style_circles
  • Line 98: circles → plot.style_circles
  • Line 100: circles → plot.style_circles
  • Line 102: circles → plot.style_circles
  • Line 104: circles → plot.style_circles
  • Line 106: circles → plot.style_circles
  • Line 111: monday → dayofweek.monday
  • Line 147: orange → color.orange
  • Line 180: red → color.red
  • Line 181: float → input.float
  • Line 192: blue → color.blue
⋯// © amysojexson-//@version=3+//@version=4strategy(title="Pivots strategy", overlay=true)⋯// Make toggles for pivot level options-plotPP   = input(title="Plot PP", type=bool, defval=true)+plotPP   = input(title="Plot PP", type=input.bool, defval=true)-plotS1R1 = input(title="Plot S1 and R1", type=bool, defval=true)+plotS1R1 = input(title="Plot S1 and R1", type=input.bool, defval=true)-plotS2R2 = input(title="Plot S2 and R2", type=bool, defval=true)+plotS2R2 = input(title="Plot S2 and R2", type=input.bool, defval=true)-plotS3R3 = input(title="Plot S3 and R3", type=bool, defval=true)+plotS3R3 = input(title="Plot S3 and R3", type=input.bool, defval=true)-plotTCBC = input(title="Plot S3 and R3", type=bool, defval=true)+plotTCBC = input(title="Plot S3 and R3", type=input.bool, defval=true)// Configure session options-sessRange = input(title="Trading Session", type=session, defval="0800-1600")+sessRange = input(title="Trading Session", type=input.session, defval="0800-1600")-showSess  = input(title="Highlight Session?", type=bool, defval=false)+showSess  = input(title="Highlight Session?", type=input.bool, defval=false)// Enable or disable pivot labels-showLabels = input(title="Show Labels?", type=bool, defval=false)+showLabels = input(title="Show Labels?", type=input.bool, defval=false)// Step 2. Calculate indicator values⋯GetData(res, data) =>-    security(tickerid, res, data[1],+    security(syminfo.tickerid, res, data[1],         lookahead=barmerge.lookahead_on)⋯// the session time range-inSession = not na(time(period, sessRange)[1])+inSession = not na(time(timeframe.period, sessRange)[1])sessStart = inSession and not inSession[1]⋯plot(series=plotS3R3 ? r3 : na, title="R3",-     style=circles, linewidth=1, color=#0023FF)+     style=plot.style_circles, linewidth=1, color=#0023FF)plot(series=plotS2R2 ? r2 : na, title="R2",-     style=circles, linewidth=1, color=#1E90FF)+     style=plot.style_circles, linewidth=1, color=#1E90FF)plot(series=plotS1R1 ? r1 : na, title="R1",-     style=circles, linewidth=1, color=#09E0F3)+     style=plot.style_circles, linewidth=1, color=#09E0F3)plot(series=plotTCBC ? tc : na, title="TC",-     style=circles, linewidth=.75, color=#FF00D1)+     style=plot.style_circles, linewidth=.75, color=#FF00D1)plot(series=plotPP ? pp : na, title="PP",-     style=circles, linewidth=1, color=#000000)+     style=plot.style_circles, linewidth=1, color=#000000)plot(series=plotTCBC ? bc : na, title="BC",-     style=circles, linewidth=.75, color=#FF00D1)+     style=plot.style_circles, linewidth=.75, color=#FF00D1)plot(series=plotS1R1 ? s1 : na, title="S1",-     style=circles, linewidth=1, color=#09E0F3)+     style=plot.style_circles, linewidth=1, color=#09E0F3)plot(series=plotS2R2 ? s2 : na, title="S2",-     style=circles, linewidth=1, color=#1E90FF)+     style=plot.style_circles, linewidth=1, color=#1E90FF)plot(series=plotS3R3 ? s3 : na, title="S3",-     style=circles, linewidth=1, color=#0023FF)+     style=plot.style_circles, linewidth=1, color=#0023FF)// Display the pivot names on the chart, if applicable⋯     (pivotType == "Daily") ? dayofmonth != dayofmonth[1] :-     dayofweek == monday and dayofmonth != dayofmonth[1]+     dayofweek == dayofweek.monday and dayofmonth != dayofmonth[1]plotchar(series=newPivots and plotS3R3 ? r3 : na,⋯bgcolor(color=showSess and inSession and (pivotType == "Intraday") ?-     orange : na, transp=95)+     color.orange : na, transp=95)// Step 4. Create indicator alerts⋯MA = sma(close, 20)-plot(MA, color=red)+plot(MA, color=color.red)-Factor                   = input(2, type=float)+Factor                   = input(2, type=input.float)Pd                       = input(10, minval=1,maxval = 100)⋯Tsl                 = Trend==1? TrendUp: TrendDown-plot(Tsl, color=blue)+plot(Tsl, color=color.blue)if close>open⋯

v4 → v5

Verified

Same 86 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 10: input(type = input.bool) → input.bool()
  • Line 11: input(type = input.bool) → input.bool()
  • Line 12: input(type = input.bool) → input.bool()
  • Line 13: input(type = input.bool) → input.bool()
  • Line 14: input(type = input.bool) → input.bool()
24 more edits
  • Line 16: input(type = input.session) → input.session()
  • Line 17: input(type = input.bool) → input.bool()
  • Line 19: input(type = input.bool) → input.bool()
  • Line 23: security → request.security
  • Line 43: max → math.max
  • Line 45: min → math.min
  • Line 146: transp = 95 → color.new(showSess and inSession and (pivotType == "Intraday") ? color.orange : na, 95)
  • Line 149: cross → ta.cross
  • Line 152: cross → ta.cross
  • Line 155: cross → ta.cross
  • Line 159: cross → ta.cross
  • Line 162: cross → ta.cross
  • Line 166: cross → ta.cross
  • Line 169: cross → ta.cross
  • Line 172: cross → ta.cross
  • Line 175: cross → ta.cross
  • Line 179: sma → ta.sma
  • Line 181: input(type = input.float) → input.float()
  • Line 183: atr → ta.atr
  • Line 184: atr → ta.atr
  • Line 186: max → math.max
  • Line 188: min → math.min
  • Line 197: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 202: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// © amysojexson-//@version=4+//@version=5strategy(title="Pivots strategy", overlay=true)⋯// Make toggles for pivot level options-plotPP   = input(title="Plot PP", type=input.bool, defval=true)+plotPP   = input.bool(title="Plot PP", defval=true)-plotS1R1 = input(title="Plot S1 and R1", type=input.bool, defval=true)+plotS1R1 = input.bool(title="Plot S1 and R1", defval=true)-plotS2R2 = input(title="Plot S2 and R2", type=input.bool, defval=true)+plotS2R2 = input.bool(title="Plot S2 and R2", defval=true)-plotS3R3 = input(title="Plot S3 and R3", type=input.bool, defval=true)+plotS3R3 = input.bool(title="Plot S3 and R3", defval=true)-plotTCBC = input(title="Plot S3 and R3", type=input.bool, defval=true)+plotTCBC = input.bool(title="Plot S3 and R3", defval=true)// Configure session options-sessRange = input(title="Trading Session", type=input.session, defval="0800-1600")+sessRange = input.session(title="Trading Session", defval="0800-1600")-showSess  = input(title="Highlight Session?", type=input.bool, defval=false)+showSess  = input.bool(title="Highlight Session?", defval=false)// Enable or disable pivot labels-showLabels = input(title="Show Labels?", type=input.bool, defval=false)+showLabels = input.bool(title="Show Labels?", defval=false)// Step 2. Calculate indicator values⋯GetData(res, data) =>-    security(syminfo.tickerid, res, data[1],+    request.security(syminfo.tickerid, res, data[1],         lookahead=barmerge.lookahead_on)⋯sessHigh := sessStart ? high :-     inSession ? max(high, sessHigh[1]) : na+     inSession ? math.max(high, sessHigh[1]) : nasessLow := sessStart ? low :-     inSession ? min(low, sessLow[1]) : na+     inSession ? math.min(low, sessLow[1]) : nasessClose := sessEnd ? close[1] : na⋯// Highlight the intra-day price data session on the chart-bgcolor(color=showSess and inSession and (pivotType == "Intraday") ?+bgcolor(color=color.new(showSess and inSession and (pivotType == "Intraday") ?-     color.orange : na, transp=95)+     color.orange : na, 95))// Step 4. Create indicator alerts-alertcondition(condition=cross(close, s3),+alertcondition(condition=ta.cross(close, s3),     title="Pivot S3 Cross",     message="Prices crossed Pivot S3 level")-alertcondition(condition=cross(close, s2),+alertcondition(condition=ta.cross(close, s2),     title="Pivot S2 Cross",     message="Prices crossed Pivot S2 level")-alertcondition(condition=cross(close, s1),+alertcondition(condition=ta.cross(close, s1),     title="Pivot S1 Cross",⋯     -alertcondition(condition=cross(close, tc),+alertcondition(condition=ta.cross(close, tc),     title="Pivot TC Cross",     message="Prices crossed Pivot TC level")-alertcondition(condition=cross(close, pp),+alertcondition(condition=ta.cross(close, pp),     title="Pivot PP Cross",⋯     -alertcondition(condition=cross(close, bc),+alertcondition(condition=ta.cross(close, bc),     title="Pivot BC Cross",     message="Prices crossed Pivot BC level")-alertcondition(condition=cross(close, r1),+alertcondition(condition=ta.cross(close, r1),     title="Pivot R1 Cross",     message="Prices crossed Pivot R1 level")-alertcondition(condition=cross(close, r2),+alertcondition(condition=ta.cross(close, r2),     title="Pivot R2 Cross",     message="Prices crossed Pivot R2 level")-alertcondition(condition=cross(close, r3),+alertcondition(condition=ta.cross(close, r3),     title="Pivot R3 Cross",⋯    -MA = sma(close, 20)+MA = ta.sma(close, 20)plot(MA, color=color.red)-Factor                   = input(2, type=input.float)+Factor                   = input.float(2)Pd                       = input(10, minval=1,maxval = 100)-Up                       = hl2-(Factor*atr(Pd))+Up                       = hl2-(Factor*ta.atr(Pd))-Dn                       = hl2+(Factor*atr(Pd))+Dn                       = hl2+(Factor*ta.atr(Pd))TrendUp                  = 0.0-TrendUp                  := close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up+TrendUp                  := close[1]>TrendUp[1]? math.max(Up,TrendUp[1]) : UpTrendDown           = 0.0-TrendDown           := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn+TrendDown           := close[1]<TrendDown[1]? math.min(Dn,TrendDown[1]) : DnTrend                    = 0.0⋯            if close>MA-                strategy.entry("long", true) +                strategy.entry("long", strategy.long) if close<open⋯            if close<MA-                strategy.entry("short", false) +                strategy.entry("short", strategy.short)                 ⋯

Clean v5

VerifiedDownload the v5 script

Same 86 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 7: input() → input.string()
  • Line 182: input() → input.int()
  • Line 204: when = open<Tsl → if block
  • Line 205: when = open>Tsl → if block
⋯// Create a pull-down menu for the pivot type-pivotType = input(title="Pivot Type",+pivotType = input.string(title="Pivot Type",     options=["Daily", "Intraday", "Weekly"], defval="Daily")⋯Factor                   = input.float(2)-Pd                       = input(10, minval=1,maxval = 100)+Pd                       = input.int(10, minval=1,maxval = 100)Up                       = hl2-(Factor*ta.atr(Pd))⋯                -strategy.close("long", when = open<Tsl)+if open<Tsl+    strategy.close("long")-strategy.close("short", when = open>Tsl)+if open>Tsl+    strategy.close("short")

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L96:C31: 'linewidth' must be at least 1 in Pine Script v6. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © amysojexson-//@version=5+//@version=6strategy(title="Pivots strategy", overlay=true)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Pivot TypeDailystring · options ["Daily", "Intraday", "Weekly"]theHigh theLow theClose newPivots bgcolor
Plot PPtrueboolPP
Plot S1 and R1trueboolR1 S1 R1 label S1 label
Plot S2 and R2trueboolR2 S2 R2 label S2 label
Plot S3 and R3trueboolR3 S3 R3 label S3 label
Plot S3 and R3trueboolTC BC TC label BC label
Trading Session0800-1600sessioninSession
Highlight Session?falseboolbgcolor
Show Labels?falseboolnewPivots
Factor (no label in the script)2floatUp Dn
Pd (no label in the script)10int · min 1 · max 100Up Dn

What it calculates

  • SMA (sma, ta.sma in v5)close, 20MA · line 179
  • ATR (atr, ta.atr in v5)Pd (10)Up · line 183
  • ATR (atr, ta.atr in v5)Pd (10)Dn · line 184

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.

The script has 68 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open long longclose>MAOn197
Open short shortclose<MAOn202
Close longopen<TslOn204
Close shortopen>TslOn205

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
Pivot S3 CrossalertconditionPrices crossed Pivot S3 level149
Pivot S2 CrossalertconditionPrices crossed Pivot S2 level152
Pivot S1 CrossalertconditionPrices crossed Pivot S1 level155
Pivot TC CrossalertconditionPrices crossed Pivot TC level159
Pivot PP CrossalertconditionPrices crossed the main Pivot Point level162
Pivot BC CrossalertconditionPrices crossed Pivot BC level166
Pivot R1 CrossalertconditionPrices crossed Pivot R1 level169
Pivot R2 CrossalertconditionPrices crossed Pivot R2 level172
Pivot R3 CrossalertconditionPrices crossed Pivot R3 level175

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

29/29trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • CheckHigher-timeframe data1 security call(s) use lookahead_on (line 23). Without a [1] offset this reads future bars in history.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo calc_on_every_tick. 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−5.7%+102.5%8633%0.9661.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+3.5%+5.5%5332%1.136.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+2.6%+9.8%6645%1.432.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.3%+8.4%7333%1.220.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%8744%0.930.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%5435%1.070.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.5%+148.3%8233%1.530.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.2%+17.1%6826%0.530.2%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 barsTradesWonP&L
Rising market2627%$6,572.29
Sideways market3037%−$17,376.60
Falling market3033%$5,080.52

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

59.3%

The 95th percentile of the worst drawdown when the same 86 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 32.8% to 59.3%; the tick is what actually happened, 51.7%. Order luck alone moves it this much.

0%68%
All 86 trades
SideEntryExitBarsP&L
long17 Feb 2024 52,124.1017 Mar 2024 65,300.6029$13,176.50
short17 Mar 2024 65,300.6018 Mar 2024 68,393.501−$3,092.83
long18 Mar 2024 68,393.5019 Mar 2024 67,610.001−$783.47
long21 Mar 2024 67,840.5022 Mar 2024 65,501.301−$2,339.23
short22 Mar 2024 65,501.3029 Mar 2024 70,780.607−$5,279.32
long29 Mar 2024 70,780.6030 Mar 2024 69,850.501−$930.07
long1 Apr 2024 71,280.002 Apr 2024 69,649.801−$1,630.19
long9 Apr 2024 71,620.0010 Apr 2024 69,146.001−$2,474.00
long11 Apr 2024 70,631.1012 Apr 2024 70,006.201−$624.86
short16 Apr 2024 63,420.0023 Apr 2024 66,819.307−$3,399.33
long23 Apr 2024 66,819.3024 Apr 2024 66,414.001−$405.32
short27 Apr 2024 63,770.0016 May 2024 66,206.5019−$2,436.51
long16 May 2024 66,206.5014 Jun 2024 66,773.0029$566.50
short18 Jun 2024 66,504.3015 Jul 2024 60,797.9027$5,706.42
long20 Jul 2024 66,660.001 Aug 2024 64,628.0012−$2,032.00
short1 Aug 2024 64,628.002 Aug 2024 65,354.001−$726.01
short3 Aug 2024 61,498.309 Aug 2024 61,686.006−$187.66
short12 Aug 2024 58,712.6013 Aug 2024 59,346.601−$634.05
short15 Aug 2024 58,683.4016 Aug 2024 57,541.101$1,142.34
short19 Aug 2024 58,427.3020 Aug 2024 59,438.501−$1,011.15
long22 Aug 2024 61,156.0029 Aug 2024 59,034.907−$2,121.13
short4 Sep 2024 57,487.7014 Sep 2024 60,498.0010−$3,010.25
long18 Sep 2024 60,314.002 Oct 2024 60,804.9014$490.93
short8 Oct 2024 62,224.0015 Oct 2024 66,084.007−$3,859.99
long27 Oct 2024 67,092.805 Nov 2024 67,850.009$757.25
short5 Nov 2024 67,850.006 Nov 2024 69,372.001−$1,522.00
long6 Nov 2024 69,372.0020 Dec 2024 97,461.9044$28,089.90
short27 Dec 2024 95,791.607 Jan 2025 102,236.0011−$6,444.00
short10 Jan 2025 92,552.5016 Jan 2025 100,497.006−$7,944.86
long22 Jan 2025 106,144.005 Feb 2025 97,763.1014−$8,380.68
short5 Feb 2025 97,763.103 Mar 2025 94,270.0026$3,493.15
short4 Mar 2025 86,221.205 Mar 2025 87,282.001−$1,060.82
short10 Mar 2025 80,734.5024 Mar 2025 86,082.5014−$5,348.02
long24 Mar 2025 86,082.5025 Mar 2025 87,498.201$1,415.66
long28 Mar 2025 87,232.0029 Mar 2025 84,424.401−$2,807.63
long2 Apr 2025 85,158.403 Apr 2025 82,516.301−$2,642.07
short3 Apr 2025 82,516.3012 Apr 2025 83,423.809−$907.55
long12 Apr 2025 83,423.8013 Apr 2025 85,276.901$1,853.08
long15 Apr 2025 84,591.6016 Apr 2025 83,644.001−$947.59
long18 Apr 2025 84,947.9019 Apr 2025 84,474.701−$473.22
long20 Apr 2025 85,077.0021 Apr 2025 85,179.201$102.24
long29 Apr 2025 95,011.2031 May 2025 103,985.0032$8,974.29
short21 Jun 2025 103,298.0026 Jun 2025 107,341.005−$4,042.61
long3 Jul 2025 108,850.001 Aug 2025 115,764.0029$6,914.48
short1 Aug 2025 115,764.0011 Aug 2025 119,294.0010−$3,530.20
long11 Aug 2025 119,294.0020 Aug 2025 112,873.009−$6,421.32
short20 Aug 2025 112,873.0023 Aug 2025 116,936.003−$4,063.05
long23 Aug 2025 116,936.0024 Aug 2025 115,438.001−$1,497.94
short26 Aug 2025 110,112.0011 Sep 2025 113,960.0016−$3,848.02
long11 Sep 2025 113,960.0024 Sep 2025 111,999.0013−$1,961.20
short26 Sep 2025 108,994.0030 Sep 2025 114,312.004−$5,317.48
long7 Oct 2025 124,659.0011 Oct 2025 112,774.004−$11,884.00
short12 Oct 2025 110,644.003 Dec 2025 91,277.9052$19,366.50
long3 Dec 2025 91,277.904 Dec 2025 93,429.901$2,152.07
long8 Dec 2025 90,395.309 Dec 2025 90,634.401$239.03
long10 Dec 2025 92,678.8011 Dec 2025 92,015.401−$663.43
short13 Dec 2025 90,268.4031 Dec 2025 88,485.5018$1,782.93
long31 Dec 2025 88,485.501 Jan 2026 87,648.201−$837.29
short1 Jan 2026 87,648.202 Jan 2026 88,839.101−$1,190.84
long2 Jan 2026 88,839.103 Jan 2026 89,995.101$1,156.09
long12 Jan 2026 91,013.7021 Jan 2026 88,427.709−$2,586.00
short1 Feb 2026 78,741.103 Mar 2026 68,830.1030$9,911.04
long3 Mar 2026 68,830.104 Mar 2026 68,338.001−$492.05
long10 Mar 2026 68,432.2022 Mar 2026 68,918.1012$485.96
short22 Mar 2026 68,918.1024 Mar 2026 70,906.402−$1,988.33
long24 Mar 2026 70,906.4025 Mar 2026 70,556.701−$349.71
short27 Mar 2026 68,820.308 Apr 2026 71,924.2012−$3,103.91
long8 Apr 2026 71,924.2016 May 2026 79,113.2038$7,188.98
short16 May 2026 79,113.2017 May 2026 78,148.101$965.15
short20 May 2026 76,834.4016 Jun 2026 66,328.7027$10,505.60
short17 Jun 2026 65,675.0018 Jun 2026 64,509.401$1,165.62
short22 Jun 2026 63,312.0023 Jun 2026 64,020.001−$708.01
long23 Jun 2026 64,020.0025 Jun 2026 61,078.002−$2,942.01
short1 Jul 2026 58,624.706 Jul 2026 63,650.005−$5,025.30
long10 Jul 2026 63,230.0028 Jul 2026 63,755.9018$525.85
short28 Jul 2026 63,755.9029 Jul 2026 63,915.001−$159.14
long31 Jul 2026 64,780.001 Aug 2026 62,887.901−$1,892.15
short1 Aug 2026 62,887.902 Aug 2026 62,823.701$64.23
short7 Aug 2026 64,323.608 Aug 2026 64,923.201−$599.59
long8 Aug 2026 64,923.2015 Aug 2026 63,043.607−$1,879.64
short15 Aug 2026 63,043.6016 Aug 2026 63,086.001−$42.45
short17 Aug 2026 62,900.0018 Aug 2026 64,532.101−$1,632.11
long18 Aug 2026 64,532.1016 Sep 2026 75,644.5029$11,112.40
short16 Sep 2026 75,644.5017 Sep 2026 76,206.001−$561.52
long19 Sep 2026 80,883.9013 Oct 2026 81,850.0024$966.15
short13 Oct 2026 81,850.0014 Oct 2026 83,169.001−$1,319.00

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Pivots strategy XN this page—v3 strategy−5.7%8661.2%
I11L - Better Buy Low Volatility or High Volatility- by I11Latr smav5 strategy+19.2%8337.4%
Vortex Cross w-MA Confirmation by DraftVentureatr smav5 strategy+2.4%524.7%
Configurable Multi MA Crossover Voting System by levieuxsma atrv5 strategy+28.5%539.4%
Swing Trend Strategy by Inkedlausma atrv5 strategy+11.2%516.2%
SSL Backtester With ATR SL TP and Money Management by JBTrippinsma atrv4 strategy+8.5%553.9%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 37 msWith a workaround 1,000 bars in 130 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 197, 202) so the engine trades the way the script says. 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. 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/// © amysojexson//@version=3strategy(title="Pivots strategy", overlay=true)// Input settings// Create a pull-down menu for the pivot typepivotType = input(title="Pivot Type",     options=["Daily", "Intraday", "Weekly"], defval="Daily")// Make toggles for pivot level optionsplotPP   = input(title="Plot PP", type=bool, defval=true)plotS1R1 = input(title="Plot S1 and R1", type=bool, defval=true)plotS2R2 = input(title="Plot S2 and R2", type=bool, defval=true)plotS3R3 = input(title="Plot S3 and R3", type=bool, defval=true)plotTCBC = input(title="Plot S3 and R3", type=bool, defval=true)// Configure session optionssessRange = input(title="Trading Session", type=session, defval="0800-1600")showSess  = input(title="Highlight Session?", type=bool, defval=false)// Enable or disable pivot labelsshowLabels = input(title="Show Labels?", type=bool, defval=false)// Step 2. Calculate indicator values// Create a function to fetch daily and weekly dataGetData(res, data) =>    security(tickerid, res, data[1],         lookahead=barmerge.lookahead_on)// Fetch daily and weekly price datadailyHigh  = GetData("D", high)dailyLow   = GetData("D", low)dailyClose = GetData("D", close)weeklyHigh  = GetData("W", high)weeklyLow   = GetData("W", low)weeklyClose = GetData("W", close)// Determine session pivot data// First see how the price bar relates to// the session time rangeinSession = not na(time(period, sessRange)[1])sessStart = inSession and not inSession[1]sessEnd   = not inSession and inSession[1]// Determine session price datasessHigh  = 0.0sessLow   = 0.0sessClose = 0.0sessHigh := sessStart ? high :     inSession ? max(high, sessHigh[1]) : nasessLow := sessStart ? low :     inSession ? min(low, sessLow[1]) : nasessClose := sessEnd ? close[1] : na// Compute high, low, close from previous intra-day sessionhighPrevSess  = 0.0lowPrevSess   = 0.0closePrevSess = 0.0highPrevSess  := sessEnd ? fixnan(sessHigh) : highPrevSess[1]lowPrevSess   := sessEnd ? fixnan(sessLow) : lowPrevSess[1]closePrevSess := sessEnd ? fixnan(sessClose) : closePrevSess[1]// Now figure out which kind of price data// to use for the pivot calculationtheHigh = if (pivotType == "Daily")    dailyHighelse    if (pivotType == "Intraday")        highPrevSess    else        weeklyHightheLow = if (pivotType == "Daily")    dailyLowelse    if (pivotType == "Intraday")        lowPrevSess    else        weeklyLowtheClose = if (pivotType == "Daily")    dailyCloseelse    if (pivotType == "Intraday")        closePrevSess    else        weeklyClose// Finally calculate the pivot levelspp = (theHigh + theLow + theClose) / 3bc= (theHigh + theLow)/2tc= (pp-bc)+ppr1 = pp+(.382*(theHigh-theLow))s1 = pp-(.382*(theHigh-theLow))r2 = pp +(.618*(theHigh-theLow))s2 = pp -(.618*(theHigh-theLow))r3 = pp +(1*(theHigh-theLow))s3 = pp -(1*(theHigh-theLow))// Step 3. Output indicator data// Plot the various pivot levelsplot(series=plotS3R3 ? r3 : na, title="R3",     style=circles, linewidth=1, color=#0023FF)plot(series=plotS2R2 ? r2 : na, title="R2",     style=circles, linewidth=1, color=#1E90FF)plot(series=plotS1R1 ? r1 : na, title="R1",     style=circles, linewidth=1, color=#09E0F3)plot(series=plotTCBC ? tc : na, title="TC",     style=circles, linewidth=.75, color=#FF00D1)plot(series=plotPP ? pp : na, title="PP",     style=circles, linewidth=1, color=#000000)plot(series=plotTCBC ? bc : na, title="BC",     style=circles, linewidth=.75, color=#FF00D1)plot(series=plotS1R1 ? s1 : na, title="S1",     style=circles, linewidth=1, color=#09E0F3)plot(series=plotS2R2 ? s2 : na, title="S2",     style=circles, linewidth=1, color=#1E90FF)plot(series=plotS3R3 ? s3 : na, title="S3",     style=circles, linewidth=1, color=#0023FF)// Display the pivot names on the chart, if applicablenewPivots = (showLabels == false) ? false :     (pivotType == "Intraday") ? sessEnd :     (pivotType == "Daily") ? dayofmonth != dayofmonth[1] :     dayofweek == monday and dayofmonth != dayofmonth[1]plotchar(series=newPivots and plotS3R3 ? r3 : na,     char='', text="R3", offset=1,     location=location.absolute,     color=#0023FF, title="R3 label")plotchar(series=newPivots and plotS2R2 ? r2 : na,     char='', text="R2", offset=1,     location=location.absolute,     color=#1E90FF, title="R2 label")plotchar(series=newPivots and plotS1R1 ? r1 : na,     char='', text="R1", offset=1,     location=location.absolute,     color=#09E0F3, title="R1 label")plotchar(series=newPivots and plotTCBC ? r1 : na,     char='', text="TC", offset=1,     location=location.absolute,     color=#FF00D1, title="TC label")     plotchar(series=newPivots and plotTCBC ? r1 : na,     char='', text="BC", offset=1,     location=location.absolute,     color=#FF00D1, title="BC label")plotchar(series=newPivots and plotS1R1 ? s1 : na,     char='', text="S1", offset=1,     location=location.absolute,     color=#09E0F3, title="S1 label")plotchar(series=newPivots and plotS2R2 ? s2 : na,     char='', text="S2", offset=1,     location=location.absolute,     color=#1E90FF, title="S2 label")plotchar(series=newPivots and plotS3R3 ? s3 : na,     char='', text="S3", offset=1,     location=location.absolute,     color=#0023FF, title="S3 label")// Highlight the intra-day price data session on the chartbgcolor(color=showSess and inSession and (pivotType == "Intraday") ?     orange : na, transp=95)// Step 4. Create indicator alertsalertcondition(condition=cross(close, s3),     title="Pivot S3 Cross",     message="Prices crossed Pivot S3 level")alertcondition(condition=cross(close, s2),     title="Pivot S2 Cross",     message="Prices crossed Pivot S2 level")alertcondition(condition=cross(close, s1),     title="Pivot S1 Cross",     message="Prices crossed Pivot S1 level")     alertcondition(condition=cross(close, tc),     title="Pivot TC Cross",     message="Prices crossed Pivot TC level")alertcondition(condition=cross(close, pp),     title="Pivot PP Cross",     message="Prices crossed the main Pivot Point level")     alertcondition(condition=cross(close, bc),     title="Pivot BC Cross",     message="Prices crossed Pivot BC level")alertcondition(condition=cross(close, r1),     title="Pivot R1 Cross",     message="Prices crossed Pivot R1 level")alertcondition(condition=cross(close, r2),     title="Pivot R2 Cross",     message="Prices crossed Pivot R2 level")alertcondition(condition=cross(close, r3),     title="Pivot R3 Cross",     message="Prices crossed Pivot R3 level")    MA = sma(close, 20)plot(MA, color=red)Factor                   = input(2, type=float)Pd                       = input(10, minval=1,maxval = 100)Up                       = hl2-(Factor*atr(Pd))Dn                       = hl2+(Factor*atr(Pd))TrendUp                  = 0.0TrendUp                  := close[1]>TrendUp[1]? max(Up,TrendUp[1]) : UpTrendDown           = 0.0TrendDown           := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : DnTrend                    = 0.0Trend                    := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)Tsl                 = Trend==1? TrendUp: TrendDownplot(Tsl, color=blue)if close>open    if open<pp        if close>pp            if close>MA                strategy.entry("long", true) if close<open    if open>pp        if close<pp            if close<MA                strategy.entry("short", false)                 strategy.close("long", when = open<Tsl)strategy.close("short", when = open>Tsl)