Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

[MACLEN] TRUE RANGE

A Pine Script v5 strategy built on TR and WMA (sube, 10). It has 8 order rules, 5 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is 0.1 contracts and pays 0.08% commission. 10 settings; defaults include Corto 10, Largo 30 and Suavizado 10.

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 [MACLEN] TRUE RANGE repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did [MACLEN] TRUE RANGE do on BTCUSDT 1D with default settings?
+2.51%
From 26 Jan 2024 to 21 Oct 2026, over 27 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does [MACLEN] TRUE RANGE 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: 27 before, 27 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does [MACLEN] TRUE RANGE use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does [MACLEN] TRUE RANGE run in Zeal Terminal?
Yes
It compiles in 77 ms and runs 1,000 bars in 69 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 (10)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctPlot$1,025$2,025Equity from $1,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.
Table drawn by the script, as it stood on the last bar
Open P/L= 0 Price Change = NaN% Capital Usado = 0
Net profit
+2.51%
$25.11
Buy and hold
+102.5%
same period
Closed trades
27
15 won · 12 lost
Profitable
55.6%
of closed trades
Profit factor
1.30
gross profit ÷ gross loss
Max drawdown
3.48%
−$35.04

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

    1 setting does nothing

    “Porc tp” is declared but never read.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Note

    6 settings have no label

    In the settings dialog corto (line 12), largo (line 13), suavizado (line 14), lev (line 26), porc_tp (line 38), safe (line 39) show an empty name. The labels on this page come from the variable names.

Settings

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

SettingDefaultType and rangeFeeds
Backtest Window
Start Timetimestamp("01 Jan 2022 00:00 -0700")timewindow
End Timetimestamp("31 Dec 2025 00:00 -0700")timewindow
Largo (no label in the script)30intslowDiff
Suavizado (no label in the script)10intind
Lev (no label in the script)2intcontrato1 labelText close_all close_all line 61
Porc tp (no label in the script)6.5float · step 0.1unused
Safe (no label in the script)-6.0float · step 0.1entry SAFE1 entry SAFE2 entry SAFE3 entry SAFE4 line 45 line 48 line 51 line 54
StopLoss-5.0float · step 0.1close_all line 65
Configuración
Corto (no label in the script)10intfastDiff
Gestión de Riesgo
Capital Inicial1000intcontrato1

What it calculates

  • TRsube · line 10
  • TRbaja · line 11
  • WMAsube, Corto (10)fastDiff · line 15
  • WMAsube, Largo (30)slowDiff · line 16
  • WMAfastDiff - slowDiff, Suavizado (10)ind · line 17

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.

