Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

ST_greed_spot_example

A Pine Script v5 strategy with no technical-analysis calculation. It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 100% of equity and pays 0.06 commission. 6 settings; defaults include Period for low 50, Depth grid 10 and Drawdown % 3.0.

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 ST_greed_spot_example repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 14 of 14 trades.
How did ST_greed_spot_example do on BTCUSDT 1D with default settings?
+17.07%
From 26 Jan 2024 to 21 Oct 2026, over 49 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does ST_greed_spot_example 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: 49 before, 49 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 ST_greed_spot_example use a stop loss?
No
Its exits set a profit target but no stop.
Does ST_greed_spot_example run in Zeal Terminal?
Yes
It compiles in 18 ms and runs 1,000 bars in 42 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • 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,171$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
+17.07%
$170.68
Buy and hold
+102.5%
same period
Closed trades
49
40 won · 9 lost
Profitable
81.6%
of closed trades
Profit factor
6.82
gross profit ÷ gross loss
Max drawdown
16.40%
−$184.67

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

    strategy.exit is used without a stop, loss or trailing stop.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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
Start datetimestamp("01 Jan 2001 00:00")timetrig
Finish datetimestamp("01 Jan 2101 00:00")timetrig
Period for low50inthl
Depth grid10intmoney order buy line 35
Drawdown %3.0floatpricen
Take %3.0floattp

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.

