Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Lawyers Trend Pro Strategy

A Pine Script v4 strategy built on SMA (src, 20), Stdev (src, 20) and Lowest (20). 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. It has no settings.

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

BTCUSDT · 1D · default settings

  • Plot
  • 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 (0)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$109,113$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 37, 40) so the engine trades the way the script says.
Net profit
+12.06%
$12,063.60
Buy and hold
+102.5%
same period
Closed trades
102
26 won · 76 lost
Profitable
25.5%
of closed trades
Profit factor
1.08
gross profit ÷ gross loss
Max drawdown
41.74%
−$46,338.60

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

    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 37, 38, 40, 41. 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, lowest → ta.lowest, highest → ta.highest, avg → math.avg, crossover → ta.crossover.
  • 4 strategy calls use the when = argument (line 37, 38, 40, 41). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 102 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: sma → ta.sma
  • Line 8: stdev → ta.stdev
  • Line 12: lowest → ta.lowest
  • Line 13: highest → ta.highest
  • Line 14: avg → math.avg
4 more edits
  • Line 27: crossover → ta.crossover
  • Line 29: crossover → ta.crossover
  • Line 37: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 40: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// © ErdemDemir-//@version=4+//@version=5strategy("Lawyers Trend Pro Strategy", shorttitle="Lawyers Trend Pro Strategy", overlay=true)⋯mult = 2.0-basis = sma(src, 20)+basis = ta.sma(src, 20)-dev = mult * stdev(src, 20)+dev = mult * ta.stdev(src, 20)upper = basis + dev⋯offset = 0-lower2 = lowest(20)+lower2 = ta.lowest(20)-upper2 = highest(20)+upper2 = ta.highest(20)-basis2 = avg(upper2, lower2)+basis2 = math.avg(upper2, lower2)MB= (basis+basis2)/2⋯// Buy only if the buy signal is triggered and we are not already long-buySignal = not isLong and crossover(close,MB)+buySignal = not isLong and ta.crossover(close,MB)// Sell only if the sell signal is triggered and we are not already short-sellSignal= not isShort and crossover(MB,close)+sellSignal= not isShort and ta.crossover(MB,close)if (buySignal)⋯/// LONG-strategy.entry("long", true , when = buySignal, comment="Open Long")+strategy.entry("long", strategy.long , when = buySignal, comment="Open Long")strategy.close("long", when=sellSignal, comment = "Close Long")/// SHORT-strategy.entry("short", false,  when = sellSignal, comment="Open Short")+strategy.entry("short", strategy.short,  when = sellSignal, comment="Open Short")strategy.close("short", when=buySignal, comment = "Close Short")

Clean v5

VerifiedDownload the v5 script

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

  • Line 37: when = buySignal → if block
  • Line 38: when = sellSignal → if block
  • Line 40: when = sellSignal → if block
  • Line 41: when = buySignal → if block
⋯/// LONG-strategy.entry("long", strategy.long , when = buySignal, comment="Open Long")+if buySignal+    strategy.entry("long", strategy.long , comment="Open Long")-strategy.close("long", when=sellSignal, comment = "Close Long")+if sellSignal+    strategy.close("long", comment = "Close Long")/// SHORT-strategy.entry("short", strategy.short,  when = sellSignal, comment="Open Short")+if sellSignal+    strategy.entry("short", strategy.short, comment="Open Short")-strategy.close("short", when=buySignal, comment = "Close Short")+if buySignal+    strategy.close("short", comment = "Close Short")

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: 102 before, 64 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.

⋯// © ErdemDemir-//@version=5+//@version=6strategy("Lawyers Trend Pro Strategy", shorttitle="Lawyers Trend Pro Strategy", overlay=true)⋯

Settings

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

The script declares no settings.

