Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Moving Average Band - Taylor V1

A Pine Script v4 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 and a profit target. Each trade commits 1000 in cash and pays .1 commission. 6 settings; defaults include Source close, Moving Average Type RMA and MA Period : 10 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 Moving Average Band - Taylor V1 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 Moving Average Band - Taylor V1 do on BTCUSDT 1D with default settings?
+57.30%
From 26 Jan 2024 to 21 Oct 2026, over 88 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Moving Average Band - Taylor V1 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 Moving Average Band - Taylor V1 use a stop loss?
Yes
strategy.exit sets a stop on line 53, 55.
Does Moving Average Band - Taylor V1 run in Zeal Terminal?
Yes
It compiles in 17 ms and runs 1,000 bars in 37 ms, in the browser.

BTCUSDT · 1D · default settings

  • Upper MA Band
  • Lower MA Band
  • 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 (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,580$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.
Net profit
+57.30%
$572.96
Buy and hold
+102.5%
same period
Closed trades
88
29 won · 59 lost
Profitable
33.0%
of closed trades
Profit factor
1.30
gross profit ÷ gross loss
Max drawdown
32.36%
−$450.02

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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

    “Source” is declared but never read.

  • 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, ema → ta.ema, wma → ta.wma, rma → ta.rma.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 10: sma → ta.sma
  • Line 13: ema → ta.ema
  • Line 16: wma → ta.wma
  • Line 19: rma → ta.rma
  • Line 22: sma → ta.sma
5 more edits
  • Line 25: ema → ta.ema
  • Line 28: wma → ta.wma
  • Line 31: rma → ta.rma
  • Line 45: input(type = input.float) → input.float()
  • Line 46: input(type = input.float) → input.float()
⋯// © TaylorTneh-//@version=4+//@version=5strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)⋯mabup = if mabtype == "SMA"-    sma(high, malen)+    ta.sma(high, malen)else    if mabtype == "EMA"-        ema(high, malen)+        ta.ema(high, malen)    else        if mabtype == "WMA"-            wma(high, malen)+            ta.wma(high, malen)        else            if mabtype == "RMA"-                rma(high, malen)+                ta.rma(high, malen)                    mabdn = if mabtype == "SMA"-    sma(low, malen)+    ta.sma(low, malen)else    if mabtype == "EMA"-        ema(low, malen)+        ta.ema(low, malen)    else        if mabtype == "WMA"-            wma(low, malen)+            ta.wma(low, malen)        else            if mabtype == "RMA"-                rma(low, malen)+                ta.rma(low, malen)                    ⋯//-------------------------------------------- (Take Profit & Stop Lose)-stopPer = input(500.0, title='# Stop Loss %', type=input.float) / 100+stopPer = input.float(500.0, title='# Stop Loss %') / 100-takePer = input(500.0, title='# Take Profit %', type=input.float) / 100+takePer = input.float(500.0, title='# Take Profit %') / 100//Determine where you've entered and in what direction⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.source()
  • Line 6: input() → input.string()
  • Line 7: input() → input.int()
  • Line 8: input() → input.float()
⋯strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)-price = input(close, title="Source")+price = input.source(close, title="Source")-mabtype = input(title="Moving Average Type", defval="RMA", options=["SMA", "EMA", "RMA", "WMA"])+mabtype = input.string(title="Moving Average Type", defval="RMA", options=["SMA", "EMA", "RMA", "WMA"])-malen = input(10, "MA Period : 10")+malen = input.int(10, "MA Period : 10")-magap = input(0.6, "Band Gap : 0.6", minval = -10, maxval = 10, step = 0.1)+magap = input.float(0.6, "Band Gap : 0.6", minval = -10, maxval = 10, step = 0.1)mabup = if mabtype == "SMA"⋯

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

⋯// © TaylorTneh-//@version=5+//@version=6strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)⋯

Settings

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

