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
- 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
VerifiedSame 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⋯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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Source | close | source | unused |
| Moving Average Type | RMA | string · options ["SMA", "EMA", "RMA", "WMA"] | mabup mabdn |
| MA Period : 10 | 10 | int | mabup mabdn |
| Band Gap : 0.6 | 0.6 | float · min -10 · max 10 · step 0.1 | upex dnex |
| # Stop Loss % | 500.0 | float | longStop shortStop |
| # Take Profit % | 500.0 | float | shortTake 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | every bar | On | 38 |
| Open Short short | every bar | On | 39 |
| Exit L-TP/SL stop and limit | strategy.position_size > 0 | On | 53 |
| Exit S-TP/SL stop and limit | strategy.position_size < 0 | On | 55 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +57.3% | +102.5% | 88 | 33% | 1.30 | 32.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −20.5% | +5.5% | 76 | 14% | 0.75 | 29.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +160.5% | +9.8% | 89 | 30% | 1.68 | 23.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −27.6% | +8.4% | 84 | 15% | 0.76 | 33.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +53.0% | +16.7% | 101 | 35% | 1.16 | 45.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +15.6% | +21.5% | 76 | 26% | 1.16 | 21.8% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −33.6% | +148.3% | 99 | 25% | 0.87 | 78.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −9.2% | +17.1% | 70 | 26% | 0.86 | 20.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 28 | 25% | −$724.56 |
| Sideways market | 46 | 39% | $1,136.89 |
| Falling market | 14 | 29% | $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.
All 88 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 41,823.50 | 27 Jan 2024 41,823.50 | 0 | −$2.00 |
| short | 27 Jan 2024 41,823.50 | 28 Jan 2024 42,120.60 | 1 | −$9.11 |
| long | 28 Jan 2024 42,120.60 | 28 Jan 2024 42,120.60 | 0 | −$2.00 |
| short | 28 Jan 2024 42,120.60 | 29 Jan 2024 42,031.10 | 1 | $0.13 |
| long | 29 Jan 2024 42,031.10 | 29 Jan 2024 42,031.10 | 0 | −$2.00 |
| short | 29 Jan 2024 42,031.10 | 30 Jan 2024 43,302.70 | 1 | −$32.29 |
| long | 30 Jan 2024 43,302.70 | 30 Jan 2024 43,302.70 | 0 | −$2.00 |
| short | 30 Jan 2024 43,302.70 | 31 Jan 2024 42,941.10 | 1 | $6.36 |
| long | 31 Jan 2024 42,941.10 | 31 Jan 2024 42,941.10 | 0 | −$2.00 |
| short | 31 Jan 2024 42,941.10 | 1 Feb 2024 42,580.00 | 1 | $6.42 |
| long | 1 Feb 2024 42,580.00 | 1 Feb 2024 42,580.00 | 0 | −$2.00 |
| short | 1 Feb 2024 42,580.00 | 2 Feb 2024 43,082.90 | 1 | −$13.82 |
| long | 2 Feb 2024 43,082.90 | 2 Feb 2024 43,082.90 | 0 | −$2.00 |
| short | 2 Feb 2024 43,082.90 | 3 Feb 2024 43,200.00 | 1 | −$4.72 |
| long | 3 Feb 2024 43,200.00 | 3 Feb 2024 43,200.00 | 0 | −$2.00 |
| short | 3 Feb 2024 43,200.00 | 4 Feb 2024 43,011.10 | 1 | $2.38 |
| long | 4 Feb 2024 43,011.10 | 4 Feb 2024 43,011.10 | 0 | −$2.00 |
| short | 4 Feb 2024 43,011.10 | 5 Feb 2024 43,411.10 | 1 | −$11.31 |
| long | 5 Feb 2024 43,411.10 | 19 Mar 2024 63,429.60 | 43 | $458.68 |
| short | 19 Mar 2024 63,429.60 | 21 Mar 2024 68,156.70 | 2 | −$76.60 |
| long | 21 Mar 2024 68,156.70 | 22 Mar 2024 63,047.30 | 1 | −$76.89 |
| short | 22 Mar 2024 63,047.30 | 25 Mar 2024 67,932.20 | 3 | −$79.56 |
| long | 25 Mar 2024 67,932.20 | 2 Apr 2024 66,007.50 | 8 | −$30.30 |
| short | 2 Apr 2024 66,007.50 | 7 Apr 2024 69,748.50 | 5 | −$58.73 |
| long | 7 Apr 2024 69,748.50 | 12 Apr 2024 66,735.40 | 5 | −$45.16 |
| short | 12 Apr 2024 66,735.40 | 6 May 2024 65,098.90 | 24 | $22.55 |
| long | 6 May 2024 65,098.90 | 8 May 2024 61,488.10 | 2 | −$57.41 |
| short | 8 May 2024 61,488.10 | 15 May 2024 64,132.10 | 7 | −$45.04 |
| long | 15 May 2024 64,132.10 | 11 Jun 2024 67,513.80 | 27 | $50.68 |
| short | 11 Jun 2024 67,513.80 | 14 Jul 2024 61,172.90 | 33 | $92.01 |
| long | 14 Jul 2024 61,172.90 | 1 Aug 2024 63,741.80 | 18 | $39.95 |
| short | 1 Aug 2024 63,741.80 | 21 Aug 2024 61,762.60 | 20 | $29.08 |
| long | 21 Aug 2024 61,762.60 | 27 Aug 2024 59,696.70 | 6 | −$35.41 |
| short | 27 Aug 2024 59,696.70 | 13 Sep 2024 59,264.40 | 17 | $5.25 |
| long | 13 Sep 2024 59,264.40 | 1 Oct 2024 61,415.50 | 18 | $34.26 |
| short | 1 Oct 2024 61,415.50 | 7 Oct 2024 63,587.70 | 6 | −$37.40 |
| long | 7 Oct 2024 63,587.70 | 9 Oct 2024 61,074.50 | 2 | −$41.48 |
| short | 9 Oct 2024 61,074.50 | 12 Oct 2024 63,466.90 | 3 | −$41.21 |
| long | 12 Oct 2024 63,466.90 | 5 Dec 2024 91,089.10 | 54 | $432.79 |
| short | 5 Dec 2024 91,089.10 | 6 Dec 2024 96,945.60 | 1 | −$66.36 |
| long | 6 Dec 2024 96,945.60 | 19 Dec 2024 97,176.60 | 13 | $0.38 |
| short | 19 Dec 2024 97,176.60 | 3 Jan 2025 98,755.70 | 15 | −$18.27 |
| long | 3 Jan 2025 98,755.70 | 8 Jan 2025 94,956.10 | 5 | −$40.44 |
| short | 8 Jan 2025 94,956.10 | 15 Jan 2025 98,136.20 | 7 | −$35.52 |
| long | 15 Jan 2025 98,136.20 | 27 Jan 2025 98,708.20 | 12 | $3.82 |
| short | 27 Jan 2025 98,708.20 | 29 Jan 2025 104,185.00 | 2 | −$57.54 |
| long | 29 Jan 2025 104,185.00 | 2 Feb 2025 99,447.20 | 4 | −$47.42 |
| short | 2 Feb 2025 99,447.20 | 2 Mar 2025 94,605.10 | 28 | $46.74 |
| long | 2 Mar 2025 94,605.10 | 3 Mar 2025 89,037.20 | 1 | −$60.79 |
| short | 3 Mar 2025 89,037.20 | 24 Mar 2025 87,302.10 | 21 | $17.51 |
| long | 24 Mar 2025 87,302.10 | 28 Mar 2025 83,670.50 | 4 | −$43.56 |
| short | 28 Mar 2025 83,670.50 | 2 Apr 2025 86,858.20 | 5 | −$40.14 |
| long | 2 Apr 2025 86,858.20 | 3 Apr 2025 82,516.30 | 1 | −$51.94 |
| short | 3 Apr 2025 82,516.30 | 12 Apr 2025 85,010.30 | 9 | −$32.25 |
| long | 12 Apr 2025 85,010.30 | 31 May 2025 103,488.00 | 49 | $215.15 |
| short | 31 May 2025 103,488.00 | 9 Jun 2025 107,038.00 | 9 | −$36.34 |
| long | 9 Jun 2025 107,038.00 | 13 Jun 2025 104,104.00 | 4 | −$29.39 |
| short | 13 Jun 2025 104,104.00 | 16 Jun 2025 107,879.00 | 3 | −$38.30 |
| long | 16 Jun 2025 107,879.00 | 17 Jun 2025 103,922.00 | 1 | −$38.64 |
| short | 17 Jun 2025 103,922.00 | 25 Jun 2025 106,971.00 | 8 | −$31.37 |
| long | 25 Jun 2025 106,971.00 | 1 Aug 2025 114,852.00 | 37 | $71.60 |
| short | 1 Aug 2025 114,852.00 | 7 Aug 2025 117,595.00 | 6 | −$25.91 |
| long | 7 Aug 2025 117,595.00 | 18 Aug 2025 115,536.00 | 11 | −$19.49 |
| short | 18 Aug 2025 115,536.00 | 10 Sep 2025 113,789.00 | 23 | $13.14 |
| long | 10 Sep 2025 113,789.00 | 22 Sep 2025 112,941.00 | 12 | −$9.45 |
| short | 22 Sep 2025 112,941.00 | 30 Sep 2025 114,638.00 | 8 | −$17.04 |
| long | 30 Sep 2025 114,638.00 | 10 Oct 2025 116,265.00 | 10 | $12.18 |
| short | 10 Oct 2025 116,265.00 | 26 Oct 2025 114,174.00 | 16 | $16.00 |
| long | 26 Oct 2025 114,174.00 | 29 Oct 2025 109,803.00 | 3 | −$40.24 |
| short | 29 Oct 2025 109,803.00 | 9 Dec 2025 93,614.50 | 41 | $145.58 |
| long | 9 Dec 2025 93,614.50 | 14 Dec 2025 89,110.30 | 5 | −$50.07 |
| short | 14 Dec 2025 89,110.30 | 29 Dec 2025 90,318.70 | 15 | −$15.57 |
| long | 29 Dec 2025 90,318.70 | 20 Jan 2026 90,997.00 | 22 | $5.50 |
| short | 20 Jan 2026 90,997.00 | 4 Mar 2026 70,241.10 | 43 | $226.32 |
| long | 4 Mar 2026 70,241.10 | 8 Mar 2026 66,587.30 | 4 | −$53.97 |
| short | 8 Mar 2026 66,587.30 | 10 Mar 2026 70,574.80 | 2 | −$61.94 |
| long | 10 Mar 2026 70,574.80 | 19 Mar 2026 68,810.90 | 9 | −$26.97 |
| short | 19 Mar 2026 68,810.90 | 6 Apr 2026 69,883.00 | 18 | −$17.60 |
| long | 6 Apr 2026 69,883.00 | 16 May 2026 77,836.40 | 40 | $111.70 |
| short | 16 May 2026 77,836.40 | 5 Jul 2026 63,547.80 | 50 | $181.76 |
| long | 5 Jul 2026 63,547.80 | 28 Jul 2026 63,168.90 | 23 | −$7.96 |
| short | 28 Jul 2026 63,168.90 | 7 Aug 2026 65,153.10 | 10 | −$33.44 |
| long | 7 Aug 2026 65,153.10 | 11 Aug 2026 63,287.10 | 4 | −$30.61 |
| short | 11 Aug 2026 63,287.10 | 18 Aug 2026 64,821.30 | 7 | −$26.27 |
| long | 18 Aug 2026 64,821.30 | 15 Sep 2026 75,773.50 | 28 | $166.79 |
| short | 15 Sep 2026 75,773.50 | 18 Sep 2026 78,578.30 | 3 | −$39.05 |
| long | 18 Sep 2026 78,578.30 | 8 Oct 2026 82,149.20 | 20 | $43.40 |
| short | 8 Oct 2026 82,149.20 | 21 Oct 2026 84,104.50 | 13 | −$25.83 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | Yes 1,000 bars in 37 ms | Not measured |
| PineTS | No 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)))//--------------------------------------------