Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Accumulation Stage Identifier and Strategy around for Trading

A Pine Script v5 strategy built on SMA (close, 200), CUM or Change and MACD (ta.pvt, 12). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 4 settings; defaults include Lookback 21, Offset 0 and Entry Line 21.

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 Accumulation Stage Identifier and Strategy around for Trading repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did Accumulation Stage Identifier and Strategy around for Trading do on BTCUSDT 1D with default settings?
−0.02%
From 26 Jan 2024 to 21 Oct 2026, over 16 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Accumulation Stage Identifier and Strategy around for Trading 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: 16 before, 41 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 Accumulation Stage Identifier and Strategy around for Trading use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Accumulation Stage Identifier and Strategy around for Trading run in Zeal Terminal?
Yes
It compiles in 23 ms and runs 1,000 bars in 79 ms, in the browser.

BTCUSDT · 1D · default settings

  • MA200
  • MA50
  • MA90
  • MA21
  • Buy Signal
  • Sell Signal
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$994,164$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.02%
−$246.24
Buy and hold
+102.5%
same period
Closed trades
16
5 won · 11 lost
Profitable
31.3%
of closed trades
Profit factor
1.00
gross profit ÷ gross loss
Max drawdown
4.07%
−$41,145.90

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A short 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

    2 settings do nothing

    “Entry Line”, “Exit Line” are declared but never read.

  • 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
Lookback21intfourlow fourhig
Offset0int · min -500 · max 500MA200 MA50 MA90 MA21
Entry Line21intunused
Exit Line21intunused

What it calculates

  • SMAclose, 200out · line 8
  • SMAclose, 50outf · line 9
  • SMAclose, 90outn · line 10
  • SMAclose, 21outt · line 11
  • CUM / Changemath.sign(ta.change(close)) * volumeobv · line 35
  • SMAobv, 5smoothingLine · line 37
  • MACDta.pvt, 12, 26, 9macdLine · line 38
  • MACDta.pvt, 12, 26, 9signalLine · line 38
  • MACDta.pvt, 12, 26, 9histLine · line 38
  • Risinghigh, 2higheshigh · line 45
  • Risinglow, 2higheslow · line 46
  • Risingout, 2twohunraise · line 47
  • Risingvolume, 2highvol · line 49
  • Lowestclose, Lookback (21)fourlow · line 50
  • Highestclose, Lookback (21)fourhig · line 51
  • Fallinghigh, 3lowesthigh · line 68
  • Fallinglow, 2lowestlow · line 69
  • Fallingout, 3twohunfall · line 70
  • Fallingoutt, 2twentyfall · line 71
  • Crossover / SMAvolume, ta.sma(volume, 5)highvole · line 72
  • ATR14atr · line 77
  • Crossover / SMAta.sma(close, 14), ta.sma(close, 28)longCondition · line 91
  • Crossunder / SMAta.sma(close, 14), ta.sma(close, 28)shortCondition · line 94

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 datavolumevolumeprice datahighhighprice datalowlowprice datalookbackLookbacksetting · 21high · low · closehigh · low · closeprice dataopenopenprice dataoutSMA→ outoutfSMA→ outfoutnSMA→ outnouttSMA→ outtobvCUM / Change→ obvsmoothingLineSMA→ smoothingLinemacdLineMACD→ macdLinesignalLineMACD→ signalLinehistLineMACD→ histLinehigheshighRising→ higheshighhigheslowRising→ higheslowtwohunraiseRising→ twohunraisehighvolRising→ highvolfourlowLowest→ fourlowfourhigHighest→ fourhiglowesthighFalling→ lowesthighlowestlowFalling→ lowestlowtwohunfallFalling→ twohunfalltwentyfallFalling→ twentyfallhighvoleCrossover / SMA→ highvoleatrATR→ atrlongConditionCrossover / SMA→ longConditionshortConditionCrossunder / SMA→ shortConditionatrlenatrlenvaluesellvolhigh, buyvolhighsellvolhigh · buyvolhigh2 conditionsmafentry, matwohun, mafexit, matexit, matwohundmafentry · matwohun +35 conditionschangechangeconditiongreen, redgreen · red2 conditionschangedchangedconditionatrsmaatrsmaconditionentry:My Long Entry IdOpen My Long Entry Idstrategy.entryentry:My Short Entry IdOpen My Short Entry Idstrategy.entryplot:13MA200plotplot:14MA50plotplot:15MA90plotplot:16MA21plotplotshape:59Buy Signalplotshapeplotshape:90Sell Signalplotshape