SettingDefaultType and rangeFeeds
Sourceclosesourceunused
Moving Average TypeRMAstring · options ["SMA", "EMA", "RMA", "WMA"]mabup mabdn
MA Period : 1010intmabup mabdn
Band Gap : 0.60.6float · min -10 · max 10 · step 0.1upex dnex
# Stop Loss %500.0floatlongStop shortStop
# Take Profit %500.0floatshortTake longTake

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.

magapBand Gap : 0.6setting · 0.6stopPer# Stop Loss %setting · 500.0takePer# Take Profit %setting · 500.0highhighprice datamabtypeMoving Average Typesetting · RMAmalenMA Period : 10setting · 10lowlowprice dataupexupexvaluednexdnexvaluelongStop, shortStoplongStop · shortStop2 valuesshortTake, longTakeshortTake · longTake2 valuesmabupmabupconditionmabdnmabdnconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:L-TP/SLexit L-TP/SLstrategy.exitexit:S-TP/SLexit S-TP/SLstrategy.exitplot:35Upper MA Bandplotplot:36Lower MA Bandplot

Order rules

OrderFires whenBy defaultLine
Open Long longevery barOn38
Open Short shortevery barOn39
Exit L-TP/SL stop and limitstrategy.position_size > 0On53
Exit S-TP/SL stop and limitstrategy.position_size < 0On55

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+57.3%+102.5%8833%1.3032.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−20.5%+5.5%7614%0.7529.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+160.5%+9.8%8930%1.6823.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−27.6%+8.4%8415%0.7633.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+53.0%+16.7%10135%1.1645.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+15.6%+21.5%7626%1.1621.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−33.6%+148.3%9925%0.8778.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−9.2%+17.1%7026%0.8620.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 market2825%−$724.56
Sideways market4639%$1,136.89
Falling market1429%$161.63

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

How bad could the drawdown be?

50.4%

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

