Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Fixed price Stop Loss [Takazudo]

A Pine Script v5 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 9 settings; defaults include Risk price for each entry 100, Deposit currency USD and Entry band bar count 100.

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 Fixed price Stop Loss [Takazudo] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
Does Fixed price Stop Loss [Takazudo] 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 Fixed price Stop Loss [Takazudo] use a stop loss?
Yes
strategy.exit sets a stop on line 173, 174.
Does Fixed price Stop Loss [Takazudo] run in Zeal Terminal?
Yes
It compiles in 34 ms and runs 1,000 bars in 305 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$0$0Equity from $0
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 direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 168, 171) 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.
Net profit
0.00%
$0.00
Buy and hold
0.0%
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, $0 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.

Settings

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

SettingDefaultType and rangeFeeds
Money management
Risk price for each entry100int · min 1line 92
Deposit currencyUSDstring · options ["USD"]_deposit depositExchangeRate
Entry strategy
Entry band bar count100int · min 1line 111 line 116
Backtesting range
From Year2016int · min 1970startDate
From Month1int · min 1 · max 12startDate
From Day1int · min 1 · max 31startDate
To Year2020int · min 1970finishDate
To Month12int · min 1 · max 12finishDate
To Day31int · min 1 · max 31finishDate

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

config_depositCurrencyDeposit currencysetting · USDhl2hl2price dataclosecloseprice dataopenopenprice datafromYearFrom Yearsetting · 2016fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1toYearTo Yearsetting · 2020toMonthTo Monthsetting · 12toDayTo Daysetting · 31_base, _quote, _priceForEachPipAsDeposit, entryBand_height, _bandHeight, _style_base · _quote +46 values_deposit_depositvalue_losePriceOnSl_losePriceOnSlvaluerateratevaluedepositExchangeRatedepositExchangeRatevalue_highest_highestvalue_lowest_lowestvaluesl_longsl_longvaluesl_shortsl_shortvalueentryQtyentryQtyvalueslPipsslPipsvalue_str_strvalue_y_yvaluestartDatestartDatevaluefinishDatefinishDatevalueslslvaluevalue_bgcolorvalue_bgcolorvalueshouldMakeEntryLongshouldMakeEntryLongconditionshouldMakeEntryShortshouldMakeEntryShortconditionrangeBreakDetected_long, rangeBreakDetected_shortrangeBreakDetected_long…2 conditionsCOLOR_TRANSPARENT, COLOR_ENTRY_BAND, COLOR_RANGE_BREAK_BULL, COLOR_RANGE_BREAK_BEARColourCOLOR_TRANSPARENT · COLOR_ENT…entry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:Long-SL/TPexit Long-SL/TPstrategy.exitexit:Short-SL/TPexit Short-SL/TPstrategy.exitplot:122plotplotplot:123plotplotplot:180SLplotbgcolor:183bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open Long longshouldMakeEntryLongOn168
Open Short shortshouldMakeEntryShortOn171
Exit Long-SL/TP stopevery barOn173
Exit Short-SL/TP stopevery barOn174

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 data1 request.security call(s), none with lookahead on.
  • 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%0.0%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%0.0%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%0.0%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%0.0%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%0.0%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%0.0%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%0.0%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%0.0%00%—0.0%8 May 2026 – 21 Oct 2026

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

Similar scripts

