Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

WEEKLY BTC TRADING SCRYPT

A Pine Script v4 strategy built on SMA (btc, 8), Crossover (btc, ma) and Crossunder (btc, ma). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 8 settings; defaults include source close, COLOR #FF3232 and LINE WIDTH 2.

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 WEEKLY BTC TRADING SCRYPT repaint?
Yes
In a live replay, it did not match history on 11 of 11 trades, and it produced 11 trades that history does not have.
How did WEEKLY BTC TRADING SCRYPT do on BTCUSDT 1D with default settings?
+17.11%
From 26 Jan 2024 to 21 Oct 2026, over 37 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can WEEKLY BTC TRADING SCRYPT 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.
What alerts does WEEKLY BTC TRADING SCRYPT have?
2
BTC buy order trigerred!; BTC sell order trigerred!.
Does WEEKLY BTC TRADING SCRYPT use a stop loss?
Yes
strategy.exit sets a stop on line 23.

BTCUSDT · 1D · default settings

  • WEEKLY CLOSE
  • SMA8 WEEKLY
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctWEEKLY CLOSE$117,112$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. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 20) 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. The live re-run is not offered here: the script requests BTCUSDT 1W, which this page cannot load in your browser.
Net profit
+17.11%
$17,107.20
Buy and hold
+102.5%
same period
Closed trades
37
11 won · 26 lost
Profitable
29.7%
of closed trades
Profit factor
1.23
gross profit ÷ gross loss
Max drawdown
24.75%
−$31,372.30

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 20, 23. The upgraded version below moves each call inside an if block.

  • Note

    Uses long =, which v5 renamed line 20

    long = on line 20. v5 writes it as direction = strategy.long or strategy.short.

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 security → request.security, sma → ta.sma, crossover → ta.crossover, crossunder → ta.crossunder.
  • 2 strategy calls use the when = argument (line 20, 23). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 5: //@version=4 → //@version=5
  • Line 8: security → request.security
  • Line 9: sma → ta.sma
  • Line 10: crossover → ta.crossover
  • Line 11: crossunder → ta.crossunder
  • Line 20: long = true → direction = strategy.long
⋯//author: taberandwords-//@version=4+//@version=5strategy("WEEKLY BTC TRADING SCRYPT","WBTS",overlay=false,default_qty_type=strategy.fixed)source=input(defval=close,title="source",group="STRATEGY")-btc=security('BTCUSDT','1W', source)+btc=request.security('BTCUSDT','1W', source)-ma=sma(btc,8)+ma=ta.sma(btc,8)-buy_condition= crossover(btc,ma) +buy_condition= ta.crossover(btc,ma) -sell_condition= crossunder(btc,ma)+sell_condition= ta.crossunder(btc,ma)ma_color=input(defval=#FF3232,title="COLOR",group="MA")⋯if(year>=start_date)-    strategy.entry('BUY',long=true,when=buy_condition,alert_message='Price came to buying value!')+    strategy.entry('BUY',direction = strategy.long,when=buy_condition,alert_message='Price came to buying value!')    if(strategy.long)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 7: input() → input.source()
  • Line 12: input() → input.color()
  • Line 13: input() → input.int()
  • Line 14: input() → input.color()
  • Line 15: input() → input.int()
  • Line 16: input() → input.int()
4 more edits
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 20: when = buy_condition → if block
  • Line 23: when = sell_condition → if block
