Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Risk to Reward - FIXED SL Backtester

A Pine Script v5 strategy built on SMA (low, 14), RMA or TR (true, 14) and Lowest (low, 8). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 33% of equity and pays 0.075% commission. 16 settings; defaults include External indicator close, External Value 100 and 🌀 Risk Type Risk To Reward.

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 Risk to Reward - FIXED SL Backtester repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Risk to Reward - FIXED SL Backtester do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does Risk to Reward - FIXED SL Backtester run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does Risk to Reward - FIXED SL Backtester use a stop loss?
Yes
strategy.exit sets a stop on line 90.
Does Risk to Reward - FIXED SL Backtester run in Zeal Terminal?
Yes
It compiles in 34 ms and runs 1,000 bars in 68 ms, in the browser.

BTCUSDT · 1D · default settings

  • SMA
  • RMA
  • Lowest
  • VWAP
  • 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 (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,000$20,253Equity from $10,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.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $10,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.

  • Note

    No slippage

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

Settings

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

SettingDefaultType and rangeFeeds
➞ Main Core Settings 🔸
External indicator Select external indicator plotclosesourcedeal_start_condition
External Value Plot Value100intdeal_start_condition
➞ TP/SL ( Risk System ) 🔸
🌀 Risk TypeSelect Which risk system you wanna use ?! Risk to Reward or fixed systemRisk To Rewardstring · options ['Risk To Reward', 'Fixed TP & SL']longTP sl
➞ Risk to Reward 🔸
Risk To Reward RatioYour Risk to Reward Ratio ? 2:1 then put 21.5float · min 0 · step 0.1longTP
⬇️ Stoploss Type Select the Stoploss MethodATR SLstring · options ["ATR SL", "Pivot low", "VWAP SL"]line 58
ATR Factor Only used with ATR SL1.4float · step 0.1x2
Pivot Lookback looks for lower low ,Only used with Pivot Low8int · min 0stopLong
Vwap Multiplier Gets the SMMA value ,Only used with SMMA SL2.5float · step 0.1longstoploss
➞ Fixed TP & SL 🔸
Fixed TP1.5float · min 0 · step 0.1longTP
Fixed SL1.5float · min 0 · step 0.1sl
➞ BreakEven Settings 🔸
BreakEven ?Breakeven wtrueboolexit Long 3 AVG Price
Risk To Reward Ratio1.0float · step 0.1BreakevenTP
Percent Above EntryMUST be higher than '0'. This input front loads the new breakeven stop loss so that it is actually in profit.0.1float · step 0.1BreakevenSL
Backtest date range
Limit Date Rangetrueboolline 75
Start Timetimestamp('01 Aug 2022 00:00 +0000')timein_date_range
End Timetimestamp('31 Dec 2025 00:00 +0000')timein_date_range

What it calculates

  • SMAlow, 14smma · line 28
  • RMA / TRta.tr(true), 14x2 · line 49
  • Lowestlow, Pivot Lookback (8)stopLong · line 50
  • VWAP / TRta.tr(true)vwap · line 51

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.

lowlowprice datahigh · low · closehigh · low · closeprice dataATRSL ATR Factor …setting · 1.4LB Pivot Lookback…setting · 8hlc3 · volumehlc3 · volumeprice datavolumevolumeprice dataclosecloseprice dataRisktype 🌀 Risk Typesetting · Risk To RewardRRTPRisk To Reward Ratiosetting · 1.5FixedTPFixed TPsetting · 1.5breakRR Risk To Reward Ra…setting · 1.0BEper Percent Above Ent…setting · 0.1VWAPSL Vwap Multiplie…setting · 2.5FixedSLFixed SLsetting · 1.5timetimeprice datastart_timeStart Timesetting · timestamp('01 Aug 2…end_timeEnd Timesetting · timestamp('31 Dec 2…deal_start_valueExternal Value …setting · 100highhighprice datasmmaSMA→ smmax2RMA / TR→ x2stopLongLowest→ stopLongvwapVWAP / TR→ vwapslValslValvaluelongTPlongTPvalueBreakevenTPBreakevenTPvalueBreakevenSLBreakevenSLvaluelong_sl_levellong_sl_levelvaluevolumzvolumzvalueatr_vwap_volumeatr_vwap_volumevaluelongstoplosslongstoplossvalueslslvaluelongDiffSLlongDiffSLvalueBREAKPLOTBREAKPLOTvalueSLplotSLplotvaluelongPlotTPlongPlotTPvalueBREKEVENLINEBREKEVENLINEvaluein_date_rangein_date_rangeconditionlongConditionlongConditionconditiondeal_start_conditiondeal_start_conditionconditionlong_tp_hitlong_tp_hitconditionbgray, WHITE, red, white, olive, blue, GreenColourbgray · WHITE +5entry:LONGOpen LONGstrategy.entryexit:Long 3exit Long 3strategy.exitplot:99LONG STOP LOSSplotplot:101LONG TAKE PROFITplotplot:102plotplotplot:104AVG Priceplotfill:105Fillfill × 2fill:106Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open LONG long(in_date_range and longCondition)On89
Exit Long 3 stop and limitevery barOn90

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

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
Risk to Reward - FIXED SL Backtester this page—v5 strategy0.0%00.0%
JBravo Swing with GoGo Juice by bradvaughnsma vwap lowestv4 strategy+68.7%9322.3%
ATR GOD Strategy by TradeSmart (PineConnector-compatible) by TradeSmart22tr lowest sma rmav5 strategyNo trades on this market
Strategy Myth-Busting #7 - MACDBB+SSL+VSF - [MYN] by myncryptosma tr lowest rmav5 strategyNo trades on this market
Stochastic RSI Strategy (with SMA and VWAP Filters) by thedoggwalkerlowest sma vwapv4 strategy−0.0%30.0%
Bagheri IG Ether by Bagheri_IGlowest rma smav4 strategy+0.0%30.0%

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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © TZack88-//@version=5+//@version=6strategy(title='RR - FIXED SL Backtester', shorttitle='ZCrypto Backtester',overlay=true,pyramiding=1, initial_capital=10000,⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 34 msYes 1,000 bars in 68 msNot measured
PineTSNot testedNot testedNot 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.

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/// © TZack88//@version=5strategy(title='RR - FIXED SL Backtester', shorttitle='ZCrypto Backtester',overlay=true,pyramiding=1, initial_capital=10000,   commission_type=strategy.commission.percent, commission_value=0.075,default_qty_value = 33, default_qty_type = strategy.percent_of_equity)  var float slVal                     = 0.0float longTP                        = navar float SL                        = nafloat BreakevenTP                   = nafloat BreakevenSL                   = navar float TPlong                    = nadeal_start_condition                = falsevar float long_sl_level             = na color bgray                         = color.rgb(128, 223, 236, 81)color WHITE                         = color.rgb(210, 210, 210)color red                           = color.rgb(163, 46, 46, 29)color white                         = color.rgb(248, 248, 248, 14)color olive                         = color.olivecolor blue                          = color.rgb(23, 43, 77)color Green                        = color.rgb(10, 218, 103, 34)string core                         =  "➞ Main Core Settings 🔸"string Breakeeven                   =  "➞ Breakeven Settings 🔸" string SLZ2                         =  "➞ TP/SL ( Risk System ) 🔸"string RRS                          =  "➞ Risk to Reward 🔸"string FTPS                         =  "➞ Fixed TP & SL 🔸"string BES                          =  "➞ BreakEven Settings 🔸"float smma                          = ta.sma(low,14)string SLZ2TOOL                     = "Select Which risk system you wanna use ?! Risk to Reward or fixed system"string RRT                          = "Your Risk to Reward Ratio ? 2:1 then put 2"string _tooltip3                    = "Select external indicator plot"string SLSelect                     = "Select the Stoploss Method"float external_indicator            = input.source(defval=close, title='External indicator         ', group=core, tooltip=_tooltip3,inline = "00")float deal_start_value              = input.int(defval=100, title='External Value               ', group=core, tooltip="Plot Value",inline = "01")bool Risktype                       = input.string('Risk To Reward', title = '   🌀 Risk Type',group=SLZ2,inline = "000",options = ['Risk To Reward', 'Fixed TP & SL'],tooltip = SLZ2TOOL) == 'Risk To Reward'float RRTP                          = input.float(1.5, minval=0,step = 0.1,title="Risk To Reward Ratio",group=RRS,inline = "01",tooltip = RRT)string stoploss                     = input.string("ATR SL", title="   ⬇️ Stoploss Type ", options=["ATR SL", "Pivot low", "VWAP SL"], group=RRS,inline = "02",tooltip = SLSelect)float ATRSL                         = input.float(1.4,"         ATR Factor           ",step = 0.1,group = RRS,inline = "03",tooltip = "Only used with ATR SL")int LB                              = input.int(8, minval=0,title="         Pivot Lookback     ",group=RRS,inline = "04",tooltip = "looks for lower low ,Only used with Pivot Low")float VWAPSL                        = input.float(2.5,"         Vwap Multiplier    ",step = 0.1,group=RRS,inline = "05",tooltip = "Gets the SMMA value ,Only used with SMMA SL")float FixedTP                       = input.float(1.5, minval=0,step = 0.1,title="Fixed TP",group=FTPS,inline = "01") / 100float FixedSL                       = input.float(1.5, minval=0,step = 0.1,title="Fixed SL",group=FTPS,inline = "01") / 100bool breakon                        = input.bool(true,"BreakEven ?" ,group = BES, inline="06",tooltip = "Breakeven w")float breakRR                       = input.float(1.0, "      Risk To Reward Ratio",step = 0.1, group = BES, inline="07")float BEper                         = input.float(0.1, "      Percent Above Entry",step = 0.1, group = BES, inline="08",tooltip="MUST be higher than '0'. This input front loads the new breakeven stop loss so that it is actually in profit.")/100deal_start_condition := if external_indicator == deal_start_value    true//-----SL core calculation-----{x2 = low - ta.rma(ta.tr(true), 14) * ATRSLstopLong =  ta.lowest(low,LB)vwap = math.sum(ta.vwap(ta.tr(true)),14) * volumevolumz = math.sum(volume,14)atr_vwap_volume = math.abs(vwap / volumz)longstoploss = low - atr_vwap_volume * VWAPSL//}// Lets get the SL and return it my_stop() =>    switch stoploss        "ATR SL" => x2        "Pivot low" => stopLong        "SMMA SL" => longstoplosssl = Risktype ? my_stop() : close  * (1 - FixedSL)// lets set the SL , TP Valuesif deal_start_condition and strategy.position_size == 0    slVal:= slelse    slVal:= slVal    longDiffSL = math.abs(close - slVal)longTP := deal_start_condition and strategy.position_size == 0 ? Risktype ? close + (RRTP * longDiffSL) : close * (1 + FixedTP) : longTP[1]// -- Backtest Date ?! {limit_date_range = input.bool(title='Limit Date Range', defval=true, group='Backtest date range')start_time  = input.time(defval=timestamp('01 Aug 2022 00:00 +0000'), title='Start Time', group='Backtest date range')end_time    = input.time(defval=timestamp('31 Dec 2025 00:00 +0000'), title='End Time', group='Backtest date range')in_date_range = trueif limit_date_range    in_date_range := time >= start_time and time <= end_time    else    in_date_range := true//-- }longCondition = (deal_start_condition== true) and strategy.position_size == 0//BreakevenBreakevenTP := longCondition ? close + (breakRR * longDiffSL) : BreakevenTP[1]BREAKPLOT = strategy.position_size > 0 ? BreakevenTP : naBreakevenSL := strategy.position_size > 0 ? strategy.position_avg_price * (1 + BEper) :nalong_tp_hit = close >= BreakevenTP or high>= BreakevenTPlong_sl_level := longCondition  ? slVal : long_tp_hit ? BreakevenSL: long_sl_level[1]if (in_date_range and longCondition)    strategy.entry("LONG", strategy.long )   strategy.exit("Long 3","LONG",      limit=longTP,       stop=(breakon ? long_sl_level : slVal),     comment_profit = "TP HIT",     comment_loss = breakon ? "BE Close" : "Loss"     )      // PLOTSSLplot =  strategy.position_size > 0 ? slVal : naSSL = plot(SLplot, title='LONG STOP LOSS', linewidth=2, style=plot.style_linebr, color=red)longPlotTP =  strategy.position_size > 0 ? longTP : naTTP = plot(longPlotTP, title='LONG TAKE PROFIT', linewidth=2, style=plot.style_linebr, color=Green)avg = plot( strategy.position_avg_price, style = plot.style_linebr,color=WHITE )BREKEVENLINE = strategy.position_size > 0 ? long_sl_level : na plot(breakon ? BREKEVENLINE : na, 'AVG Price',color=color.white, style=plot.style_linebr,editable = false,linewidth = 2)fill(TTP, avg, color = color.new(Green,80))fill(avg, SSL, color =color.new(red,80))