timetimeprice datastartStart datesetting · timestamp("01 Jan 2…finishFinish datesetting · timestamp("01 Jan 2…lPeriod for lowsetting · 50nDepth gridsetting · 10closecloseprice datakDrawdown %setting · 3.0tTake %setting · 3.0lowlowprice datatrigtrigvaluehlhlvaluemoneymoneyvalueprice1price1valuevol1vol1valueiivaluepricenpricenvaluevolnvolnvaluetptpvaluecondcondconditionentry:buyOpen buystrategy.entryorder:buyorder buystrategy.orderexit:buyexit buystrategy.exitplot:30plotplotplot:31plotplotplot:32plotplot

Order rules

OrderFires whenBy defaultLine
Open buy longcond and strategy.position_size == 0 and strategy.equity > 0 and trigOn34
order buy longstrategy.position_size != 0 and strategy.equity > 0 and trig and i <= n - 1On36
Exit buy limittrigOn38

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.

14/14trades 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+17.1%+102.5%4982%6.8216.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+4.9%+5.5%1788%12.4317.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+26.4%+9.8%7675%3.7319.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+4.3%+8.4%1587%9.4921.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+21.7%+16.7%5476%3.6935.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+4.3%+21.5%1580%5.8620.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+10.6%+148.3%3379%4.0718.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+6.2%+17.1%2186%14.712.7%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 market4100%$19.22
Sideways market1788%$50.53
Falling market2875%$100.92

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

How bad could the drawdown be?

1.4%

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

0%2%
All 49 trades
SideEntryExitBarsP&L
long1 May 2024 60,672.003 May 2024 61,255.502$0.80
long2 May 2024 58,365.003 May 2024 61,255.501$4.79
long24 Jun 2024 59,060.6025 Jun 2024 60,832.401$2.89
long29 Jun 2024 60,427.8030 Jun 2024 62,240.701$2.84
long4 Jul 2024 58,615.0010 Jul 2024 58,395.906−$0.50
long5 Jul 2024 56,856.6010 Jul 2024 58,395.905$2.61
long7 Jul 2024 55,990.7010 Jul 2024 58,395.903$4.21
long8 Jul 2024 55,419.4010 Jul 2024 58,395.902$5.29
long5 Aug 2024 54,994.206 Aug 2024 56,644.001$2.90
long6 Sep 2024 53,344.308 Sep 2024 54,944.702$2.90
long14 Jan 2025 94,536.1015 Jan 2025 97,372.201$2.96
long3 Feb 2025 91,700.004 Feb 2025 101,329.001$10.67
long25 Feb 2025 88,949.002 Mar 2025 88,365.905−$0.80
long26 Feb 2025 86,280.502 Mar 2025 88,365.904$2.36
long27 Feb 2025 84,250.102 Mar 2025 88,365.903$4.86
long28 Feb 2025 83,863.202 Mar 2025 88,365.902$5.40
long3 Mar 2025 86,064.504 Mar 2025 88,646.501$3.03
long4 Mar 2025 83,482.605 Mar 2025 87,282.001$4.67
long9 Mar 2025 80,978.1010 Mar 2025 83,407.501$3.03
long10 Mar 2025 78,548.8010 Mar 2025 83,407.500$6.39
long11 Mar 2025 78,595.9012 Mar 2025 82,933.001$5.63
long7 Apr 2025 76,238.008 Apr 2025 79,163.201$3.98
long31 Aug 2025 108,377.002 Sep 2025 111,629.002$3.11
long10 Oct 2025 105,126.0011 Oct 2025 112,774.001$7.73
long4 Nov 2025 101,972.009 Nov 2025 105,031.005$3.11
long12 Nov 2025 102,313.0014 Jan 2026 97,419.8063−$5.36
long13 Nov 2025 99,243.6014 Jan 2026 97,419.8062−$2.14
long14 Nov 2025 97,732.2014 Jan 2026 97,419.8061−$0.48
long15 Nov 2025 94,594.0014 Jan 2026 97,419.8060$3.07
long16 Nov 2025 95,461.6014 Jan 2026 97,419.8059$2.11
long17 Nov 2025 94,261.4014 Jan 2026 97,419.8058$3.51
long18 Nov 2025 92,215.1014 Jan 2026 97,419.8057$5.91
long19 Nov 2025 92,960.8014 Jan 2026 97,419.8056$5.08
long20 Nov 2025 91,555.0014 Jan 2026 97,419.8055$6.76
long21 Nov 2025 86,637.2014 Jan 2026 97,419.8054$12.61
long30 Jan 2026 84,650.2017 Apr 2026 77,206.9077−$9.51
long31 Jan 2026 82,110.6017 Apr 2026 77,206.9076−$6.86
long1 Feb 2026 78,741.1017 Apr 2026 77,206.9075−$2.27
long2 Feb 2026 76,968.2017 Apr 2026 77,206.9074$0.21
long3 Feb 2026 78,080.7017 Apr 2026 77,206.9073−$1.39
long4 Feb 2026 75,770.2017 Apr 2026 77,206.9072$1.95
long5 Feb 2026 73,165.8017 Apr 2026 77,206.9071$5.79
long6 Feb 2026 62,909.9017 Apr 2026 77,206.9070$21.06
long7 Feb 2026 70,580.3017 Apr 2026 77,206.9069$9.94
long8 Feb 2026 69,289.4017 Apr 2026 77,206.9068$12.02
long11 Jun 2026 61,511.0012 Jun 2026 63,626.001$3.82
long24 Jun 2026 59,665.7025 Jun 2026 61,455.601$3.33
long26 Jun 2026 59,794.602 Jul 2026 60,640.806$1.47
long1 Jul 2026 58,000.802 Jul 2026 60,640.801$5.16

Similar scripts

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

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.

  • 4 settings use the untyped input() (line 8, 11, 25, 28). 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 49 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 8: input() → input.int()
  • Line 11: input() → input.int()
  • Line 25: input() → input.float()
  • Line 28: input() → input.float()
⋯trig = time > start and time < finish ? true : false-l = ta.lowest(low, input(50, title = 'Period for low'))+l = ta.lowest(low, input.int(50, title = 'Period for low'))hl = l[6]// plot(hl, color = color.red)-n = input(10, title = 'Depth grid')+n = input.int(10, title = 'Depth grid')var money = 0.0⋯    -k = input(3.0, title = 'Drawdown %')+k = input.float(3.0, title = 'Drawdown %')pricen = strategy.position_avg_price * (1 - (k/100))voln = money/pricen-t = input(3.0, title = 'Take %')+t = input.float(3.0, title = 'Take %')tp = strategy.position_avg_price * (1 + (t/100))⋯

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

⋯// © Alferow-//@version=5+//@version=6strategy("ST_gree_spot_example", overlay=true, initial_capital = 1000, pyramiding = 20, commission_value = 0.06, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msYes 1,000 bars in 42 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/// © Alferow//@version=5strategy("ST_gree_spot_example", overlay=true, initial_capital = 1000, pyramiding = 20, commission_value = 0.06, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)start = input.time(timestamp("01 Jan 2001 00:00"), title = 'Start date')finish = input.time(timestamp("01 Jan 2101 00:00"), title = 'Finish date')trig = time > start and time < finish ? true : falsel = ta.lowest(low, input(50, title = 'Period for low'))hl = l[6]// plot(hl, color = color.red)n = input(10, title = 'Depth grid')var money = 0.0var price1 = 0.0cond = low < hl and close > hlif strategy.position_size == 0 and cond and strategy.equity > 0    price1 := close[1]    money := strategy.equity/nvol1 = money/price1var i = 0if strategy.position_size > strategy.position_size[1]    i := i + 1if strategy.position_size == 0    i := 0    k = input(3.0, title = 'Drawdown %')pricen = strategy.position_avg_price * (1 - (k/100))voln = money/pricent = input(3.0, title = 'Take %')tp = strategy.position_avg_price * (1 + (t/100))plot(strategy.position_avg_price, color = color.white)plot(tp, color = color.green)plot(pricen, color = color.red, offset = 3)if cond and strategy.position_size == 0 and strategy.equity > 0 and trig    strategy.entry('buy', strategy.long, qty = vol1, limit = price1)if strategy.position_size != 0 and strategy.equity > 0 and trig and i <= n - 1    strategy.order('buy', strategy.long, qty = voln, limit = pricen)if trig    strategy.exit('buy', limit = tp)