⋯strategy("WEEKLY BTC TRADING SCRYPT","WBTS",overlay=false,default_qty_type=strategy.fixed)-source=input(defval=close,title="source",group="STRATEGY")+source=input.source(defval=close,title="source",group="STRATEGY")btc=request.security('BTCUSDT','1W', source)⋯sell_condition= ta.crossunder(btc,ma)-ma_color=input(defval=#FF3232,title="COLOR",group="MA")+ma_color=input.color(defval=#FF3232,title="COLOR",group="MA")-ma_linewidth=input(defval=2,title="LINE WIDTH",group="MA")+ma_linewidth=input.int(defval=2,title="LINE WIDTH",group="MA")-graphic_color=input(defval=#6666FF,title="COLOR",group="GRAPHIC")+graphic_color=input.color(defval=#6666FF,title="COLOR",group="GRAPHIC")-graphic_linewidth=input(defval=2,title="LINE WIDTH",group="GRAPHIC")+graphic_linewidth=input.int(defval=2,title="LINE WIDTH",group="GRAPHIC")-start_date=input(defval=2020,title="YEAR",group="STRATEGY EXECUTION YEAR")+start_date=input.int(defval=2020,title="YEAR",group="STRATEGY EXECUTION YEAR")-loss_ratio=input(defval=1,title="LOSS RATIO", group="STRATEGY")+loss_ratio=input.int(defval=1,title="LOSS RATIO", group="STRATEGY")-reward_ratio=input(defval=3,title="REWARD RATIO", group="STRATEGY")+reward_ratio=input.int(defval=3,title="REWARD RATIO", group="STRATEGY")if(year>=start_date)-    strategy.entry('BUY',direction = strategy.long,when=buy_condition,alert_message='Price came to buying value!')+    if buy_condition+        strategy.entry('BUY',direction = strategy.long,alert_message='Price came to buying value!')    if(strategy.long)        alert('BTC buy order trigerred!',alert.freq_once_per_bar)-    strategy.exit(id="SELL",loss=loss_ratio,profit=reward_ratio,when=sell_condition,alert_message='Price came to position closing value!')+    if sell_condition+        strategy.exit(id="SELL",loss=loss_ratio,profit=reward_ratio,alert_message='Price came to position closing value!')    if(sell_condition)⋯

Does it run in Pine Script v6?

Yes

Same 37 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯//author: taberandwords-//@version=5+//@version=6strategy("WEEKLY BTC TRADING SCRYPT","WBTS",overlay=false,default_qty_type=strategy.fixed)⋯

Settings

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

SettingDefaultType and rangeFeeds
STRATEGY
sourceclosesourcebtc WEEKLY CLOSE
LOSS RATIO1intexit SELL
REWARD RATIO3intexit SELL
MA
COLOR#FF3232valueSMA8 WEEKLY
LINE WIDTH2intSMA8 WEEKLY
GRAPHIC
COLOR#6666FFvalueWEEKLY CLOSE
LINE WIDTH2intWEEKLY CLOSE
STRATEGY EXECUTION YEAR
YEAR2020intentry BUY exit SELL line 19

What it calculates

  • SMA (sma, ta.sma in v5)btc, 8ma · line 9
  • Crossover (crossover, ta.crossover in v5)btc, mabuy_condition · line 10
  • Crossunder (crossunder, ta.crossunder in v5)btc, masell_condition · line 11

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 datamaSMA→ mabuy_conditionCrossover→ buy_conditionsell_conditionCrossunder→ sell_conditionbtcbtcvalueentry:BUYOpen BUYstrategy.entryexit:SELLexit SELLstrategy.exitalert:22alertalertalert:25alertalertplot:26WEEKLY CLOSEplotplot:27SMA8 WEEKLYplotplot:28plotplot

Order rules

OrderFires whenBy defaultLine
Open BUY longbuy_conditionOn20
Exit SELL stop and limitsell_conditionOn23

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
(no title)alertBTC buy order trigerred!22
(no title)alertBTC sell order trigerred!25

Does it repaint?

Yes

The live replay did not match history.

0/11trades 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 data1 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 1D+17.1%+102.5%3730%1.2324.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−10.2%+5.5%714%0.2013.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.2%+9.8%3741%1.052.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.4%+8.4%714%0.210.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%3746%0.940.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%743%0.270.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.2%+148.3%3749%1.240.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%714%0.010.2%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): BTCUSDT 1W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1436%$15,264.20
Sideways market1625%−$3,982.94
Falling market729%$5,826.00

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

How bad could the drawdown be?

33.4%

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

