Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Jaws Mean Reversion [Strategy]

A Pine Script v4 strategy built on SMA (close, 2). 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. 4 settings; defaults include Source close, Small Moving Average 2 and Big Moving Average 8.

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 Jaws Mean Reversion [Strategy] repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 17 of 17 trades.
How did Jaws Mean Reversion [Strategy] do on BTCUSDT 1D with default settings?
+29.18%
From 26 Jan 2024 to 21 Oct 2026, over 57 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Jaws Mean Reversion [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 Jaws Mean Reversion [Strategy] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Jaws Mean Reversion [Strategy] run in Zeal Terminal?
Yes
It compiles in 9 ms and runs 1,000 bars in 15 ms, in the browser.

BTCUSDT · 1D · default settings

  • SMA
  • SMA
  • SMA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$129,179$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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.
Net profit
+29.18%
$29,175.00
Buy and hold
+102.5%
same period
Closed trades
57
40 won · 17 lost
Profitable
70.2%
of closed trades
Profit factor
1.43
gross profit ÷ gross loss
Max drawdown
20.91%
−$30,338.20

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

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

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, crossunder → ta.crossunder, crossover → ta.crossover.

v4 → v5

Verified

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

  • Line 1: //@version=4 → //@version=5
  • Line 19: sma → ta.sma
  • Line 20: sma → ta.sma
  • Line 21: sma → ta.sma
  • Line 22: crossunder → ta.crossunder
  • Line 24: crossover → ta.crossover
-// @version=4+// @version=5//⋯//Strategy calculation-smallMA = sma(source, smallMAPeriod)+smallMA = ta.sma(source, smallMAPeriod)-bigMA =  sma(source, bigMAPeriod) +bigMA =  ta.sma(source, bigMAPeriod) -buyMA = ((100 - percentBelowToBuy) / 100) * sma(source, bigMAPeriod)[0]+buyMA = ((100 - percentBelowToBuy) / 100) * ta.sma(source, bigMAPeriod)[0]-if(crossunder(smallMA, buyMA))+if(ta.crossunder(smallMA, buyMA))    strategy.entry("BUY", strategy.long)-if(crossover(smallMA, bigMA))+if(ta.crossover(smallMA, bigMA))    strategy.close("BUY")

Clean v5

VerifiedDownload the v5 script

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

  • Line 14: input() → input.source()
  • Line 15: input() → input.int()
  • Line 16: input() → input.int()
  • Line 17: input() → input.int()
⋯//Strategy inputs-source = input(title = "Source", defval = close)+source = input.source(title = "Source", defval = close)-smallMAPeriod = input(title = "Small Moving Average", defval = 2)+smallMAPeriod = input.int(title = "Small Moving Average", defval = 2)-bigMAPeriod = input(title = "Big Moving Average", defval = 8)+bigMAPeriod = input.int(title = "Big Moving Average", defval = 8)-percentBelowToBuy = input(title = "Percent below to buy %", defval = 1)+percentBelowToBuy = input.int(title = "Percent below to buy %", defval = 1)//Strategy calculation⋯

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: 57 before, 46 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.

-// @version=5+// @version=6//⋯

Settings

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

SettingDefaultType and rangeFeeds
SourceclosesourcesmallMA bigMA buyMA
Small Moving Average2intsmallMA
Big Moving Average8intbigMA buyMA
Percent below to buy %1intbuyMA

What it calculates

  • SMA (sma, ta.sma in v5)Source (close), Small Moving Average (2)smallMA · line 19
  • SMA (sma, ta.sma in v5)Source (close), Big Moving Average (8)bigMA · line 20
  • SMA (sma, ta.sma in v5)Source (close), Big Moving Average (8)buyMA · line 21

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.

closecloseprice datasmallMAPeriodSmall Moving Averagesetting · 2bigMAPeriodBig Moving Averagesetting · 8percentBelowToBuyPercent below to buy %setting · 1smallMASMA→ smallMAbigMASMA→ bigMAbuyMASMA→ buyMAentry:BUYOpen BUYstrategy.entryclose:BUYClose BUYstrategy.close

Order rules

OrderFires whenBy defaultLine
Open BUY long(crossunder(smallMA, buyMA))On23
Close BUY(crossover(smallMA, bigMA))On25

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.

17/17trades 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.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+29.2%+102.5%5770%1.4320.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.8%+5.5%3070%1.1114.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.7%+9.8%6060%0.871.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%3863%1.020.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%6352%0.700.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%4576%1.400.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.4%+148.3%5368%1.560.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%2677%0.810.2%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 barsTradesWonP&L
Rising market2181%$42,877.60
Sideways market1958%−$9,639.37
Falling market1771%−$4,063.28

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

How bad could the drawdown be?

23.1%

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

0%27%
All 57 trades
SideEntryExitBarsP&L
long24 Feb 2024 50,744.2027 Feb 2024 54,476.503$3,732.33
long17 Mar 2024 65,300.6026 Mar 2024 69,880.009$4,579.36
long3 Apr 2024 65,464.008 Apr 2024 69,360.405$3,896.39
long13 Apr 2024 67,116.5021 Apr 2024 64,940.608−$2,175.94
long27 Apr 2024 63,770.005 May 2024 63,892.008$122.03
long11 May 2024 60,800.0014 May 2024 62,940.103$2,140.10
long2 Jun 2024 67,766.804 Jun 2024 68,809.902$1,043.05
long12 Jun 2024 67,314.201 Jul 2024 62,772.0019−$4,542.22
long5 Jul 2024 57,050.0011 Jul 2024 57,725.806$675.83
long26 Jul 2024 65,799.9027 Jul 2024 67,908.001$2,108.05
long1 Aug 2024 64,628.0010 Aug 2024 60,838.009−$3,790.02
long16 Aug 2024 57,541.1019 Aug 2024 58,427.303$886.30
long28 Aug 2024 59,415.0011 Sep 2024 57,636.0014−$1,779.01
long2 Oct 2024 60,804.907 Oct 2024 62,819.905$2,014.99
long11 Oct 2024 60,326.4013 Oct 2024 63,206.202$2,879.83
long24 Oct 2024 66,668.6029 Oct 2024 69,962.205$3,293.56
long4 Nov 2024 68,776.007 Nov 2024 75,572.003$6,796.00
long27 Nov 2024 91,965.2030 Nov 2024 97,460.003$5,494.84
long11 Dec 2024 96,593.0013 Dec 2024 100,004.002$3,411.29
long20 Dec 2024 97,461.9026 Dec 2024 99,429.606$1,967.75
long28 Dec 2024 94,299.003 Jan 2025 96,984.806$2,685.76
long9 Jan 2025 95,060.6015 Jan 2025 96,560.906$1,500.24
long28 Jan 2025 102,083.0031 Jan 2025 104,723.003$2,640.11
long2 Feb 2025 100,636.0013 Feb 2025 97,870.0011−$2,765.66
long25 Feb 2025 91,552.903 Mar 2025 94,270.006$2,717.11
long9 Mar 2025 86,222.5016 Mar 2025 84,338.407−$1,884.02
long30 Mar 2025 82,648.505 Apr 2025 83,889.906$1,241.34
long7 Apr 2025 78,430.0011 Apr 2025 79,607.304$1,177.30
long30 May 2025 105,590.008 Jun 2025 105,552.009−$37.60
long14 Jun 2025 106,067.0025 Jun 2025 106,083.0011$16.41
long2 Aug 2025 113,298.008 Aug 2025 117,472.006$4,174.10
long17 Aug 2025 117,381.0024 Aug 2025 115,438.007−$1,942.60
long26 Aug 2025 110,112.003 Sep 2025 111,240.008$1,128.03
long23 Sep 2025 112,651.0030 Sep 2025 114,312.007$1,660.98
long11 Oct 2025 112,774.0022 Oct 2025 108,298.0011−$4,476.83
long31 Oct 2025 108,323.0011 Nov 2025 106,011.0011−$2,311.74
long14 Nov 2025 99,692.0027 Nov 2025 90,484.0013−$9,208.02
long2 Dec 2025 86,286.004 Dec 2025 93,429.902$7,143.94
long7 Dec 2025 89,236.809 Dec 2025 90,634.402$1,397.55
long15 Dec 2025 88,172.2021 Dec 2025 88,360.906$188.75
long11 Jan 2026 90,504.7014 Jan 2026 95,414.003$4,909.29
long20 Jan 2026 92,631.0029 Jan 2026 89,300.009−$3,330.99
long30 Jan 2026 84,650.2015 Feb 2026 69,822.9016−$14,827.20
long19 Feb 2026 66,461.0023 Feb 2026 67,643.404$1,182.39
long24 Feb 2026 64,656.0027 Feb 2026 67,485.203$2,829.18
long8 Mar 2026 67,262.9011 Mar 2026 69,948.603$2,685.73
long20 Mar 2026 69,930.0025 Mar 2026 70,556.705$626.73
long28 Mar 2026 66,407.302 Apr 2026 68,113.905$1,706.64
long30 Apr 2026 75,780.002 May 2026 78,231.102$2,451.13
long14 May 2026 79,313.6026 May 2026 77,322.0012−$1,991.60
long28 May 2026 74,449.3012 Jun 2026 63,626.0015−$10,823.30
long19 Jun 2026 62,958.003 Jul 2026 61,560.0014−$1,398.01
long26 Jul 2026 64,375.005 Aug 2026 64,106.6010−$268.46
long12 Aug 2026 63,600.0018 Aug 2026 64,532.106$932.10
long3 Sep 2026 77,340.004 Sep 2026 81,270.401$3,930.36
long10 Sep 2026 78,306.4019 Sep 2026 80,883.909$2,577.43
long9 Oct 2026 81,754.5020 Oct 2026 81,938.4011$183.93

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
Jaws Mean Reversion [Strategy] this page—v4 strategy+29.2%5720.9%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msWith a workaround 1,000 bars in 15 msNot measured
PineTSNo v5 and v6 only—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. 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.

// @version=4//// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0///// @author Sunil Halai//// This very simple strategy is an implementation of PJ Sutherlands' Jaws Mean reversion algorithm. It simply buys when a small moving average period (e.g. 2) is below// a longer moving average period (e.g. 8) by a certain percentage, and closes when the small period average crosses over the longer moving average. // // If you are going to use this, you may wish to apply this to a range of investment assets, as the amount signals is low. Alternatively you may wish to tweak the settings to provide more// signals.strategy("Jaws Mean Reversion [Strategy]", overlay = true)//Strategy inputssource = input(title = "Source", defval = close)smallMAPeriod = input(title = "Small Moving Average", defval = 2)bigMAPeriod = input(title = "Big Moving Average", defval = 8)percentBelowToBuy = input(title = "Percent below to buy %", defval = 1)//Strategy calculationsmallMA = sma(source, smallMAPeriod)bigMA =  sma(source, bigMAPeriod) buyMA = ((100 - percentBelowToBuy) / 100) * sma(source, bigMAPeriod)[0]if(crossunder(smallMA, buyMA))    strategy.entry("BUY", strategy.long)if(crossover(smallMA, bigMA))    strategy.close("BUY")