Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

SSL Backtester With ATR SL TP and Money Management

A Pine Script v4 strategy built on SMA (high, 16) and ATR (14). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 8 settings; defaults include SSL Period 16, ATR Period 14 and ATR Stop Loss Factor 1.5.

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 SSL Backtester With ATR SL TP and Money Management repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 16 of 16 trades.
How did SSL Backtester With ATR SL TP and Money Management do on BTCUSDT 1D with default settings?
+8.48%
From 26 Jan 2024 to 21 Oct 2026, over 55 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can SSL Backtester With ATR SL TP and Money Management be converted to Pine Script v5?
No
The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
Does SSL Backtester With ATR SL TP and Money Management use a stop loss?
Yes
strategy.exit sets a stop on line 45, 50.
Does SSL Backtester With ATR SL TP and Money Management run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 29 ms, in the browser.

BTCUSDT · 1D · default settings

  • SSL
  • SSL
  • 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 (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctSSL$108,485$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.
Net profit
+8.48%
$8,484.41
Buy and hold
+102.5%
same period
Closed trades
55
37 won · 18 lost
Profitable
67.3%
of closed trades
Profit factor
1.50
gross profit ÷ gross loss
Max drawdown
3.94%
−$3,940.40

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

v4 → v5

Differs

Trades differ: 55 before, 55 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 19: sma → ta.sma
  • Line 20: sma → ta.sma
  • Line 27: atr → ta.atr
⋯// © comiclysm-//@version=4+//@version=5strategy("SSL Backtester", overlay=false)⋯    -sma_high = sma(high, ssl_period)+sma_high = ta.sma(high, ssl_period)-sma_low = sma(low, ssl_period)+sma_low = ta.sma(low, ssl_period)ssl_value = 0⋯    -atr = atr(atr_period)+atr = ta.atr(atr_period)//--TRADE LOGIC----------------------------------------------------------⋯

Clean v5

Verified

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

  • Line 8: input() → input.bool()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.float()
  • Line 12: input() → input.float()
  • Line 13: input() → input.bool()
  • Line 14: input() → input.int()
  • Line 15: input() → input.float()
⋯//--USER INPUTS-two_digit = input(false, "Check this for 2-digit pairs (JPY, Gold, Etc)")+two_digit = input.bool(false, "Check this for 2-digit pairs (JPY, Gold, Etc)")-ssl_period = input(16, "SSL Period")+ssl_period = input.int(16, "SSL Period")-atr_period = input(14, "ATR Period")+atr_period = input.int(14, "ATR Period")-atr_stop_factor = input(1.5, "ATR Stop Loss Factor")+atr_stop_factor = input.float(1.5, "ATR Stop Loss Factor")-atr_target_factor = input(1.0, "ATR Target Factor")+atr_target_factor = input.float(1.0, "ATR Target Factor")-use_mm = input(true, "Check this to use Money Management")+use_mm = input.bool(true, "Check this to use Money Management")-position_size = input(1000, "Position size (for Fixed Risk)")+position_size = input.int(1000, "Position size (for Fixed Risk)")-risk = input(0.01, "Risk % in Decimal Form")+risk = input.float(0.01, "Risk % in Decimal Form")//--INDICATORS------------------------------------------------------------⋯

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

⋯// © comiclysm-//@version=5+//@version=6strategy("SSL Backtester", overlay=false)⋯

Settings

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

SettingDefaultType and rangeFeeds
Check this for 2-digit pairs (JPY, Gold, Etc)falseboolline 34
SSL Period16intsma_high sma_low
ATR Period14intatr
ATR Stop Loss Factor1.5floatrisk_pips stop_loss
ATR Target Factor1.0floattarget
Check this to use Money Managementtrueboolfinal_risk
Position size (for Fixed Risk)1000intfinal_risk
Risk % in Decimal Form0.01floatrisk_in_value

What it calculates

  • SMA (sma, ta.sma in v5)high, SSL Period (16)sma_high · line 19
  • SMA (sma, ta.sma in v5)low, SSL Period (16)sma_low · line 20
  • ATR (atr, ta.atr in v5)ATR Period (14)atr · 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.

highhighprice datassl_periodSSL Periodsetting · 16lowlowprice datahigh · low · closehigh · low · closeprice dataatr_periodATR Periodsetting · 14closecloseprice dataatr_stop_factorATR Stop Loss Factorsetting · 1.5riskRisk % in Decimal Formsetting · 0.01position_sizePosition size (for Fixe…setting · 1000atr_target_factorATR Target Factorsetting · 1.0sma_highSMA→ sma_highsma_lowSMA→ sma_lowatrATR→ atrssl_valuessl_valuevaluessl_low, ssl_highssl_low · ssl_high2 valuesbalance, point_valuebalance · point_value2 valuesrisk_pipsrisk_pipsvaluerisk_in_valuerisk_in_valuevaluerisk_lotsrisk_lotsvaluefinal_riskfinal_riskvaluestop_lossstop_lossvaluetargettargetvaluesignal_longsignal_longconditionsignal_shortsignal_shortconditionentry:LongOpen Longstrategy.entryexit:Xexit Xstrategy.exitentry:ShortOpen Shortstrategy.entryplot:53SSLplotplot:54SSLplot

Order rules

OrderFires whenBy defaultLine
Open Long long(signal_long)On44
Exit X stop and limit(signal_long)On45
Open Short short(signal_short)On49
Exit X stop and limit(signal_short)On50

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.

16/16trades 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+8.5%+102.5%5567%1.503.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+4.3%+5.5%6463%1.194.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%5959%1.003.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−6.9%+8.4%7151%0.7711.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+8.6%+16.7%5569%1.482.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+6.6%+21.5%5963%1.344.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+1.9%+148.3%5661%1.093.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.9%+17.1%7159%1.037.0%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 market1861%$390.58
Sideways market2673%$6,061.05
Falling market1164%$2,032.78

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

How bad could the drawdown be?

5.9%

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

0%7%
All 55 trades
SideEntryExitBarsP&L
short20 Mar 2024 61,937.4020 Mar 2024 67,619.800−$1,000.00
long29 Mar 2024 70,780.602 Apr 2024 65,120.504−$990.00
short3 Apr 2024 65,464.008 Apr 2024 70,626.905−$980.10
long9 Apr 2024 71,620.0012 Apr 2024 66,794.203−$970.30
short13 Apr 2024 67,116.5013 Apr 2024 63,742.700$640.40
long16 May 2024 66,206.5020 May 2024 69,032.304$644.67
short12 Jun 2024 67,314.2014 Jun 2024 65,230.002$648.96
long15 Jul 2024 60,797.9015 Jul 2024 63,126.900$653.29
short1 Aug 2024 64,628.002 Aug 2024 62,229.001$657.65
long22 Aug 2024 61,156.0023 Aug 2024 64,080.701$662.03
short29 Aug 2024 59,034.904 Sep 2024 56,251.806$666.45
long14 Sep 2024 60,498.0019 Sep 2024 62,955.805$670.89
short2 Oct 2024 60,804.907 Oct 2024 64,079.905−$1,013.31
long15 Oct 2024 66,084.0016 Oct 2024 68,199.801$668.60
short20 Dec 2024 97,461.9020 Dec 2024 93,123.500$673.06
long4 Jan 2025 98,174.206 Jan 2025 101,881.002$677.55
short10 Jan 2025 92,552.5015 Jan 2025 98,252.205−$1,023.10
long16 Jan 2025 100,497.0017 Jan 2025 104,187.001$675.25
short2 Feb 2025 100,636.002 Feb 2025 96,606.600$679.75
long21 Feb 2025 98,305.0024 Feb 2025 93,511.703−$1,026.42
short25 Feb 2025 91,552.9025 Feb 2025 88,377.200$677.44
long20 Mar 2025 86,845.9030 Mar 2025 82,648.5010−$662.84
short30 Mar 2025 82,648.502 Apr 2025 87,777.503−$1,022.93
long13 Apr 2025 85,276.9022 Apr 2025 89,469.409$670.71
short31 May 2025 103,985.005 Jun 2025 100,995.005$675.18
long10 Jun 2025 110,263.0012 Jun 2025 105,785.002−$1,019.53
short21 Jun 2025 103,298.0022 Jun 2025 100,404.001$672.89
long26 Jun 2025 107,341.003 Jul 2025 110,478.007$677.37
short1 Aug 2025 115,764.001 Aug 2025 112,970.000$681.89
long11 Aug 2025 119,294.0011 Aug 2025 121,886.000$686.37
short20 Aug 2025 112,873.0022 Aug 2025 117,226.002−$1,036.52
long11 Sep 2025 113,960.0015 Sep 2025 116,726.004$684.10
short23 Sep 2025 112,651.0025 Sep 2025 110,398.002$688.66
long2 Oct 2025 118,595.003 Oct 2025 121,121.001$693.25
short11 Oct 2025 112,774.0016 Oct 2025 108,578.005$697.87
long27 Oct 2025 114,559.0030 Oct 2025 108,833.003−$1,053.80
short31 Oct 2025 108,323.004 Nov 2025 104,426.004$695.50
long3 Dec 2025 91,277.9015 Dec 2025 88,172.2012−$548.93
short15 Dec 2025 88,172.2018 Dec 2025 84,699.703$700.14
long3 Jan 2026 89,995.105 Jan 2026 92,609.402$701.15
short21 Jan 2026 88,427.7029 Jan 2026 85,953.608$705.82
long3 Mar 2026 68,830.104 Mar 2026 72,284.401$710.53
short22 Mar 2026 68,918.1027 Mar 2026 65,983.605$715.26
long8 Apr 2026 71,924.2013 Apr 2026 74,532.005$720.03
short17 May 2026 78,148.1022 May 2026 75,993.605$724.84
long16 Jun 2026 66,328.7018 Jun 2026 62,873.202−$1,094.50
short24 Jun 2026 62,734.6024 Jun 2026 60,609.100$722.37
long5 Jul 2026 63,144.0015 Jul 2026 65,345.2010$727.18
short28 Jul 2026 63,755.908 Aug 2026 64,923.2011−$496.51
long8 Aug 2026 64,923.2014 Aug 2026 62,649.506−$1,098.06
short15 Aug 2026 63,043.6018 Aug 2026 64,532.103−$798.06
long18 Aug 2026 64,532.1019 Aug 2026 65,803.401$721.40
short11 Sep 2026 76,568.7018 Sep 2026 79,903.207−$1,081.33
long19 Sep 2026 80,883.9021 Sep 2026 83,236.502$713.69
short8 Oct 2026 83,321.808 Oct 2026 81,134.600$718.44

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
SSL Backtester With ATR SL TP and Money Management this page—v4 strategy+8.5%553.9%
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%
Baseline Cross Qualifier Volatility Strategy with HMA Trend Bias by sevencampbellsma atrv5 strategy−1.4%2141.8%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msYes 1,000 bars in 29 msNot measured
PineTSNo v5 and v6 only—Not measured

“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/// © comiclysm//@version=4strategy("SSL Backtester", overlay=false)//--This strategy will simply test the effectiveness of the SSL using//--money management and an ATR-derived stop loss//--USER INPUTStwo_digit = input(false, "Check this for 2-digit pairs (JPY, Gold, Etc)")ssl_period = input(16, "SSL Period")atr_period = input(14, "ATR Period")atr_stop_factor = input(1.5, "ATR Stop Loss Factor")atr_target_factor = input(1.0, "ATR Target Factor")use_mm = input(true, "Check this to use Money Management")position_size = input(1000, "Position size (for Fixed Risk)")risk = input(0.01, "Risk % in Decimal Form")//--INDICATORS------------------------------------------------------------    //--SSL    sma_high = sma(high, ssl_period)sma_low = sma(low, ssl_period)ssl_value = 0ssl_value := close > sma_high ? 1 : close < sma_low ? -1 : ssl_value[1]ssl_low = ssl_value < 0 ? sma_high : sma_lowssl_high = ssl_value < 0 ? sma_low : sma_high    //--Average True Range    atr = atr(atr_period)//--TRADE LOGIC----------------------------------------------------------signal_long = ssl_value > 0 and ssl_value[1] < 0signal_short = ssl_value < 0 and ssl_value[1] > 0//--RISK MANAGMENT-------------------------------------------------------balance = strategy.netprofit + strategy.initial_capitalrisk_pips = atr*10000*atr_stop_factorif(two_digit)    risk_pips := risk_pips / 100risk_in_value = balance * riskpoint_value = syminfo.pointvaluerisk_lots = risk_in_value / point_value / risk_pipsfinal_risk = use_mm ? risk_lots * 10000 : position_size//--TRADE EXECUTION-----------------------------------------------------if (signal_long)    stop_loss = close - atr * atr_stop_factor    target = close + atr * atr_target_factor    strategy.entry("Long", strategy.long, final_risk)    strategy.exit("X", "Long", stop=stop_loss, limit=target)if (signal_short)    stop_loss = close + atr * atr_stop_factor    target = close - atr * atr_target_factor    strategy.entry("Short", strategy.short, final_risk)    strategy.exit("X", "Short", stop=stop_loss, limit=target)    //--PLOTTING-----------------------------------------------------------plot(ssl_low, "SSL", color.red, linewidth=1)plot(ssl_high, "SSL", color.lime, linewidth=1)