0%38%
All 37 trades
SideEntryExitBarsP&L
long4 Mar 2024 63,114.0018 Mar 2024 68,393.5014$5,279.50
long1 Apr 2024 71,280.008 Apr 2024 69,360.407−$1,919.62
long6 May 2024 64,012.0013 May 2024 61,484.007−$2,528.00
long20 May 2024 66,274.003 Jun 2024 67,765.6014$1,491.62
long10 Jun 2024 69,648.1017 Jun 2024 66,676.907−$2,971.29
long15 Jul 2024 60,797.905 Aug 2024 58,161.0021−$2,636.91
long12 Aug 2024 58,712.6019 Aug 2024 58,427.307−$285.24
long26 Aug 2024 64,220.002 Sep 2024 57,301.807−$6,918.22
long16 Sep 2024 59,132.007 Oct 2024 62,819.9021$3,687.91
long14 Oct 2024 62,870.0028 Oct 2024 68,021.7014$5,151.67
long4 Nov 2024 68,776.002 Dec 2024 97,185.2028$28,409.20
long9 Dec 2024 101,110.0023 Dec 2024 95,186.3014−$5,923.32
long6 Jan 2025 98,363.6013 Jan 2025 94,545.107−$3,818.54
long20 Jan 2025 101,332.003 Feb 2025 97,700.6014−$3,630.98
long24 Feb 2025 96,258.003 Mar 2025 94,270.007−$1,988.01
long17 Mar 2025 82,574.5031 Mar 2025 82,390.0014−$184.52
long14 Apr 2025 83,760.002 Jun 2025 105,643.0049$21,882.90
long9 Jun 2025 105,734.0016 Jun 2025 105,594.007−$139.99
long30 Jun 2025 108,357.0021 Jul 2025 117,265.0021$8,908.18
long28 Jul 2025 119,416.004 Aug 2025 114,209.007−$5,206.75
long11 Aug 2025 119,294.0018 Aug 2025 117,405.007−$1,889.26
long8 Sep 2025 111,137.0022 Sep 2025 115,232.0014$4,094.94
long6 Oct 2025 123,482.0013 Oct 2025 114,959.007−$8,523.51
long27 Oct 2025 114,559.003 Nov 2025 110,541.007−$4,018.72
long1 Dec 2025 90,360.0015 Dec 2025 88,172.2014−$2,187.85
long22 Dec 2025 88,658.9029 Dec 2025 87,952.707−$706.16
long5 Jan 2026 91,529.7012 Jan 2026 91,013.707−$516.08
long19 Jan 2026 93,673.1026 Jan 2026 86,670.407−$7,002.78
long9 Mar 2026 65,971.2023 Mar 2026 67,859.0014$1,887.80
long6 Apr 2026 69,034.204 May 2026 78,568.6028$9,534.40
long11 May 2026 82,210.1018 May 2026 77,457.707−$4,752.40
long15 Jun 2026 65,746.4022 Jun 2026 63,312.007−$2,434.45
long6 Jul 2026 63,650.003 Aug 2026 63,570.0028−$80.00
long10 Aug 2026 64,901.6017 Aug 2026 62,900.007−$2,001.59
long24 Aug 2026 77,734.0031 Aug 2026 77,682.007−$52.00
long7 Sep 2026 80,341.8014 Sep 2026 76,842.007−$3,499.82
long21 Sep 2026 81,178.0012 Oct 2026 83,773.1021$2,595.11

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
WEEKLY BTC TRADING SCRYPT this page—v4 strategy+17.1%3724.7%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msWith a workaround 1,000 bars in 33 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 20) 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. 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/// © taberandwords//developer: taberandwords//author: taberandwords//@version=4strategy("WEEKLY BTC TRADING SCRYPT","WBTS",overlay=false,default_qty_type=strategy.fixed)source=input(defval=close,title="source",group="STRATEGY")btc=security('BTCUSDT','1W', source)ma=sma(btc,8)buy_condition= crossover(btc,ma) sell_condition= crossunder(btc,ma)ma_color=input(defval=#FF3232,title="COLOR",group="MA")ma_linewidth=input(defval=2,title="LINE WIDTH",group="MA")graphic_color=input(defval=#6666FF,title="COLOR",group="GRAPHIC")graphic_linewidth=input(defval=2,title="LINE WIDTH",group="GRAPHIC")start_date=input(defval=2020,title="YEAR",group="STRATEGY EXECUTION YEAR")loss_ratio=input(defval=1,title="LOSS RATIO", group="STRATEGY")reward_ratio=input(defval=3,title="REWARD RATIO", group="STRATEGY")if(year>=start_date)    strategy.entry('BUY',long=true,when=buy_condition,alert_message='Price came to buying value!')    if(strategy.long)        alert('BTC buy order trigerred!',alert.freq_once_per_bar)    strategy.exit(id="SELL",loss=loss_ratio,profit=reward_ratio,when=sell_condition,alert_message='Price came to position closing value!')    if(sell_condition)        alert('BTC sell order trigerred!',alert.freq_once_per_bar)plot(series=source,title="WEEKLY CLOSE",color=graphic_color,linewidth=graphic_linewidth)plot(ma,title="SMA8 WEEKLY",color=ma_color,linewidth=ma_linewidth)plot(strategy.equity,display=0)