0%58%
All 88 trades
SideEntryExitBarsP&L
long27 Jan 2024 41,823.5027 Jan 2024 41,823.500−$2.00
short27 Jan 2024 41,823.5028 Jan 2024 42,120.601−$9.11
long28 Jan 2024 42,120.6028 Jan 2024 42,120.600−$2.00
short28 Jan 2024 42,120.6029 Jan 2024 42,031.101$0.13
long29 Jan 2024 42,031.1029 Jan 2024 42,031.100−$2.00
short29 Jan 2024 42,031.1030 Jan 2024 43,302.701−$32.29
long30 Jan 2024 43,302.7030 Jan 2024 43,302.700−$2.00
short30 Jan 2024 43,302.7031 Jan 2024 42,941.101$6.36
long31 Jan 2024 42,941.1031 Jan 2024 42,941.100−$2.00
short31 Jan 2024 42,941.101 Feb 2024 42,580.001$6.42
long1 Feb 2024 42,580.001 Feb 2024 42,580.000−$2.00
short1 Feb 2024 42,580.002 Feb 2024 43,082.901−$13.82
long2 Feb 2024 43,082.902 Feb 2024 43,082.900−$2.00
short2 Feb 2024 43,082.903 Feb 2024 43,200.001−$4.72
long3 Feb 2024 43,200.003 Feb 2024 43,200.000−$2.00
short3 Feb 2024 43,200.004 Feb 2024 43,011.101$2.38
long4 Feb 2024 43,011.104 Feb 2024 43,011.100−$2.00
short4 Feb 2024 43,011.105 Feb 2024 43,411.101−$11.31
long5 Feb 2024 43,411.1019 Mar 2024 63,429.6043$458.68
short19 Mar 2024 63,429.6021 Mar 2024 68,156.702−$76.60
long21 Mar 2024 68,156.7022 Mar 2024 63,047.301−$76.89
short22 Mar 2024 63,047.3025 Mar 2024 67,932.203−$79.56
long25 Mar 2024 67,932.202 Apr 2024 66,007.508−$30.30
short2 Apr 2024 66,007.507 Apr 2024 69,748.505−$58.73
long7 Apr 2024 69,748.5012 Apr 2024 66,735.405−$45.16
short12 Apr 2024 66,735.406 May 2024 65,098.9024$22.55
long6 May 2024 65,098.908 May 2024 61,488.102−$57.41
short8 May 2024 61,488.1015 May 2024 64,132.107−$45.04
long15 May 2024 64,132.1011 Jun 2024 67,513.8027$50.68
short11 Jun 2024 67,513.8014 Jul 2024 61,172.9033$92.01
long14 Jul 2024 61,172.901 Aug 2024 63,741.8018$39.95
short1 Aug 2024 63,741.8021 Aug 2024 61,762.6020$29.08
long21 Aug 2024 61,762.6027 Aug 2024 59,696.706−$35.41
short27 Aug 2024 59,696.7013 Sep 2024 59,264.4017$5.25
long13 Sep 2024 59,264.401 Oct 2024 61,415.5018$34.26
short1 Oct 2024 61,415.507 Oct 2024 63,587.706−$37.40
long7 Oct 2024 63,587.709 Oct 2024 61,074.502−$41.48
short9 Oct 2024 61,074.5012 Oct 2024 63,466.903−$41.21
long12 Oct 2024 63,466.905 Dec 2024 91,089.1054$432.79
short5 Dec 2024 91,089.106 Dec 2024 96,945.601−$66.36
long6 Dec 2024 96,945.6019 Dec 2024 97,176.6013$0.38
short19 Dec 2024 97,176.603 Jan 2025 98,755.7015−$18.27
long3 Jan 2025 98,755.708 Jan 2025 94,956.105−$40.44
short8 Jan 2025 94,956.1015 Jan 2025 98,136.207−$35.52
long15 Jan 2025 98,136.2027 Jan 2025 98,708.2012$3.82
short27 Jan 2025 98,708.2029 Jan 2025 104,185.002−$57.54
long29 Jan 2025 104,185.002 Feb 2025 99,447.204−$47.42
short2 Feb 2025 99,447.202 Mar 2025 94,605.1028$46.74
long2 Mar 2025 94,605.103 Mar 2025 89,037.201−$60.79
short3 Mar 2025 89,037.2024 Mar 2025 87,302.1021$17.51
long24 Mar 2025 87,302.1028 Mar 2025 83,670.504−$43.56
short28 Mar 2025 83,670.502 Apr 2025 86,858.205−$40.14
long2 Apr 2025 86,858.203 Apr 2025 82,516.301−$51.94
short3 Apr 2025 82,516.3012 Apr 2025 85,010.309−$32.25
long12 Apr 2025 85,010.3031 May 2025 103,488.0049$215.15
short31 May 2025 103,488.009 Jun 2025 107,038.009−$36.34
long9 Jun 2025 107,038.0013 Jun 2025 104,104.004−$29.39
short13 Jun 2025 104,104.0016 Jun 2025 107,879.003−$38.30
long16 Jun 2025 107,879.0017 Jun 2025 103,922.001−$38.64
short17 Jun 2025 103,922.0025 Jun 2025 106,971.008−$31.37
long25 Jun 2025 106,971.001 Aug 2025 114,852.0037$71.60
short1 Aug 2025 114,852.007 Aug 2025 117,595.006−$25.91
long7 Aug 2025 117,595.0018 Aug 2025 115,536.0011−$19.49
short18 Aug 2025 115,536.0010 Sep 2025 113,789.0023$13.14
long10 Sep 2025 113,789.0022 Sep 2025 112,941.0012−$9.45
short22 Sep 2025 112,941.0030 Sep 2025 114,638.008−$17.04
long30 Sep 2025 114,638.0010 Oct 2025 116,265.0010$12.18
short10 Oct 2025 116,265.0026 Oct 2025 114,174.0016$16.00
long26 Oct 2025 114,174.0029 Oct 2025 109,803.003−$40.24
short29 Oct 2025 109,803.009 Dec 2025 93,614.5041$145.58
long9 Dec 2025 93,614.5014 Dec 2025 89,110.305−$50.07
short14 Dec 2025 89,110.3029 Dec 2025 90,318.7015−$15.57
long29 Dec 2025 90,318.7020 Jan 2026 90,997.0022$5.50
short20 Jan 2026 90,997.004 Mar 2026 70,241.1043$226.32
long4 Mar 2026 70,241.108 Mar 2026 66,587.304−$53.97
short8 Mar 2026 66,587.3010 Mar 2026 70,574.802−$61.94
long10 Mar 2026 70,574.8019 Mar 2026 68,810.909−$26.97
short19 Mar 2026 68,810.906 Apr 2026 69,883.0018−$17.60
long6 Apr 2026 69,883.0016 May 2026 77,836.4040$111.70
short16 May 2026 77,836.405 Jul 2026 63,547.8050$181.76
long5 Jul 2026 63,547.8028 Jul 2026 63,168.9023−$7.96
short28 Jul 2026 63,168.907 Aug 2026 65,153.1010−$33.44
long7 Aug 2026 65,153.1011 Aug 2026 63,287.104−$30.61
short11 Aug 2026 63,287.1018 Aug 2026 64,821.307−$26.27
long18 Aug 2026 64,821.3015 Sep 2026 75,773.5028$166.79
short15 Sep 2026 75,773.5018 Sep 2026 78,578.303−$39.05
long18 Sep 2026 78,578.308 Oct 2026 82,149.2020$43.40
short8 Oct 2026 82,149.2021 Oct 2026 84,104.5013−$25.83

