Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

B-Xtrender [Backtest Edition] @QuantTherapy

A Pine Script v4 strategy built on RSI or EMA (close, i_short_l2, 15) and EMA or SMA (close, 200). It has 7 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. 16 settings; defaults include [Backtest] From Month 1, [Backtest] From Day 1 and [Backtest] From Year 2010.

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 B-Xtrender [Backtest Edition] @QuantTherapy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 38 of 38 trades.
How did B-Xtrender [Backtest Edition] @QuantTherapy do on BTCUSDT 1D with default settings?
+24.32%
From 26 Jan 2024 to 21 Oct 2026, over 87 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can B-Xtrender [Backtest Edition] @QuantTherapy 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 B-Xtrender [Backtest Edition] @QuantTherapy use a stop loss?
Yes
strategy.exit sets a stop on line 88, 90.
Does B-Xtrender [Backtest Edition] @QuantTherapy run in Zeal Terminal?
Yes
It compiles in 27 ms and runs 1,000 bars in 75 ms, in the browser.

BTCUSDT · 1D · default settings

  • B-Xtrender Osc. - Histogram
  • B-Xtrender Trend - Histogram
  • B-Xtrender Trend - Line
  • 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,000AprJulOct2025AprJulOct2026AprJulOctB-Xtrender Osc. - Histogram$124,321$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
+24.32%
$24,319.80
Buy and hold
+102.5%
same period
Closed trades
87
43 won · 44 lost
Profitable
49.4%
of closed trades
Profit factor
1.28
gross profit ÷ gross loss
Max drawdown
26.66%
−$30,759.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.

  • Note

    Uses an argument v6 removed

    when = on line 63, 64, 65, 66. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 34

    transp = on line 34, 37, 38, 39, 51, 52. v5 folds the transparency into the colour with color.new(c, transp).

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 rsi → ta.rsi, ema → ta.ema, sma → ta.sma, max → math.max, min → math.min.
  • 4 strategy calls use the when = argument (line 63, 64, 65, 66). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.integer) → input.int()
  • Line 7: input(type = input.integer) → input.int()
  • Line 8: input(type = input.integer) → input.int()
  • Line 9: input(type = input.integer) → input.int()
  • Line 10: input(type = input.integer) → input.int()