high · low · closehigh · low · closeprice dataclosecloseprice datacortoCortosetting · 10largoLargosetting · 30suavizadoSuavizadosetting · 10capitalCapital Inicialsetting · 1000levLevsetting · 2timetimeprice datai_startTimeStart Timesetting · timestamp("01 Jan 2…i_endTimeEnd Timesetting · timestamp("31 Dec 2…safeSafesetting · -6.0slStopLosssetting · -5.0subeTR→ subebajaTR→ bajafastDiffWMA→ fastDiffslowDiffWMA→ slowDiffindWMA→ indcontrato1contrato1valuec1, c2, c3, c4, c5c1 · c2 +35 valueschangechangevalueusedusedvaluedisplaydisplayvaluelabelTextlabelTextvaluewindowwindowconditionlonglongconditionshortshortconditionmin_profmin_profconditioniColorColouriColorentry:BUYOpen BUYstrategy.entryentry:SAFE1Open SAFE1strategy.entryentry:SAFE2Open SAFE2strategy.entryentry:SAFE3Open SAFE3strategy.entryentry:SAFE4Open SAFE4strategy.entryclose_all:close_all strategy.close_allplot:19plotplotplot:20plotplotplotshape:23plotshapeplotshapeplotshape:24plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open BUY longstrategy.opentrades == 0 and long and not long[1] and windowOn43
Open SAFE1 longstrategy.opentrades == 1 and long and not long[1] and window and change<safeOn46
Open SAFE2 longstrategy.opentrades == 2 and long and not long[1] and window and change<safeOn49
Open SAFE3 longstrategy.opentrades == 3 and long and not long[1] and window and change<safeOn52
Open SAFE4 longstrategy.opentrades == 4 and long and not long[1] and window and change<safeOn55
Close (short and min_prof)On59
Close math.abs(strategy.openprofit) >= (used/lev)On62
Close change<=slOn66

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 1D+2.5%+102.5%2756%1.303.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−6.6%+9.8%3033%0.6310.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.6%+16.7%3043%0.977.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+4.9%+148.3%3358%1.412.5%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.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market956%$23.44
Sideways market1450%−$12.70
Falling market475%$14.36

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

How bad could the drawdown be?

5.2%

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

0%6%
All 27 trades
SideEntryExitBarsP&L
long25 Mar 2024 67,210.005 Apr 2024 68,487.8011$2.17
long21 Apr 2024 64,940.601 May 2024 60,672.0010−$8.41
long5 May 2024 63,892.0023 May 2024 69,166.6018$10.11
long3 Jun 2024 67,765.609 Jun 2024 69,310.506$2.65
long18 Jun 2024 66,504.3025 Jun 2024 60,293.307−$11.86
long27 Jun 2024 60,865.005 Jul 2024 57,050.008−$8.03
long10 Aug 2024 60,838.0016 Aug 2024 57,541.106−$6.97
long6 Sep 2024 56,180.0025 Sep 2024 64,262.7019$17.77
long13 Oct 2024 63,206.2023 Oct 2024 67,426.0010$8.14
long8 Nov 2024 75,857.9017 Nov 2024 90,588.009$24.05
long5 Dec 2024 98,587.3031 Dec 2024 92,792.1026−$7.54
long2 Jan 2025 94,591.8011 Jan 2025 94,726.109−$0.02
long19 Jan 2025 104,556.0031 Jan 2025 104,723.0012−$0.00
long11 Feb 2025 97,430.8025 Feb 2025 91,552.9014−$7.74
long4 Mar 2025 86,221.2010 Mar 2025 80,734.506−$8.15
long5 Apr 2025 83,889.907 Apr 2025 78,430.002−$8.33
long9 Apr 2025 76,322.4019 Apr 2025 84,474.7010$13.14
long8 May 2025 97,030.5019 Jun 2025 104,887.0042$9.91
long26 Jun 2025 107,341.006 Jul 2025 108,198.0010$0.80
long5 Aug 2025 115,055.0016 Aug 2025 117,342.0011$2.28
long24 Aug 2025 115,438.0030 Aug 2025 108,377.006−$7.84
long1 Sep 2025 108,246.008 Sep 2025 111,137.007$3.14
long30 Sep 2025 114,312.009 Oct 2025 123,306.009$9.63
long20 Oct 2025 108,643.001 Nov 2025 109,608.0012$0.91
long9 Nov 2025 102,313.0015 Nov 2025 94,594.006−$9.62
long25 Nov 2025 88,300.006 Dec 2025 89,330.0011$1.26
long23 Dec 2025 88,620.808 Jan 2026 91,364.2016$3.67

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.

  • 4 settings use the untyped input() (line 12, 13, 14, 28). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
  • Line 28: input() → input.int()
⋯baja = close<close[1] ? ta.tr : 0-corto = input(10, group="Configuración")+corto = input.int(10, group="Configuración")-largo = input(30)+largo = input.int(30)-suavizado = input(10)+suavizado = input.int(10)fastDiff = ta.wma(sube, corto) - ta.wma(baja,corto)⋯//Contratos-capital = input(defval=1000, title="Capital Inicial", group="Gestión de Riesgo")+capital = input.int(defval=1000, title="Capital Inicial", group="Gestión de Riesgo")contrato1 = (capital*lev)/(16*close)⋯

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

⋯// © MaclenMtz-//@version=5+//@version=6strategy("[MACLEN] Rangos", shorttitle="Rangos [https://t.me/Bitcoin_Maclen]", overlay=false, slippage=0, initial_capital=1000, currency=currency.USD, default_qty_type=strategy.fixed, default_qty_value=0.1, pyramiding=5, commission_type=strategy.commission.percent, commission_value=0.08)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 77 msYes 1,000 bars in 69 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/// © MaclenMtz//@version=5strategy("[MACLEN] Rangos", shorttitle="Rangos [https://t.me/Bitcoin_Maclen]", overlay=false, slippage=0, initial_capital=1000, currency=currency.USD, default_qty_type=strategy.fixed, default_qty_value=0.1, pyramiding=5, commission_type=strategy.commission.percent, commission_value=0.08)//------WINDOW----------i_startTime = input.time(defval = timestamp("01 Jan 2022 00:00 -0700"), title = "Start Time", group = "Backtest Window")i_endTime = input.time(defval = timestamp("31 Dec 2025 00:00 -0700"), title = "End Time")window = time >= i_startTime and time <= i_endTime//-----------------------------sube = close>close[1] ? ta.tr : 0baja = close<close[1] ? ta.tr : 0corto = input(10, group="Configuración")largo = input(30)suavizado = input(10)fastDiff = ta.wma(sube, corto) - ta.wma(baja,corto)slowDiff = ta.wma(sube, largo) - ta.wma(baja, largo)ind = ta.wma(fastDiff - slowDiff, suavizado)iColor = ind>0 ? color.green : ind<0 ? color.red : color.blackplot(ind, color=iColor)plot(0, color=color.white)long = ind[1]<ind and ind[2]<ind[1] and ind<0short = ind[1]>ind and ind[2]>ind[1] and ind>0plotshape(long and not long[1], style = shape.xcross, color=color.green, location=location.bottom, size=size.tiny)plotshape(short and not short[1], style = shape.xcross, color=color.red, location=location.top, size=size.tiny)//Apalancamientolev = input.int(2)//Contratoscapital = input(defval=1000, title="Capital Inicial", group="Gestión de Riesgo")contrato1 = (capital*lev)/(16*close)c1 = contrato1c2 = contrato1c3 = contrato1*2c4 = contrato1*4c5 = contrato1*8//cap_enopentrade = strategy.opentrades == 1 ? c1: strategy.opentrades == 2 ? c1+c2: strategy.opentrades == 3 ? c1+c2+c3: strategy.opentrades == 4 ? c1+c2+c3+c4: strategy.opentrades == 5 ? c1+c2+c3+c4+c5 : 0change = math.round((close-strategy.position_avg_price)/strategy.position_avg_price * 100,2)var float used = 0porc_tp = input.float(6.5, step=0.1)safe = input.float(-6.0, step=0.1)sl = input.float(-5.0, title="StopLoss", step=0.1)//----------------Strategy---------------------------if strategy.opentrades == 0 and long and not long[1] and window    strategy.entry('BUY', strategy.long, qty=c1, comment="Buy")    used := used + (c1*close)if strategy.opentrades == 1 and long and not long[1] and window and change<safe    strategy.entry('SAFE1', strategy.long, qty=c2, comment="Safe1")    used := used + (c2*close)if strategy.opentrades == 2 and long and not long[1] and window and change<safe    strategy.entry('SAFE2', strategy.long, qty=c3, comment="Safe2")    used := used + (c3*close)if strategy.opentrades == 3 and long and not long[1] and window and change<safe    strategy.entry('SAFE3', strategy.long, qty=c4, comment="Safe3")    used := used + (c4*close)if strategy.opentrades == 4 and long and not long[1] and window and change<safe    strategy.entry('SAFE4', strategy.long, qty=c5, comment="Safe4")    used := used + (c5*close)min_prof = strategy.openprofit>0if (short and min_prof)    strategy.close_all(comment="Close (Profit= "+ str.tostring(math.round(change,2)*lev)+"%)")    used := 0if math.abs(strategy.openprofit) >= (used/lev)    strategy.close_all(comment="LIQ")    used := 0    if change<=sl    strategy.close_all(comment="SL")    used := 0//plot (strategy.openprofit)//plot(strategy.position_size)//plot(change)//plot(used/lev)var table display = table.new(position.top_right,1,1)labelText = "Open P/L= " + str.tostring(math.round(strategy.openprofit,2)) + "\n" + "Price Change = " + str.tostring(change) + "%" + "\n" + "Capital Usado = " + str.tostring(used/lev)table.cell(display,0,0, labelText, text_size=size.normal)