What it calculates

  • SMA (sma, ta.sma in v5)src, 20basis · line 7
  • Stdev (stdev, ta.stdev in v5)src, 20dev · line 8
  • Lowest (lowest, ta.lowest in v5)20lower2 · line 12
  • Highest (highest, ta.highest in v5)20upper2 · line 13

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 databasisSMA→ basisdevStdev→ devlower2Lowest→ lower2upper2Highest→ upper2srcsrcvalueupper, lowerupper · lower2 valuesbasis2basis2valueMBMBvalueisLongisLongvalueisShortisShortvaluebuySignalbuySignalconditionsellSignalsellSignalconditioncol1, col3col1 · col32 conditionscolorEColourcolorEentry:longOpen longstrategy.entryclose:longClose longstrategy.closeentry:shortOpen shortstrategy.entryclose:shortClose shortstrategy.closeplot:19plotplot

Order rules

OrderFires whenBy defaultLine
Open long longbuySignalnot isLong and crossover(close,MB)On37
Close longsellSignalnot isShort and crossover(MB,close)On38
Open short shortsellSignalnot isShort and crossover(MB,close)On40
Close shortbuySignalnot isLong and crossover(close,MB)On41

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.

27/27trades 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+12.1%+102.5%10225%1.0841.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+3.8%+5.5%10525%1.0713.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.2%+9.8%9827%1.141.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.7%+8.4%14718%0.731.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%10632%1.180.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%12122%1.090.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%10625%1.010.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%13724%0.780.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 market3625%−$21,448.00
Sideways market4132%$22,570.20
Falling market2516%$10,941.40

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

How bad could the drawdown be?

57.5%

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