16 more edits
  • Line 11: input(type = input.integer) → input.int()
  • Line 31: rsi → ta.rsi
  • Line 31: ema → ta.ema
  • Line 31: ema → ta.ema
  • Line 32: rsi → ta.rsi
  • Line 32: ema → ta.ema
  • Line 34: transp = 40 → color.new(shortXtrenderCol, 40)
  • Line 37: transp = 90 → color.new(longXtrenderCol, 90)
  • Line 38: transp = 100 → color.new(#000000, 100)
  • Line 39: transp = 100 → color.new(macollongXtrenderCol, 100)
  • Line 41: ema → ta.ema
  • Line 41: sma → ta.sma
  • Line 51: transp = 10 → color.new(color.lime, 10)
  • Line 52: transp = 10 → color.new(color.red, 10)
  • Line 71: max → math.max
  • Line 76: min → math.min
⋯// © QuantTherapy-//@version=4+//@version=5strategy("B-Xtrender [Backtest Edition] @QuantTherapy")// === DATE & TIME SELECTION ===-i_fromMonth  = input(defval = 1,       title = "[Backtest] From Month",      type = input.integer, minval = 1, maxval = 12)+i_fromMonth  = input.int(defval = 1,       title = "[Backtest] From Month", minval = 1, maxval = 12)-i_fromDay    = input(defval = 1,       title = "[Backtest] From Day",        type = input.integer, minval = 1, maxval = 31)+i_fromDay    = input.int(defval = 1,       title = "[Backtest] From Day", minval = 1, maxval = 31)-i_fromYear   = input(defval = 2010,    title = "[Backtest] From Year",       type = input.integer, minval = 1970)+i_fromYear   = input.int(defval = 2010,    title = "[Backtest] From Year", minval = 1970)-i_thruMonth  = input(defval = 1,       title = "[Backtest] Thru Month",      type = input.integer, minval = 1, maxval = 12)+i_thruMonth  = input.int(defval = 1,       title = "[Backtest] Thru Month", minval = 1, maxval = 12)-i_thruDay    = input(defval = 1,       title = "[Backtest] Thru Day",        type = input.integer, minval = 1, maxval = 31)+i_thruDay    = input.int(defval = 1,       title = "[Backtest] Thru Day", minval = 1, maxval = 31)-i_thruYear   = input(defval = 2345,    title = "[Backtest] Thru Year",       type = input.integer, minval = 1970)+i_thruYear   = input.int(defval = 2345,    title = "[Backtest] Thru Year", minval = 1970)// === DATE & TIME RANGE FUNCTIONS ===⋯i_ma_type   = input("EMA", title="[MA Filter] type", options = ["SMA", "EMA"])-shortTermXtrender = rsi( ema(close, i_short_l1) - ema(close, i_short_l2), i_short_l3 ) - 50+shortTermXtrender = ta.rsi( ta.ema(close, i_short_l1) - ta.ema(close, i_short_l2), i_short_l3 ) - 50-longTermXtrender  = rsi( ema(close, i_long_l1), i_long_l2 ) - 50+longTermXtrender  = ta.rsi( ta.ema(close, i_long_l1), i_long_l2 ) - 50shortXtrenderCol = shortTermXtrender > 0 ? shortTermXtrender > shortTermXtrender[1] ? color.lime : #228B22 : shortTermXtrender > shortTermXtrender[1] ? color.red : #8B0000-plot(shortTermXtrender, color=shortXtrenderCol, style=plot.style_columns, linewidth=1, title="B-Xtrender Osc. - Histogram", transp = 40)+plot(shortTermXtrender, color=color.new(shortXtrenderCol, 40), style=plot.style_columns, linewidth=1, title="B-Xtrender Osc. - Histogram")longXtrenderCol   = longTermXtrender> 0 ? longTermXtrender > longTermXtrender[1] ? color.lime : #228B22 : longTermXtrender > longTermXtrender[1] ? color.red : #8B0000macollongXtrenderCol =  longTermXtrender > longTermXtrender[1] ? color.lime : color.red-plot(longTermXtrender , color=longXtrenderCol, style=plot.style_columns, linewidth=2, title="B-Xtrender Trend - Histogram", transp = 90)+plot(longTermXtrender , color=color.new(longXtrenderCol, 90), style=plot.style_columns, linewidth=2, title="B-Xtrender Trend - Histogram")-plot(longTermXtrender , color=#000000             , style=plot.style_line, linewidth=5, title="B-Xtrender Trend - Line", transp = 100)+plot(longTermXtrender , color=color.new(#000000, 100)             , style=plot.style_line, linewidth=5, title="B-Xtrender Trend - Line")-plot(longTermXtrender , color=macollongXtrenderCol, style=plot.style_line, linewidth=3, title="B-Xtrender Trend - Line", transp = 100)+plot(longTermXtrender , color=color.new(macollongXtrenderCol, 100), style=plot.style_line, linewidth=3, title="B-Xtrender Trend - Line")// === INIT MA FILTER-ma = i_ma_type == "EMA" ? ema(close, i_ma_len) : sma(close, i_ma_len)+ma = i_ma_type == "EMA" ? ta.ema(close, i_ma_len) : ta.sma(close, i_ma_len)maFilterLong = true⋯closeShort = shortTermXtrender > 0 or longTermXtrender > 0 -plotshape(long[1]==true  and long[2]==false  ? 0 : na , location=location.absolute, style=shape.labelup  , color=color.lime, size=size.small, transp=10)+plotshape(long[1]==true  and long[2]==false  ? 0 : na , location=location.absolute, style=shape.labelup  , color=color.new(color.lime, 10), size=size.small)-plotshape(short[1]==true and short[2]==false ? 0 : na, location=location.absolute, style=shape.labeldown, color=color.red , size=size.small, transp=10)+plotshape(short[1]==true and short[2]==false ? 0 : na, location=location.absolute, style=shape.labeldown, color=color.new(color.red, 10) , size=size.small)plotshape(closeLong[1]==true and closeLong[2]==false⋯    stopValue = close - sl_val-    max(stopValue, longStopPrice[1])+    math.max(stopValue, longStopPrice[1])else⋯    stopValue = close + sl_val-    min(stopValue, shortStopPrice[1])+    math.min(stopValue, shortStopPrice[1])else⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 22: input() → input.int()
  • Line 23: input() → input.int()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 28: input() → input.bool()
7 more edits
  • Line 29: input() → input.int()
  • Line 30: input() → input.string()
  • Line 55: input() → input.float()
  • Line 63: when = toLong → if block
  • Line 64: when = closeLong → if block
  • Line 65: when = toShort → if block
  • Line 66: when = closeShort → if block
⋯// === LONG/ SHORT EXTRENDER SELECTION ===-i_short_l1  = input(5 , title="[Short] L1")+i_short_l1  = input.int(5 , title="[Short] L1")-i_short_l2  = input(20, title="[Short] L2")+i_short_l2  = input.int(20, title="[Short] L2")-i_short_l3  = input(15, title="[Short] L3")+i_short_l3  = input.int(15, title="[Short] L3")-i_long_l1   = input(20, title="[Long] L1")+i_long_l1   = input.int(20, title="[Long] L1")-i_long_l2   = input(15, title="[Long] L2")+i_long_l2   = input.int(15, title="[Long] L2")// === TSL SELECTION ===-i_ma_use    = input(true , title="[MA Filter] Yes/No" )+i_ma_use    = input.bool(true , title="[MA Filter] Yes/No" )-i_ma_len    = input(200  , title="[MA Filter] length" )+i_ma_len    = input.int(200  , title="[MA Filter] length" )-i_ma_type   = input("EMA", title="[MA Filter] type", options = ["SMA", "EMA"])+i_ma_type   = input.string("EMA", title="[MA Filter] type", options = ["SMA", "EMA"])shortTermXtrender = ta.rsi( ta.ema(close, i_short_l1) - ta.ema(close, i_short_l2), i_short_l3 ) - 50⋯ or closeShort[1]==true and closeShort[2]==false ? 0 : na, location=location.absolute, style=shape.circle, color=color.orange , size=size.small)-i_perc     = input(defval = 20.0, title = "[TSL-%] Percent"  , minval = 0.1 )+i_perc     = input.float(defval = 20.0, title = "[TSL-%] Percent"  , minval = 0.1 )i_src = close // constant for calculation⋯    strategy.close_all()-strategy.entry("Long", strategy.long, when = toLong ) +if toLong+    strategy.entry("Long", strategy.long ) -strategy.close("Long", when = closeLong)+if closeLong+    strategy.close("Long")-strategy.entry("Short", strategy.short, when = toShort) +if toShort+    strategy.entry("Short", strategy.short) -strategy.close("Short", when = closeShort)+if closeShort+    strategy.close("Short")// Calculate SL⋯

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

⋯// © QuantTherapy-//@version=5+//@version=6strategy("B-Xtrender [Backtest Edition] @QuantTherapy")⋯

Settings

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

SettingDefaultType and rangeFeeds
[Backtest] From Month1int (written input.integer) · min 1 · max 12start
[Backtest] From Day1int (written input.integer) · min 1 · max 31start
[Backtest] From Year2010int (written input.integer) · min 1970start
[Backtest] Thru Month1int (written input.integer) · min 1 · max 12finish
[Backtest] Thru Day1int (written input.integer) · min 1 · max 31finish
[Backtest] Thru Year2345int (written input.integer) · min 1970finish
[Backtest] Trade Directionstrategy.direction.allvalue · options [strategy.direction.all, strategy.direction.long, strategy.direction.short]line 20
[Short] L15intshortTermXtrender
[Short] L220intshortTermXtrender
[Short] L315intshortTermXtrender
[Long] L120intlongTermXtrender
[Long] L215intlongTermXtrender
[MA Filter] Yes/Notrueboolline 44
[MA Filter] length200intma
[MA Filter] typeEMAstring · options ["SMA", "EMA"]ma
[TSL-%] Percent20.0float · min 0.1sl_val

What it calculates

  • RSI / EMA (rsi, ta.rsi in v5)ema(close, i_short_l1) - ema(close, i_short_l2), [Short] L3 (15)shortTermXtrender · line 31
  • RSI / EMA (rsi, ta.rsi in v5)ema(close, i_long_l1), [Long] L2 (15)longTermXtrender · line 32
  • EMA / SMA (ema, ta.ema in v5)close, [MA Filter] length (200) · chosen by [MA Filter] typema · line 41

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 datai_short_l1[Short] L1setting · 5i_short_l2[Short] L2setting · 20i_short_l3[Short] L3setting · 15i_long_l1[Long] L1setting · 20i_long_l2[Long] L2setting · 15i_ma_type[MA Filter] typesetting · EMAi_ma_len[MA Filter] lengthsetting · 200i_fromYear[Backtest] From Yearsetting · 2010i_fromMonth[Backtest] From Monthsetting · 1i_fromDay[Backtest] From Daysetting · 1i_thruYear[Backtest] Thru Yearsetting · 2345i_thruMonth[Backtest] Thru Monthsetting · 1i_thruDay[Backtest] Thru Daysetting · 1i_perc[TSL-%] Percentsetting · 20.0timetimeprice datashortTermXtrenderRSI / EMA→ shortTermXtrenderlongTermXtrenderRSI / EMA→ longTermXtrendermaEMA / SMA→ ma · by [MA Filter] typestartstartvaluefinishfinishvaluemaFilterLong, maFilterShortmaFilterLong · maFilter…2 valuesi_srci_srcvaluesl_valsl_valvaluestopValuestopValuevaluecloseLongcloseLongconditioncloseShortcloseShortconditiontoLongtoLongconditiontoShorttoShortconditionisDateisDateconditionlong, shortlong · short2 conditionslongStopPricelongStopPriceconditionshortXtrenderCol, longXtrenderCol, macollongXtrenderCol, shortStopPriceColourshortXtrenderCol · longXtrend…close_all:close_all strategy.close_allentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeexit:TSL Longexit TSL Longstrategy.exitexit:TSL Shortexit TSL Shortstrategy.exitplot:34B-Xtrender Osc. - Histo…plotplot:37B-Xtrender Trend - Hist…plotplot:38B-Xtrender Trend - Lineplotplot:39B-Xtrender Trend - Lineplotplotshape:51plotshapeplotshapeplotshape:52plotshapeplotshapeplotshape:53plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Close not f_isDate() and strategy.position_size != 0On62
Open Long longtoLonglong and f_isDate()On63
Close LongcloseLongshortTermXtrender < 0 or longTermXtrender < 0On64
Open Short shorttoShortshort and f_isDate()On65
Close ShortcloseShortshortTermXtrender > 0 or longTermXtrender > 0On66
Exit TSL Long stop(strategy.position_size > 0)On88
Exit TSL Short stop(strategy.position_size < 0)On90

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.

38/38trades 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+24.3%+102.5%8749%1.2826.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+12.9%+5.5%7653%1.884.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.7%+9.8%3238%1.171.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%3324%1.040.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%3043%1.830.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%2931%1.040.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%3933%0.820.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%3132%1.130.1%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 market1136%$4,825.08
Sideways market3656%$5,976.91
Falling market4048%$13,517.80

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

How bad could the drawdown be?

31.1%

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

0%36%
All 87 trades
SideEntryExitBarsP&L
short13 Aug 2024 59,346.6014 Aug 2024 60,587.201−$1,240.52
short15 Aug 2024 58,683.4016 Aug 2024 57,541.101$1,142.34
short17 Aug 2024 58,874.6018 Aug 2024 59,492.001−$617.40
short19 Aug 2024 58,427.3020 Aug 2024 59,438.501−$1,011.15
short30 Aug 2024 59,359.0031 Aug 2024 59,124.001$235.01
short1 Sep 2024 58,974.002 Sep 2024 57,301.801$1,672.23
short3 Sep 2024 59,132.104 Sep 2024 57,487.701$1,644.38
short5 Sep 2024 57,970.906 Sep 2024 56,180.001$1,790.90
short7 Sep 2024 53,963.008 Sep 2024 54,160.901−$197.89
short9 Sep 2024 54,869.9010 Sep 2024 57,042.001−$2,172.06
short11 Sep 2024 57,636.0012 Sep 2024 57,338.001$297.99
long21 Sep 2024 63,201.102 Oct 2024 60,804.9011−$2,396.13
long15 Oct 2024 66,084.0027 Oct 2024 67,092.8012$1,008.76
long29 Oct 2024 69,962.204 Nov 2024 68,776.006−$1,186.22
long7 Nov 2024 75,572.0027 Nov 2024 91,965.2020$16,393.20
long17 Dec 2024 106,059.0019 Dec 2024 100,204.002−$5,854.64
long7 Jan 2025 102,236.009 Jan 2025 95,060.602−$7,174.99
long16 Jan 2025 100,497.0029 Jan 2025 101,336.0013$838.17
long31 Jan 2025 104,723.001 Feb 2025 102,430.001−$2,293.38
short27 Feb 2025 84,250.1028 Feb 2025 84,708.601−$458.48
short1 Mar 2025 84,349.902 Mar 2025 86,064.501−$1,714.59
short10 Mar 2025 80,734.5011 Mar 2025 78,595.901$2,138.62
short12 Mar 2025 82,933.0013 Mar 2025 83,680.101−$747.13
short14 Mar 2025 81,115.8015 Mar 2025 83,983.201−$2,867.41
short7 Apr 2025 78,430.008 Apr 2025 79,163.201−$733.24
short9 Apr 2025 76,322.4010 Apr 2025 82,615.201−$6,292.80
short11 Apr 2025 79,607.3012 Apr 2025 83,423.801−$3,816.53
long23 Apr 2025 93,443.0027 May 2025 109,435.0034$15,991.80
long11 Jun 2025 110,274.0013 Jun 2025 105,672.002−$4,602.65
long27 Jun 2025 106,947.0025 Jul 2025 118,341.0028$11,393.90
long12 Aug 2025 118,686.0017 Aug 2025 117,381.005−$1,305.34
long17 Sep 2025 116,789.0023 Sep 2025 112,651.006−$4,137.97
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$5,820.50
short18 Oct 2025 106,432.0019 Oct 2025 107,185.001−$753.32
short23 Oct 2025 107,567.0024 Oct 2025 110,078.001−$2,510.74
short31 Oct 2025 108,323.001 Nov 2025 109,608.001−$1,285.14
short4 Nov 2025 106,583.005 Nov 2025 101,497.001$5,085.82
short6 Nov 2025 103,885.007 Nov 2025 101,346.001$2,539.12
short8 Nov 2025 103,339.009 Nov 2025 102,313.001$1,026.14
short10 Nov 2025 104,723.0011 Nov 2025 106,011.001−$1,288.18
short12 Nov 2025 103,059.0013 Nov 2025 101,654.001$1,404.63
short14 Nov 2025 99,692.0015 Nov 2025 94,594.001$5,098.03
short16 Nov 2025 95,596.2017 Nov 2025 94,261.401$1,334.78
short18 Nov 2025 92,215.1019 Nov 2025 92,960.801−$745.69
short20 Nov 2025 91,555.0021 Nov 2025 86,637.201$4,917.74
short22 Nov 2025 85,129.4023 Nov 2025 84,739.801$389.67
short24 Nov 2025 86,830.0025 Nov 2025 88,300.001−$1,470.01
short26 Nov 2025 87,370.0027 Nov 2025 90,484.001−$3,114.04
short18 Dec 2025 86,243.2019 Dec 2025 85,516.401$726.82
short26 Jan 2026 86,670.4027 Jan 2026 88,347.101−$1,676.72
short28 Jan 2026 89,250.0029 Jan 2026 89,300.001−$50.01
short30 Jan 2026 84,650.2031 Jan 2026 84,260.501$389.66
short1 Feb 2026 78,741.102 Feb 2026 76,968.201$1,772.88
short3 Feb 2026 78,738.604 Feb 2026 75,770.201$2,968.39
short5 Feb 2026 73,165.806 Feb 2026 62,909.901$10,256.00
short7 Feb 2026 70,580.308 Feb 2026 69,289.401$1,290.89
short9 Feb 2026 70,330.4010 Feb 2026 70,138.001$192.38
short11 Feb 2026 68,841.3012 Feb 2026 67,082.501$1,758.76
short13 Feb 2026 66,272.2014 Feb 2026 68,854.001−$2,581.80
short15 Feb 2026 69,822.9016 Feb 2026 68,832.601$990.35
short23 Mar 2026 67,859.0024 Mar 2026 70,906.401−$3,047.45
short28 Mar 2026 66,407.3029 Mar 2026 66,377.001$30.24
short30 Mar 2026 66,010.9031 Mar 2026 66,797.401−$786.45
short1 Apr 2026 68,284.502 Apr 2026 68,113.901$170.57
short3 Apr 2026 66,902.004 Apr 2026 66,964.301−$62.30
short5 Apr 2026 67,300.406 Apr 2026 69,034.201−$1,733.76
long11 May 2026 82,210.1014 May 2026 79,313.603−$2,896.46
short29 May 2026 73,617.5030 May 2026 73,460.801$156.74
short31 May 2026 73,884.401 Jun 2026 73,674.401$209.99
short2 Jun 2026 71,408.903 Jun 2026 66,760.801$4,648.06
short4 Jun 2026 64,142.805 Jun 2026 63,886.001$256.76
short6 Jun 2026 61,056.507 Jun 2026 60,884.601$171.85
short8 Jun 2026 63,332.009 Jun 2026 63,086.001$246.01
short10 Jun 2026 61,730.0011 Jun 2026 61,511.001$219.01
short12 Jun 2026 63,626.0013 Jun 2026 63,580.001$46.00
short14 Jun 2026 64,458.0015 Jun 2026 65,746.401−$1,288.44
short26 Jun 2026 59,794.6027 Jun 2026 60,097.301−$302.63
short28 Jun 2026 60,029.0029 Jun 2026 59,577.001$452.00
short30 Jun 2026 60,260.201 Jul 2026 58,624.701$1,635.49
short2 Aug 2026 62,823.703 Aug 2026 63,570.001−$746.36
short4 Aug 2026 63,520.005 Aug 2026 64,106.601−$586.55
short13 Aug 2026 63,480.0014 Aug 2026 63,490.901−$10.87
short15 Aug 2026 63,043.6016 Aug 2026 63,086.001−$42.45
short17 Aug 2026 62,900.0018 Aug 2026 64,532.101−$1,632.11
long21 Aug 2026 73,027.003 Sep 2026 77,340.0013$4,312.99
long4 Sep 2026 81,270.408 Sep 2026 79,112.004−$2,158.37
long21 Sep 2026 81,178.0030 Sep 2026 83,663.709$2,485.65

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
B-Xtrender [Backtest Edition] @QuantTherapy this page—v4 strategy+24.3%8726.7%
MACD, RSI, & RVOL Strategy by BobBarker42069rsi ema smav4 strategy+32.6%11.5%
IFR2 - RSI2 by jocker.soadrsi sma emav4 strategyNo trades on this market
Vin's Playzone Strategy by Vvaz_ema rsi smav5 strategy−908.1%213,570.5%
Momentum Explosion 2CCI RSI by capamema sma rsiv4 strategy+24.1%642.3%
3 x EMA + Stochastic RSI + ATR by tomimarsonema rsi smav4 strategy−42.3%1844.8%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 27 msYes 1,000 bars in 75 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/// © QuantTherapy//@version=4strategy("B-Xtrender [Backtest Edition] @QuantTherapy")// === DATE & TIME SELECTION ===i_fromMonth  = input(defval = 1,       title = "[Backtest] From Month",      type = input.integer, minval = 1, maxval = 12)i_fromDay    = input(defval = 1,       title = "[Backtest] From Day",        type = input.integer, minval = 1, maxval = 31)i_fromYear   = input(defval = 2010,    title = "[Backtest] From Year",       type = input.integer, minval = 1970)i_thruMonth  = input(defval = 1,       title = "[Backtest] Thru Month",      type = input.integer, minval = 1, maxval = 12)i_thruDay    = input(defval = 1,       title = "[Backtest] Thru Day",        type = input.integer, minval = 1, maxval = 31)i_thruYear   = input(defval = 2345,    title = "[Backtest] Thru Year",       type = input.integer, minval = 1970)// === DATE & TIME RANGE FUNCTIONS ===f_isDate() =>                                                      // create function "within window of dates"    start  = timestamp(i_fromYear, i_fromMonth, i_fromDay, 00, 00)     // date start    finish = timestamp(i_thruYear, i_thruMonth, i_thruDay, 23, 59)     // date finish    isDate = time >= start and time <= finish                    // current date is "within window of dates"    // === TRADE DIRECTION ===i_tradeDirection = input(title="[Backtest] Trade Direction", defval=strategy.direction.all, options=[strategy.direction.all, strategy.direction.long, strategy.direction.short])    strategy.risk.allow_entry_in(i_tradeDirection)// === LONG/ SHORT EXTRENDER SELECTION ===i_short_l1  = input(5 , title="[Short] L1")i_short_l2  = input(20, title="[Short] L2")i_short_l3  = input(15, title="[Short] L3")i_long_l1   = input(20, title="[Long] L1")i_long_l2   = input(15, title="[Long] L2")// === TSL SELECTION ===i_ma_use    = input(true , title="[MA Filter] Yes/No" )i_ma_len    = input(200  , title="[MA Filter] length" )i_ma_type   = input("EMA", title="[MA Filter] type", options = ["SMA", "EMA"])shortTermXtrender = rsi( ema(close, i_short_l1) - ema(close, i_short_l2), i_short_l3 ) - 50longTermXtrender  = rsi( ema(close, i_long_l1), i_long_l2 ) - 50shortXtrenderCol = shortTermXtrender > 0 ? shortTermXtrender > shortTermXtrender[1] ? color.lime : #228B22 : shortTermXtrender > shortTermXtrender[1] ? color.red : #8B0000plot(shortTermXtrender, color=shortXtrenderCol, style=plot.style_columns, linewidth=1, title="B-Xtrender Osc. - Histogram", transp = 40)longXtrenderCol   = longTermXtrender> 0 ? longTermXtrender > longTermXtrender[1] ? color.lime : #228B22 : longTermXtrender > longTermXtrender[1] ? color.red : #8B0000macollongXtrenderCol =  longTermXtrender > longTermXtrender[1] ? color.lime : color.redplot(longTermXtrender , color=longXtrenderCol, style=plot.style_columns, linewidth=2, title="B-Xtrender Trend - Histogram", transp = 90)plot(longTermXtrender , color=#000000             , style=plot.style_line, linewidth=5, title="B-Xtrender Trend - Line", transp = 100)plot(longTermXtrender , color=macollongXtrenderCol, style=plot.style_line, linewidth=3, title="B-Xtrender Trend - Line", transp = 100)// === INIT MA FILTERma = i_ma_type == "EMA" ? ema(close, i_ma_len) : sma(close, i_ma_len)maFilterLong = truemaFilterShort = trueif i_ma_use    maFilterLong  := close > ma ? true : false    maFilterShort := close < ma ? true : falselong  = shortTermXtrender > 0 and longTermXtrender > 0 and maFilterLongcloseLong = shortTermXtrender < 0 or longTermXtrender < 0 short = shortTermXtrender < 0 and longTermXtrender < 0 and maFilterShortcloseShort = shortTermXtrender > 0 or longTermXtrender > 0 plotshape(long[1]==true  and long[2]==false  ? 0 : na , location=location.absolute, style=shape.labelup  , color=color.lime, size=size.small, transp=10)plotshape(short[1]==true and short[2]==false ? 0 : na, location=location.absolute, style=shape.labeldown, color=color.red , size=size.small, transp=10)plotshape(closeLong[1]==true and closeLong[2]==false or closeShort[1]==true and closeShort[2]==false ? 0 : na, location=location.absolute, style=shape.circle, color=color.orange , size=size.small)i_perc     = input(defval = 20.0, title = "[TSL-%] Percent"  , minval = 0.1 )i_src = close // constant for calculationsl_val = i_src * i_perc / 100toLong = long and f_isDate()toShort = short and f_isDate()// === WHEN POSITION IS OPEN AN DATE IS OUT OF BOUND CLOSE ALL TRADESif not f_isDate() and strategy.position_size != 0    strategy.close_all()strategy.entry("Long", strategy.long, when = toLong ) strategy.close("Long", when = closeLong)strategy.entry("Short", strategy.short, when = toShort) strategy.close("Short", when = closeShort)// Calculate SLlongStopPrice = 0.0, shortStopPrice = 0.0longStopPrice := if (strategy.position_size > 0)    stopValue = close - sl_val    max(stopValue, longStopPrice[1])else    0shortStopPrice := if (strategy.position_size < 0)    stopValue = close + sl_val    min(stopValue, shortStopPrice[1])else    syminfo.mintick*1000000// For TSL Visualisation on Chart    // plot(series=(strategy.position_size > 0) ? longStopPrice : na,//      color=color.fuchsia, style = plot.style_circles,//      linewidth=1, title="Long Trail Stop")     // plot(series=(strategy.position_size < 0) ? shortStopPrice : na,//      color=color.fuchsia, style = plot.style_circles,//      linewidth=1, title="Short Trail Stop")if (strategy.position_size > 0)    strategy.exit(id="TSL Long", stop=longStopPrice)if (strategy.position_size < 0)    strategy.exit(id="TSL Short", stop=shortStopPrice)