No other indicator or strategy here shares enough of its calculations.

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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6//@author=Takazudo⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 34 msWith a workaround 1,000 bars in 305 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 168, 171) 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.

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///@version=5//@author=Takazudostrategy("Fixed price SL",  overlay=true,  default_qty_type=strategy.fixed,  initial_capital=0,  currency=currency.USD)var COLOR_TRANSPARENT = color.new(#000000, 100)var COLOR_ENTRY_BAND = color.new(#43A6F5, 30)var COLOR_RANGE_BREAK_BULL = color.new(#315F2E, 80)var COLOR_RANGE_BREAK_BEAR = color.new(#802A1C, 80)//============================================================================// config//============================================================================// Money management_g1 = 'Money management'var config_riskPrice = input.int(100, minval=1, title="Risk price for each entry", group=_g1)var config_depositCurrency = input.string(title="Deposit currency", defval="USD", options=["USD"], group=_g1)// Entry strategy_g2 = 'Entry strategy'var config_entryBandBars = input.int(defval = 100, title = "Entry band bar count",  minval=1, group=_g2)// Backtesting range_g3 = 'Backtesting range'fromYear  = input.int(defval = 2016, title = "From Year",  minval = 1970, group=_g3)fromMonth = input.int(defval = 1,    title = "From Month", minval = 1, maxval = 12, group=_g3)fromDay   = input.int(defval = 1,    title = "From Day",   minval = 1, maxval = 31, group=_g3)toYear  = input.int(defval = 2020, title = "To Year",  minval = 1970, group=_g3)toMonth = input.int(defval = 12,    title = "To Month", minval = 1, maxval = 12, group=_g3)toDay   = input.int(defval = 31,    title = "To Day",   minval = 1, maxval = 31, group=_g3)//============================================================================// exchange calculations//============================================================================// mico pip size calculation// ex1: AUDCAD -> 0.0001// ex2: USDJPY -> 0.01f_calcMicroPipSize() =>    _base = syminfo.basecurrency    _quote = syminfo.currency    _result = 0.0001    if _quote == 'JPY'        _result := _result * 100    if _base == 'BTC'        _result := _result * 100    _result// convert price to pipsf_convertPriceToPips(_price) =>    _microPipSize = f_calcMicroPipSize()    _price / _microPipSize// calculate exchange rate between deposit and quote currencyf_calcDepositExchangeSymbolId() =>    _result = ''    _deposit = config_depositCurrency    _quote = syminfo.currency    if (_deposit == 'USD') and (_quote == 'USD')        _result := na    if (_deposit == 'USD') and (_quote == 'AUD')        _result := 'OANDA:AUDUSD'    if (_deposit == 'EUR') and (_quote == 'USD')        _result := 'OANDA:EURUSD'    if (_deposit == 'USD') and (_quote == 'GBP')        _result := 'OANDA:GBPUSD'    if (_deposit == 'USD') and (_quote == 'NZD')        _result := 'OANDA:NZDUSD'    if (_deposit == 'USD') and (_quote == 'CAD')        _result := 'OANDA:USDCAD'    if (_deposit == 'USD') and (_quote == 'CHF')        _result := 'OANDA:USDCHF'    if (_deposit == 'USD') and (_quote == 'JPY')        _result := 'OANDA:USDJPY'    _result// Let's say we need CAD to USD exchange// However there's only "OANDA:USDCAD" symbol.// Then we need to invert the exhchange rate.// this function tells us whether we should invert the rate or notf_calcShouldInvert() =>    _result = false    _deposit = config_depositCurrency    _quote = syminfo.currency    if (_deposit == 'USD') and (_quote == 'CAD')        _result := true    if (_deposit == 'USD') and (_quote == 'CHF')        _result := true    if (_deposit == 'USD') and (_quote == 'JPY')        _result := true    _result// calculate how much quantity should I buy or sellf_calcQuantitiesForEntry(_depositExchangeRate, _slPips) =>    _microPipSize = f_calcMicroPipSize()    _priceForEachPipAsDeposit = _microPipSize * _depositExchangeRate    _losePriceOnSl = _priceForEachPipAsDeposit * _slPips    math.floor(config_riskPrice / _losePriceOnSl)//============================================================================// Quantity calculation//============================================================================depositExchangeSymbolId = f_calcDepositExchangeSymbolId()// calculate deposit exchange raterate = request.security(depositExchangeSymbolId, timeframe.period, hl2)shouldInvert = f_calcShouldInvert()depositExchangeRate = if config_depositCurrency == syminfo.currency    // if USDUSD, no exchange of course    1else    // else, USDCAD to CADUSD invert if we need    shouldInvert ? (1 / rate) : rate//============================================================================// Range Edge calculation//============================================================================f_calcEntryBand_high() =>    _highest = math.max(open[3], close[3])    for i = 4 to (config_entryBandBars - 1)        _highest := math.max(_highest, open[i], close[i])    _highestf_calcEntryBand_low() =>    _lowest = math.min(open[3], close[3])    for i = 4 to (config_entryBandBars - 1)        _lowest := math.min(_lowest, open[i], close[i])    _lowestentryBand_high = f_calcEntryBand_high()entryBand_low = f_calcEntryBand_low()entryBand_height = entryBand_high - entryBand_lowplot(entryBand_high, color=COLOR_ENTRY_BAND, linewidth=1)plot(entryBand_low, color=COLOR_ENTRY_BAND, linewidth=1)rangeBreakDetected_long = entryBand_high < closerangeBreakDetected_short = entryBand_low > closeshouldMakeEntryLong = (strategy.position_size == 0) and rangeBreakDetected_longshouldMakeEntryShort = (strategy.position_size == 0) and rangeBreakDetected_short//============================================================================// SL & Quantity//============================================================================var sl_long = hl2var sl_short = hl2entryQty = 0slPips = 0.0// just show info bubblef_showEntryInfo(_isLong) =>    _str =      'SL pips: ' + str.tostring(slPips) + '\n' +      'Qty: ' + str.tostring(entryQty)    _bandHeight = entryBand_high - entryBand_low    _y = _isLong ? (entryBand_low + _bandHeight * 1/4) : (entryBand_high - _bandHeight * 1/4)    _style = _isLong ? label.style_label_up : label.style_label_down    label.new(bar_index, _y, _str, size=size.large, style=_style)if shouldMakeEntryLong    sl_long := (entryBand_high + entryBand_low) / 2    slPips := f_convertPriceToPips(close - sl_long)    entryQty := f_calcQuantitiesForEntry(depositExchangeRate, slPips)if shouldMakeEntryShort    sl_short := (entryBand_high + entryBand_low) / 2    slPips := f_convertPriceToPips(sl_short - close)    entryQty := f_calcQuantitiesForEntry(depositExchangeRate, slPips)// trailing SLif strategy.position_size > 0    sl_long := math.max(sl_long, entryBand_low)if strategy.position_size < 0    sl_short := math.min(sl_short, entryBand_high)//============================================================================// backtest duration//============================================================================// Calculate start/end date and time conditionstartDate  = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear,   toMonth,   toDay,   00, 00)//============================================================================// make entries//============================================================================if (time >= startDate and time <= finishDate)    if shouldMakeEntryLong        strategy.entry(id="Long", direction=strategy.long, stop=close, qty=entryQty)        f_showEntryInfo(true)    if shouldMakeEntryShort        strategy.entry(id="Short", direction=strategy.short, stop=close, qty=entryQty)        f_showEntryInfo(false)strategy.exit('Long-SL/TP', 'Long', stop=sl_long)strategy.exit('Short-SL/TP', 'Short', stop=sl_short)//============================================================================// plot misc//============================================================================sl = strategy.position_size > 0 ? sl_long :  strategy.position_size < 0 ? sl_short : naplot(sl, color=color.red, style=plot.style_cross, linewidth=2, title="SL")value_bgcolor = rangeBreakDetected_long ? COLOR_RANGE_BREAK_BULL :  rangeBreakDetected_short ? COLOR_RANGE_BREAK_BEAR : COLOR_TRANSPARENTbgcolor(value_bgcolor)