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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Start date | timestamp("01 Jan 2001 00:00") | time | trig |
| Finish date | timestamp("01 Jan 2101 00:00") | time | trig |
| Period for low | 50 | int | hl |
| Depth grid | 10 | int | money order buy line 35 |
| Drawdown % | 3.0 | float | pricen |
| Take % | 3.0 | float | tp |
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 buy long | cond and strategy.position_size == 0 and strategy.equity > 0 and trig | On | 34 |
| order buy long | strategy.position_size != 0 and strategy.equity > 0 and trig and i <= n - 1 | On | 36 |
| Exit buy limit | trig | On | 38 |
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 | +17.1% | +102.5% | 49 | 82% | 6.82 | 16.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +4.9% | +5.5% | 17 | 88% | 12.43 | 17.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +26.4% | +9.8% | 76 | 75% | 3.73 | 19.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +4.3% | +8.4% | 15 | 87% | 9.49 | 21.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +21.7% | +16.7% | 54 | 76% | 3.69 | 35.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +4.3% | +21.5% | 15 | 80% | 5.86 | 20.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +10.6% | +148.3% | 33 | 79% | 4.07 | 18.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +6.2% | +17.1% | 21 | 86% | 14.71 | 2.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 100% | $19.22 |
| Sideways market | 17 | 88% | $50.53 |
| Falling market | 28 | 75% | $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.
All 49 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 1 May 2024 60,672.00 | 3 May 2024 61,255.50 | 2 | $0.80 |
| long | 2 May 2024 58,365.00 | 3 May 2024 61,255.50 | 1 | $4.79 |
| long | 24 Jun 2024 59,060.60 | 25 Jun 2024 60,832.40 | 1 | $2.89 |
| long | 29 Jun 2024 60,427.80 | 30 Jun 2024 62,240.70 | 1 | $2.84 |
| long | 4 Jul 2024 58,615.00 | 10 Jul 2024 58,395.90 | 6 | −$0.50 |
| long | 5 Jul 2024 56,856.60 | 10 Jul 2024 58,395.90 | 5 | $2.61 |
| long | 7 Jul 2024 55,990.70 | 10 Jul 2024 58,395.90 | 3 | $4.21 |
| long | 8 Jul 2024 55,419.40 | 10 Jul 2024 58,395.90 | 2 | $5.29 |
| long | 5 Aug 2024 54,994.20 | 6 Aug 2024 56,644.00 | 1 | $2.90 |
| long | 6 Sep 2024 53,344.30 | 8 Sep 2024 54,944.70 | 2 | $2.90 |
| long | 14 Jan 2025 94,536.10 | 15 Jan 2025 97,372.20 | 1 | $2.96 |
| long | 3 Feb 2025 91,700.00 | 4 Feb 2025 101,329.00 | 1 | $10.67 |
| long | 25 Feb 2025 88,949.00 | 2 Mar 2025 88,365.90 | 5 | −$0.80 |
| long | 26 Feb 2025 86,280.50 | 2 Mar 2025 88,365.90 | 4 | $2.36 |
| long | 27 Feb 2025 84,250.10 | 2 Mar 2025 88,365.90 | 3 | $4.86 |
| long | 28 Feb 2025 83,863.20 | 2 Mar 2025 88,365.90 | 2 | $5.40 |
| long | 3 Mar 2025 86,064.50 | 4 Mar 2025 88,646.50 | 1 | $3.03 |
| long | 4 Mar 2025 83,482.60 | 5 Mar 2025 87,282.00 | 1 | $4.67 |
| long | 9 Mar 2025 80,978.10 | 10 Mar 2025 83,407.50 | 1 | $3.03 |
| long | 10 Mar 2025 78,548.80 | 10 Mar 2025 83,407.50 | 0 | $6.39 |
| long | 11 Mar 2025 78,595.90 | 12 Mar 2025 82,933.00 | 1 | $5.63 |
| long | 7 Apr 2025 76,238.00 | 8 Apr 2025 79,163.20 | 1 | $3.98 |
| long | 31 Aug 2025 108,377.00 | 2 Sep 2025 111,629.00 | 2 | $3.11 |
| long | 10 Oct 2025 105,126.00 | 11 Oct 2025 112,774.00 | 1 | $7.73 |
| long | 4 Nov 2025 101,972.00 | 9 Nov 2025 105,031.00 | 5 | $3.11 |
| long | 12 Nov 2025 102,313.00 | 14 Jan 2026 97,419.80 | 63 | −$5.36 |
| long | 13 Nov 2025 99,243.60 | 14 Jan 2026 97,419.80 | 62 | −$2.14 |
| long | 14 Nov 2025 97,732.20 | 14 Jan 2026 97,419.80 | 61 | −$0.48 |
| long | 15 Nov 2025 94,594.00 | 14 Jan 2026 97,419.80 | 60 | $3.07 |
| long | 16 Nov 2025 95,461.60 | 14 Jan 2026 97,419.80 | 59 | $2.11 |
| long | 17 Nov 2025 94,261.40 | 14 Jan 2026 97,419.80 | 58 | $3.51 |
| long | 18 Nov 2025 92,215.10 | 14 Jan 2026 97,419.80 | 57 | $5.91 |
| long | 19 Nov 2025 92,960.80 | 14 Jan 2026 97,419.80 | 56 | $5.08 |
| long | 20 Nov 2025 91,555.00 | 14 Jan 2026 97,419.80 | 55 | $6.76 |
| long | 21 Nov 2025 86,637.20 | 14 Jan 2026 97,419.80 | 54 | $12.61 |
| long | 30 Jan 2026 84,650.20 | 17 Apr 2026 77,206.90 | 77 | −$9.51 |
| long | 31 Jan 2026 82,110.60 | 17 Apr 2026 77,206.90 | 76 | −$6.86 |
| long | 1 Feb 2026 78,741.10 | 17 Apr 2026 77,206.90 | 75 | −$2.27 |
| long | 2 Feb 2026 76,968.20 | 17 Apr 2026 77,206.90 | 74 | $0.21 |
| long | 3 Feb 2026 78,080.70 | 17 Apr 2026 77,206.90 | 73 | −$1.39 |
| long | 4 Feb 2026 75,770.20 | 17 Apr 2026 77,206.90 | 72 | $1.95 |
| long | 5 Feb 2026 73,165.80 | 17 Apr 2026 77,206.90 | 71 | $5.79 |
| long | 6 Feb 2026 62,909.90 | 17 Apr 2026 77,206.90 | 70 | $21.06 |
| long | 7 Feb 2026 70,580.30 | 17 Apr 2026 77,206.90 | 69 | $9.94 |
| long | 8 Feb 2026 69,289.40 | 17 Apr 2026 77,206.90 | 68 | $12.02 |
| long | 11 Jun 2026 61,511.00 | 12 Jun 2026 63,626.00 | 1 | $3.82 |
| long | 24 Jun 2026 59,665.70 | 25 Jun 2026 61,455.60 | 1 | $3.33 |
| long | 26 Jun 2026 59,794.60 | 2 Jul 2026 60,640.80 | 6 | $1.47 |
| long | 1 Jul 2026 58,000.80 | 2 Jul 2026 60,640.80 | 1 | $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.
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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | Yes 1,000 bars in 42 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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)