Similar scripts

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

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 17 msYes 1,000 bars in 37 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/// © TaylorTneh//@version=4strategy("Moving Average Band Taylor V1",shorttitle="MA Band+",overlay=true,default_qty_type=strategy.cash,default_qty_value=1000,initial_capital=1000,currency=currency.USD,commission_value=.1)price = input(close, title="Source")mabtype = input(title="Moving Average Type", defval="RMA", options=["SMA", "EMA", "RMA", "WMA"])malen = input(10, "MA Period : 10")magap = input(0.6, "Band Gap : 0.6", minval = -10, maxval = 10, step = 0.1)mabup = if mabtype == "SMA"    sma(high, malen)else    if mabtype == "EMA"        ema(high, malen)    else        if mabtype == "WMA"            wma(high, malen)        else            if mabtype == "RMA"                rma(high, malen)                    mabdn = if mabtype == "SMA"    sma(low, malen)else    if mabtype == "EMA"        ema(low, malen)    else        if mabtype == "WMA"            wma(low, malen)        else            if mabtype == "RMA"                rma(low, malen)                    upex = mabup * (1 + magap/100)dnex = mabdn * (1 - magap/100)plot(upex, "Upper MA Band", color.orange)plot(dnex, "Lower MA Band", color.orange)//-------------------------------------------- (Strategy)strategy.entry("Long", strategy.long, stop = upex)strategy.entry("Short", strategy.short, stop = dnex)//Long Only//strategy.entry("Long", strategy.long, stop = upex)//Long Only//strategy.exit("Short", stop = dnex)//Short Only//strategy.entry("Short", strategy.short, stop = dnex)//Short Only//strategy.exit("Long", stop = upex)//-------------------------------------------- (Take Profit & Stop Lose)stopPer = input(500.0, title='# Stop Loss %', type=input.float) / 100takePer = input(500.0, title='# Take Profit %', type=input.float) / 100//Determine where you've entered and in what directionlongStop = strategy.position_avg_price * (1 - stopPer)shortStop = strategy.position_avg_price * (1 + stopPer)shortTake = strategy.position_avg_price * (1 - takePer)longTake = strategy.position_avg_price * (1 + takePer)if strategy.position_size > 0     strategy.exit(id="L-TP/SL", stop=longStop, limit=longTake)if strategy.position_size < 0     strategy.exit(id="S-TP/SL", stop=shortStop, limit=shortTake)//-------------------------------------------- (Sample Time Filter Strategy)//fromyear = input(2018, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")//toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")//frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")//tomonth = input(10, defval = 10, minval = 01, maxval = 12, title = "To Month")//fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")//today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")//strategy.entry("Long", strategy.long, stop = upex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))//strategy.entry("Short", strategy.short, stop = dnex, when = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))//--------------------------------------------