Order rules

OrderFires whenBy defaultLine
Open My Long Entry Id long(allup)On93
Open My Short Entry Id short(alldwn)On96

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.

1/1trades 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.0%+102.5%1631%1.004.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−1.5%+5.5%2433%0.643.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.2%+9.8%1429%0.470.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%2236%1.460.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%1839%0.960.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%1817%0.540.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%2232%0.920.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%1833%1.190.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 market922%−$13,315.30
Sideways market743%$13,069.00
Falling market0—$0.00

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

How bad could the drawdown be?

4.9%

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

0%6%
All 16 trades
SideEntryExitBarsP&L
short16 Mar 2024 69,499.807 Nov 2024 75,572.00236−$6,072.15
long7 Nov 2024 75,572.0026 Nov 2024 93,010.0019$17,438.00
short26 Nov 2024 93,010.007 Jan 2025 102,236.0042−$9,225.59
long7 Jan 2025 102,236.009 Jan 2025 95,060.602−$7,174.99
short9 Jan 2025 95,060.6016 Jan 2025 100,497.007−$5,436.74
long16 Jan 2025 100,497.003 Feb 2025 97,700.6018−$2,796.76
short3 Feb 2025 97,700.6026 Jun 2025 107,341.00143−$9,640.00
long26 Jun 2025 107,341.0026 Jul 2025 117,614.0030$10,273.70
short26 Jul 2025 117,614.0015 Aug 2025 118,295.0020−$680.78
long15 Aug 2025 118,295.0016 Aug 2025 117,342.001−$953.05
short16 Aug 2025 117,342.009 Sep 2025 112,065.0024$5,276.81
long9 Sep 2025 112,065.0024 Sep 2025 111,999.0015−$66.43
short24 Sep 2025 111,999.0028 Oct 2025 114,108.0034−$2,108.85
long28 Oct 2025 114,108.005 Nov 2025 101,497.008−$12,610.40
short5 Nov 2025 101,497.0026 Aug 2026 78,539.10294$22,958.10
long26 Aug 2026 78,539.108 Sep 2026 79,112.0013$572.87

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
Accumulation Stage Identifier and Strategy around for Trading this page—v5 strategy−0.0%164.1%
ICHIMOKU Crypto Swing Strategy by exlux99highest lowest sma rising fallingv4 strategydoes not run in Zeal Terminal
Altered OBV On MACD by stocktechbotsma cum macd rising fallingv5 strategy+0.1%474.4%
Linear On MACD by stocktechbotcum sma macd rising fallingv5 strategy+1.5%165.6%
DC Breakout Strategy - This is simplicity at its finest. by Robrecht99sma highest lowest atrv5 strategy+10.8%578.3%
Linear Cross Trading Strategy by stocktechbotsma macd rising fallingv5 strategy+9.7%142.7%

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.

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

  • Line 5: input() → input.int()
  • Line 55: input() → input.int()
  • Line 67: input() → input.int()
⋯strategy("Accumulate", overlay = true)-lookback = input(defval = 21, title = 'Lookback')+lookback = input.int(defval = 21, title = 'Lookback')offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯allup = false-lineabove = ta.cross(close, ta.sma(close, input(defval = 21, title = 'Entry Line')))+lineabove = ta.cross(close, ta.sma(close, input.int(defval = 21, title = 'Entry Line')))if matwohun and mafentry and higheshigh and twohunraise and buyvolhigh⋯matwohund = close < ta.sma(close, 200)-linebreak = ta.sma(close, input(defval = 21, title = 'Exit Line')) > close+linebreak = ta.sma(close, input.int(defval = 21, title = 'Exit Line')) > closelowesthigh = ta.falling(high, 3)⋯

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