0%66%
All 102 trades
SideEntryExitBarsP&L
short20 Mar 2024 61,937.4021 Mar 2024 67,840.501−$5,903.10
long21 Mar 2024 67,840.5022 Mar 2024 65,501.301−$2,339.23
short22 Mar 2024 65,501.3025 Mar 2024 67,210.003−$1,708.72
long25 Mar 2024 67,210.003 Apr 2024 65,464.009−$1,746.01
short3 Apr 2024 65,464.005 Apr 2024 68,487.802−$3,023.81
long5 Apr 2024 68,487.8013 Apr 2024 67,116.508−$1,371.28
short13 Apr 2024 67,116.5023 Apr 2024 66,819.3010$297.20
long23 Apr 2024 66,819.3025 Apr 2024 64,289.602−$2,529.74
short25 Apr 2024 64,289.604 May 2024 62,882.009$1,407.57
long4 May 2024 62,882.008 May 2024 62,312.104−$569.94
short8 May 2024 62,312.1010 May 2024 63,074.002−$761.93
long10 May 2024 63,074.0011 May 2024 60,800.001−$2,274.01
short11 May 2024 60,800.0014 May 2024 62,940.103−$2,140.10
long14 May 2024 62,940.1015 May 2024 61,577.501−$1,362.60
short15 May 2024 61,577.5016 May 2024 66,206.501−$4,629.02
long16 May 2024 66,206.5012 Jun 2024 67,314.2027$1,107.72
short12 Jun 2024 67,314.2014 Jul 2024 59,204.0032$8,110.22
long14 Jul 2024 59,204.003 Aug 2024 61,498.3020$2,294.33
short3 Aug 2024 61,498.309 Aug 2024 61,686.006−$187.66
long9 Aug 2024 61,686.0010 Aug 2024 60,838.001−$848.01
short10 Aug 2024 60,838.0020 Aug 2024 59,438.5010$1,399.49
long20 Aug 2024 59,438.5028 Aug 2024 59,415.008−$23.50
short28 Aug 2024 59,415.0014 Sep 2024 60,498.0017−$1,082.99
long14 Sep 2024 60,498.002 Oct 2024 60,804.9018$306.93
short2 Oct 2024 60,804.907 Oct 2024 62,819.905−$2,014.99
long7 Oct 2024 62,819.908 Oct 2024 62,224.001−$595.90
short8 Oct 2024 62,224.0013 Oct 2024 63,206.205−$982.22
long13 Oct 2024 63,206.204 Nov 2024 68,776.0022$5,569.76
short4 Nov 2024 68,776.006 Nov 2024 69,372.002−$596.02
long6 Nov 2024 69,372.0011 Dec 2024 96,593.0035$27,221.00
short11 Dec 2024 96,593.0012 Dec 2024 101,125.001−$4,532.00
long12 Dec 2024 101,125.0020 Dec 2024 97,461.908−$3,663.14
short20 Dec 2024 97,461.907 Jan 2025 102,236.0018−$4,773.74
long7 Jan 2025 102,236.009 Jan 2025 95,060.602−$7,174.99
short9 Jan 2025 95,060.6015 Jan 2025 96,560.906−$1,500.24
long15 Jan 2025 96,560.902 Feb 2025 100,636.0018$4,074.81
short2 Feb 2025 100,636.0021 Feb 2025 98,305.0019$2,330.65
long21 Feb 2025 98,305.0022 Feb 2025 96,182.001−$2,123.02
short22 Feb 2025 96,182.003 Mar 2025 94,270.009$1,912.00
long3 Mar 2025 94,270.004 Mar 2025 86,221.201−$8,048.83
short4 Mar 2025 86,221.206 Mar 2025 90,606.002−$4,384.84
long6 Mar 2025 90,606.007 Mar 2025 89,931.901−$674.12
short7 Mar 2025 89,931.9020 Mar 2025 86,845.9013$3,085.95
long20 Mar 2025 86,845.9021 Mar 2025 84,223.401−$2,622.55
short21 Mar 2025 84,223.4024 Mar 2025 86,082.503−$1,859.12
long24 Mar 2025 86,082.5030 Mar 2025 82,648.506−$3,433.97
short30 Mar 2025 82,648.502 Apr 2025 85,158.403−$2,509.82
long2 Apr 2025 85,158.403 Apr 2025 82,516.301−$2,642.07
short3 Apr 2025 82,516.3010 Apr 2025 82,615.207−$98.94
long10 Apr 2025 82,615.2011 Apr 2025 79,607.301−$3,007.92
short11 Apr 2025 79,607.3012 Apr 2025 83,423.801−$3,816.53
long12 Apr 2025 83,423.8030 May 2025 105,590.0048$22,165.90
short30 May 2025 105,590.0010 Jun 2025 110,263.0011−$4,673.27
long10 Jun 2025 110,263.0013 Jun 2025 105,672.003−$4,591.28
short13 Jun 2025 105,672.0014 Jun 2025 106,067.001−$394.85
long14 Jun 2025 106,067.0015 Jun 2025 105,415.001−$651.96
short15 Jun 2025 105,415.0017 Jun 2025 106,795.002−$1,379.90
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$2,243.36
short18 Jun 2025 104,551.0024 Jun 2025 105,334.006−$782.77
long24 Jun 2025 105,334.0031 Jul 2025 117,840.0037$12,506.30
short31 Jul 2025 117,840.008 Aug 2025 117,472.008$368.27
long8 Aug 2025 117,472.0016 Aug 2025 117,342.008−$129.98
short16 Aug 2025 117,342.009 Sep 2025 112,065.0024$5,276.81
long9 Sep 2025 112,065.0010 Sep 2025 111,546.001−$518.85
short10 Sep 2025 111,546.0011 Sep 2025 113,960.001−$2,413.62
long11 Sep 2025 113,960.0023 Sep 2025 112,651.0012−$1,309.01
short23 Sep 2025 112,651.0030 Sep 2025 114,312.007−$1,660.98
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$1,537.48
short11 Oct 2025 112,774.0027 Oct 2025 114,559.0016−$1,784.92
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$4,538.11
short30 Oct 2025 110,021.003 Nov 2025 110,541.004−$519.39
long3 Nov 2025 110,541.004 Nov 2025 106,583.001−$3,957.64
short4 Nov 2025 106,583.004 Dec 2025 93,429.9030$13,153.10
long4 Dec 2025 93,429.9015 Dec 2025 88,172.2011−$5,257.79
short15 Dec 2025 88,172.202 Jan 2026 88,839.1018−$666.89
long2 Jan 2026 88,839.1021 Jan 2026 88,427.7019−$411.39
short21 Jan 2026 88,427.7026 Feb 2026 67,988.0036$20,439.60
long26 Feb 2026 67,988.0027 Feb 2026 67,485.201−$502.85
short27 Feb 2026 67,485.203 Mar 2026 68,830.104−$1,344.87
long3 Mar 2026 68,830.108 Mar 2026 67,262.905−$1,567.15
short8 Mar 2026 67,262.9010 Mar 2026 68,432.202−$1,169.25
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.4027 Mar 2026 68,820.303−$2,086.14
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.2023 Jun 2026 64,020.0038$15,093.20
long23 Jun 2026 64,020.0024 Jun 2026 62,734.601−$1,285.44
short24 Jun 2026 62,734.604 Jul 2026 62,583.3010$151.31
long4 Jul 2026 62,583.3025 Jul 2026 64,140.0021$1,556.74
short25 Jul 2026 64,140.0026 Jul 2026 64,375.001−$235.01
long26 Jul 2026 64,375.0028 Jul 2026 63,755.902−$619.15
short28 Jul 2026 63,755.9031 Jul 2026 64,780.003−$1,024.17
long31 Jul 2026 64,780.001 Aug 2026 62,887.901−$1,892.15
short1 Aug 2026 62,887.906 Aug 2026 64,665.205−$1,777.36
long6 Aug 2026 64,665.207 Aug 2026 64,323.601−$341.63
short7 Aug 2026 64,323.608 Aug 2026 64,923.201−$599.59
long8 Aug 2026 64,923.2011 Aug 2026 63,970.003−$953.19
short11 Aug 2026 63,970.0018 Aug 2026 64,532.107−$562.10
long18 Aug 2026 64,532.1011 Sep 2026 76,568.7024$12,036.60
short11 Sep 2026 76,568.7019 Sep 2026 80,883.908−$4,315.13
long19 Sep 2026 80,883.909 Oct 2026 81,754.5020$870.60

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
Lawyers Trend Pro Strategy this page—v4 strategy+12.1%10241.7%
BTC Volatility Band Strategy by gary_tradessma stdev lowest highestv4 strategy−33.5%8045.0%
MACandles-LinearRegression-Strategy by Trendoscopestdev sma highest lowestv5 strategy+26.7%346.7%
VixFixLinReg-Strategy by Trendoscopehighest stdev sma lowestv4 strategy−49.3%1251.1%
Chandelier + BB + EMAS by juanchezhighest lowest sma stdevv4 strategy−20.6%1038.6%
Crunchster's Turtle and Trend System by Crunchster1lowest highest stdev smav5 strategy+18.0%3116.7%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msWith a workaround 1,000 bars in 22 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 37, 40) 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/// © ErdemDemir//@version=4strategy("Lawyers Trend Pro Strategy", shorttitle="Lawyers Trend Pro Strategy", overlay=true)src = closemult = 2.0basis = sma(src, 20)dev = mult * stdev(src, 20)upper = basis + devlower = basis - devoffset = 0lower2 = lowest(20)upper2 = highest(20)basis2 = avg(upper2, lower2)MB= (basis+basis2)/2col1=close>MBcol3=MB>closecolorE = col1 ? color.blue : col3 ? color.red : color.yellowp3=plot(MB, color=colorE, linewidth=3)// Deternine if we are currently LONGisLong = falseisLong := nz(isLong[1], false)// Determine if we are currently SHORTisShort = falseisShort := nz(isShort[1], false)// Buy only if the buy signal is triggered and we are not already longbuySignal = not isLong and crossover(close,MB)// Sell only if the sell signal is triggered and we are not already shortsellSignal= not isShort and crossover(MB,close)if (buySignal)    isLong := true    isShort := falseif (sellSignal)    isLong := false    isShort := true/// LONGstrategy.entry("long", true , when = buySignal, comment="Open Long")strategy.close("long", when=sellSignal, comment = "Close Long")/// SHORTstrategy.entry("short", false,  when = sellSignal, comment="Open Short")strategy.close("short", when=buySignal, comment = "Close Short")