Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Astor SMA20-60

A Pine Script v5 strategy built on SMA (close, 10), Crossover or SMA (close, close, 20) and Crossunder or SMA (close, close, 20). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 3 settings; defaults include backtest_year 2018, backtest_month 01 and backtest_day 01.

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 Astor SMA20-60 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 15 of 15 trades.
How did Astor SMA20-60 do on BTCUSDT 1D with default settings?
+0.22%
From 26 Jan 2024 to 21 Oct 2026, over 50 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Astor SMA20-60 run in Pine Script v6?
Yes
Same 50 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. The v6 script can be downloaded below.
Does Astor SMA20-60 use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Astor SMA20-60 run in Zeal Terminal?
Yes
It compiles in 33 ms and runs 1,000 bars in 41 ms, in the browser.

BTCUSDT · 1D · default settings

  • sma(20)
  • sma(60)
  • 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 (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,002,180$2,025,273Equity from $1,000,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
+0.22%
$2,177.44
Buy and hold
+102.5%
same period
Closed trades
50
13 won · 37 lost
Profitable
26.0%
of closed trades
Profit factor
1.26
gross profit ÷ gross loss
Max drawdown
0.30%
−$2,966.03

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

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

  • 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.

Settings

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

SettingDefaultType and rangeFeeds
backtest_year2018intstart_time
backtest_month01int · min 1 · max 12start_time
backtest_day01int · min 1 · max 31start_time

What it calculates

  • SMAclose, 10sma10 · line 10
  • SMAclose, 20sma20 · line 11
  • SMAclose, 60sma60 · line 12
  • Crossover / SMAclose, ta.sma(close, 20)longCondition · line 17
  • Crossunder / SMAclose, ta.sma(close, 20)shortCondition · line 20
  • Crossover / SMAclose, ta.sma(close, 60)longCondition1 · line 24
  • Crossunder / SMAclose, ta.sma(close, 60)shortCondition1 · line 27

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 databacktest_yearbacktest_yearsetting · 2018backtest_monthbacktest_monthsetting · 01backtest_daybacktest_daysetting · 01timetimeprice datasma10SMA→ sma10sma20SMA→ sma20sma60SMA→ sma60longConditionCrossover / SMA→ longConditionshortConditionCrossunder / SMA→ shortConditionlongCondition1Crossover / SMA→ longCondition1shortCondition1Crossunder / SMA→ shortCondition1start_timestart_timevalueentry:open long20Open open long20strategy.entryclose:open long20Close open long20strategy.closeentry:open long60Open open long60strategy.entryclose:open long60Close open long60strategy.closeplot:13sma(20)plotplot:14sma(60)plot

Order rules

OrderFires whenBy defaultLine
Open open long20 long(longCondition) and time >=start_timeOn19
Close open long20(shortCondition) and time >=start_timeOn22
Open open long60 long(longCondition1) and time >=start_timeOn26
Close open long60(shortCondition1) and time >=start_timeOn29

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.

15/15trades 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+0.2%+102.5%5026%1.260.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.0%+5.5%5417%0.920.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%4920%1.060.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.0%+8.4%8111%0.670.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%5428%1.160.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%6617%0.960.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%5237%1.600.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%6327%1.070.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 market1527%−$948.19
Sideways market2227%$1,621.08
Falling market1323%$1,504.56

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

How bad could the drawdown be?

0.5%

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

0%1%
All 50 trades
SideEntryExitBarsP&L
long18 Mar 2024 68,393.5020 Mar 2024 61,937.402−$645.61
long21 Mar 2024 67,840.5022 Mar 2024 65,501.301−$233.92
long26 Mar 2024 69,880.003 Apr 2024 65,464.008−$441.60
long5 Apr 2024 68,487.8013 Apr 2024 67,116.508−$137.13
long15 Apr 2024 65,661.9016 Apr 2024 63,420.001−$224.19
long23 Apr 2024 66,819.3024 Apr 2024 66,414.001−$40.53
long5 May 2024 63,892.007 May 2024 63,165.202−$72.69
long14 May 2024 62,940.1015 May 2024 61,577.501−$136.26
long16 May 2024 66,206.5012 Jun 2024 67,314.2027$110.77
long15 Jul 2024 60,797.901 Aug 2024 64,628.0017$383.01
long22 Aug 2024 61,156.0028 Aug 2024 59,415.006−$174.10
long14 Sep 2024 60,498.002 Oct 2024 60,804.9018$30.69
long12 Oct 2024 62,540.009 Jan 2025 95,060.6089$3,252.06
long15 Jan 2025 96,560.902 Feb 2025 100,636.0018$407.48
long4 Feb 2025 101,329.005 Feb 2025 97,763.101−$356.54
long21 Feb 2025 98,305.0022 Feb 2025 96,182.001−$212.30
long3 Mar 2025 94,270.004 Mar 2025 86,221.201−$804.88
long20 Mar 2025 86,845.9021 Mar 2025 84,223.401−$262.25
long24 Mar 2025 86,082.5030 Mar 2025 82,648.506−$343.40
long2 Apr 2025 85,158.403 Apr 2025 82,516.301−$264.21
long12 Apr 2025 83,423.8030 May 2025 105,590.0048$2,216.59
long10 Jun 2025 110,263.0013 Jun 2025 105,672.003−$459.13
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$224.34
long24 Jun 2025 105,334.0030 Jul 2025 117,951.0036$1,261.68
long8 Aug 2025 117,472.009 Aug 2025 116,675.001−$79.73
long11 Aug 2025 119,294.0019 Aug 2025 116,227.008−$306.72
long23 Aug 2025 116,936.0024 Aug 2025 115,438.001−$149.79
long9 Sep 2025 112,065.0023 Sep 2025 112,651.0014$58.58
long30 Sep 2025 114,312.001 Oct 2025 114,049.001−$26.30
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$582.05
long13 Oct 2025 114,959.0015 Oct 2025 113,028.002−$193.07
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$453.81
long3 Nov 2025 110,541.004 Nov 2025 106,583.001−$395.76
long3 Dec 2025 91,277.906 Dec 2025 89,330.003−$194.78
long8 Dec 2025 90,395.3013 Dec 2025 90,268.405−$12.69
long31 Dec 2025 88,485.501 Jan 2026 87,648.201−$83.73
long2 Jan 2026 88,839.1021 Jan 2026 88,427.7019−$41.14
long3 Mar 2026 68,830.108 Mar 2026 67,262.905−$156.72
long10 Mar 2026 68,432.2020 Mar 2026 69,930.0010$149.78
long21 Mar 2026 70,510.7022 Mar 2026 68,918.101−$159.26
long24 Mar 2026 70,906.4027 Mar 2026 68,820.303−$208.61
long6 Apr 2026 69,034.2016 May 2026 79,113.2040$1,007.90
long21 Jun 2026 64,298.0022 Jun 2026 63,312.001−$98.60
long23 Jun 2026 64,020.0024 Jun 2026 62,734.601−$128.54
long4 Jul 2026 62,583.3025 Jul 2026 64,140.0021$155.67
long26 Jul 2026 64,375.0028 Jul 2026 63,755.902−$61.91
long29 Jul 2026 63,915.001 Aug 2026 62,887.903−$102.71
long3 Aug 2026 63,570.0013 Aug 2026 63,480.0010−$9.00
long18 Aug 2026 64,532.1010 Sep 2026 78,306.4023$1,377.43
long19 Sep 2026 80,883.908 Oct 2026 83,321.8019$243.79

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
Astor SMA20-60 this page—v5 strategy+0.2%500.3%
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%

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.

  • 1 setting uses the untyped input() (line 5). 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 50 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 5: input() → input.int()
⋯strategy("Astor SMA20/60", overlay=true, margin_long=100, margin_short=100)-backtest_year = input(2018, title='backtest_year') //回測開始年分+backtest_year = input.int(2018, title='backtest_year') //回測開始年分backtest_month = input.int(01, title='backtest_month', minval=1, maxval=12) //回測開始月份⋯

Does it run in Pine Script v6?

Yes

Same 50 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

⋯// © Astorhsu-//@version=5+//@version=6strategy("Astor SMA20/60", overlay=true, margin_long=100, margin_short=100)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 33 msYes 1,000 bars in 41 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/// © Astorhsu//@version=5strategy("Astor SMA20/60", overlay=true, margin_long=100, margin_short=100)backtest_year = input(2018, title='backtest_year') //回測開始年分backtest_month = input.int(01, title='backtest_month', minval=1, maxval=12) //回測開始月份backtest_day = input.int(01, title='backtest_day', minval=1, maxval=31)  //回測開始日期start_time = timestamp(backtest_year, backtest_month, backtest_day, 00, 00)  //回測開始的時間函數//Indicatorssma10 = ta.sma(close,10)sma20 = ta.sma(close,20)sma60 = ta.sma(close,60)plot(sma20, color=color.green, title="sma(20)")plot(sma60, color=color.red, title="sma(60)")//進場條件// trend1 = sma60 > sma20 //假設目前趨勢為60>20longCondition = ta.crossover(close, ta.sma(close, 20))if (longCondition) and time >=start_time    strategy.entry("open long20", strategy.long, qty=0.1, comment="站上m20做多")shortCondition = ta.crossunder(close, ta.sma(close, 20))if (shortCondition) and time >=start_time    strategy.close("open long20",comment="跌破m20平倉", qty=0.1)         longCondition1 = ta.crossover(close, ta.sma(close, 60))if (longCondition1) and time >=start_time    strategy.entry("open long60", strategy.long, qty=0.1, comment="站上m60做多")shortCondition1 = ta.crossunder(close, ta.sma(close, 60))if (shortCondition1) and time >=start_time    strategy.close("open long60",comment="跌破m60平倉", qty=0.1)         // longCondition2 = ta.crossover(close, ta.sma(close, 10))// if (longCondition2) //     strategy.entry("open long10", strategy.long, qty=0.1, comment="站上m10做多")// shortCondition2 = ta.crossunder(close, ta.sma(close, 10))// if (shortCondition2)//     strategy.close("open long10",comment="跌破m10平倉", qty=0.1)