⋯// © stocktechbot-//@version=5+//@version=6strategy("Accumulate", overlay = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 23 msYes 1,000 bars in 79 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/// © stocktechbot//@version=5strategy("Accumulate", overlay = true)lookback = input(defval = 21, title = 'Lookback')offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)//SMA Tredlineout = ta.sma(close, 200)outf = ta.sma(close, 50)outn = ta.sma(close, 90)outt = ta.sma(close, 21)//sma plotplot(out, color=color.blue, title="MA200", offset=offset)plot(outf, color=color.maroon, title="MA50", offset=offset)plot(outn, color=color.orange, title="MA90", offset=offset)plot(outt, color=color.olive, title="MA21", offset=offset)//MarketCap Calculation//MarketCap = 0.0//TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ", ignore_invalid_symbol = true)//if str.tostring(TSO) != 'na'//    if ta.barssince(TSO != TSO[1] and TSO > TSO[1])==0//        MarketCap := TSO * close//       //    if barstate.islast and MarketCap == 0//        runtime.error("No MarketCap is provided by the data vendor.")//    //momlen = 100//msrc = MarketCap//mom = msrc - msrc[momlen]//plotmom = if (mom > mom[1])//    true//else//   false//OBV with sma on macdobv = ta.cum(math.sign(ta.change(close)) * volume)smoothingLength = 5smoothingLine = ta.sma(obv,5)[macdLine, signalLine, histLine] = ta.macd(ta.pvt, 12, 26, 9)sellvolhigh = macdLine < signalLinebuyvolhigh = macdLine > signalLine//Buy Signalmafentry =ta.sma(close, 50) > ta.sma(close, 90)//matentry = ta.sma(close, 21) > ta.sma(close, 50)matwohun = close > ta.sma(close, 200)higheshigh = ta.rising(high, 2)higheslow = ta.rising(low, 2 )twohunraise = ta.rising(out, 2)//highvol =  ta.crossover(volume, ta.sma(volume, lookback))highvol = ta.rising(volume,2)fourlow = ta.lowest(close, lookback)fourhig = ta.highest(close, lookback)change =  (((fourhig - fourlow) / fourlow) * 100) <= 30green = close > openallup = falselineabove = ta.cross(close, ta.sma(close, input(defval = 21, title = 'Entry Line')))if matwohun and mafentry and higheshigh and twohunraise and buyvolhigh//if higheshigh and higheslow and highvol    allup := trueplotshape(allup, style=shape.arrowup,location=location.belowbar, color=color.green, title = "Buy Signal")barsSinceLastEntry() =>    strategy.opentrades > 0 ? bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) : na    //Sell Signalmafexit =ta.sma(close, 50) < ta.sma(close, 90)matexit = ta.sma(close, 21) < ta.sma(close, 50)matwohund = close < ta.sma(close, 200)linebreak = ta.sma(close, input(defval = 21, title = 'Exit Line')) > closelowesthigh = ta.falling(high, 3)lowestlow = ta.falling(low, 2 )twohunfall = ta.falling(out, 3)twentyfall = ta.falling(outt, 2)highvole =  ta.crossover(volume, ta.sma(volume, 5))//fourlow = ta.lowest(close, lookback)//fourhig = ta.highest(close, lookback)changed =  (((fourhig - close) / close) * 100) >= 10red = close < openatr = ta.atr(14)//atrsmalen = int(bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) )atrsmalen = barsSinceLastEntry()atrsma = falseatrlen = 5if str.tostring(atrsmalen) != 'NaN' and atrsmalen > 0    atrlen := atrsmalen    atrsma := atr > ta.sma(atr,50)alldwn = falseif sellvolhigh and lowestlow and (close < close[1] and close < open)//if higheshigh and higheslow and highvol    alldwn := trueplotshape(alldwn, style=shape.arrowdown,location=location.abovebar, color=color.red, title = "Sell Signal")longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))if (allup)    strategy.entry("My Long Entry Id", strategy.long)shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))if (alldwn)    strategy.entry("My Short Entry Id", strategy.short)