Pine Script v4 · Strategy
Multiple -- profit exits example
A Pine Script v4 strategy built on Crossover or SMA (close, 14, close, 28) and Crossunder or SMA (close, 14, close, 28). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is 100 contracts and pays no commission. It has no settings.
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 Multiple -- profit exits example repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 48 of 48 trades.
- How did Multiple -- profit exits example do on BTCUSDT 1D with default settings?
- −457.31%
- From 26 Jan 2024 to 21 Oct 2026, over 172 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Multiple -- profit exits example 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.
- Does Multiple -- profit exits example use a stop loss?
- Yes
- strategy.exit sets a stop on line 14, 15, 16, 17.
- Does Multiple -- profit exits example run in Zeal Terminal?
- Yes
- It compiles in 14 ms and runs 1,000 bars in 37 ms, in the browser.
BTCUSDT · 1D · default settings
- open profit % upper bound
- open profit % lower bound
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −457.31%
- −$457,309.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 172
- 83 won · 89 lost
- Profitable
- 48.3%
- of closed trades
- Profit factor
- 0.92
- gross profit ÷ gross loss
- Max drawdown
- 197.08%
- −$2,227,670.00
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.
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 crossover → ta.crossover, sma → ta.sma, crossunder → ta.crossunder, round → math.round.
Same 172 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 5: crossover → ta.crossover
- Line 5: sma → ta.sma
- Line 5: sma → ta.sma
- Line 8: crossunder → ta.crossunder
- Line 8: sma → ta.sma
- Line 8: sma → ta.sma
- Line 12: round → math.round
⋯// © adolgov-//@version=4+//@version=5strategy("Multiple %% profit exits example", overlay=false, default_qty_value = 100)-longCondition = crossover(sma(close, 14), sma(close, 28))+longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))if (longCondition) strategy.entry("My Long Entry Id", strategy.long)-shortCondition = crossunder(sma(close, 14), sma(close, 28))+shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))if (shortCondition)⋯percentAsPoints(pcnt) =>- strategy.position_size != 0 ? round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)+ strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)lossPnt = percentAsPoints(2)⋯Clean v5
VerifiedNothing to change.
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: 172 before, 79 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.
⋯// © adolgov-//@version=5+//@version=6strategy("Multiple %% profit exits example", overlay=false, default_qty_value = 100)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
- Crossover / SMA (
crossover,ta.crossoverin v5)sma(close, 14), sma(close, 28)longCondition · line 5 - Crossunder / SMA (
crossunder,ta.crossunderin v5)sma(close, 14), sma(close, 28)shortCondition · line 8
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 My Long Entry Id long | (longCondition) | On | 7 |
| Open My Short Entry Id short | (shortCondition) | On | 10 |
| Exit x1 stop and limit | every bar | On | 14 |
| Exit x2 stop and limit | every bar | On | 15 |
| Exit x3 stop and limit | every bar | On | 16 |
| Exit x4 stop and limit | every bar | On | 17 |
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 | −457.3% | +102.5% | 172 | 48% | 0.92 | 197.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −1,428.4% | +5.5% | 158 | 36% | 0.59 | 1,629.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +9.3% | +9.8% | 150 | 39% | 1.05 | 55.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −31.8% | +8.4% | 169 | 44% | 0.72 | 50.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +1.3% | +16.7% | 132 | 53% | 1.16 | 4.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +1.1% | +21.5% | 155 | 53% | 1.34 | 1.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −4.9% | +148.3% | 148 | 41% | 0.84 | 13.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −6.7% | +17.1% | 161 | 42% | 0.78 | 12.6% | 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 | 60 | 52% | −$297,745.00 |
| Sideways market | 72 | 50% | −$314,862.00 |
| Falling market | 40 | 40% | $155,298.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
99.3%
The 95th percentile of the worst drawdown when the same 172 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 87.1% to 99.3%; the tick is what actually happened, 99.5%. Order luck alone moves it this much.
The first 150 of 172 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 29 Mar 2024 70,780.60 | 30 Mar 2024 69,850.50 | 1 | $23,251.80 |
| short | 29 Mar 2024 70,780.60 | 1 Apr 2024 69,365.00 | 3 | $35,390.30 |
| short | 29 Mar 2024 70,780.60 | 1 Apr 2024 68,657.20 | 3 | $53,085.50 |
| short | 29 Mar 2024 70,780.60 | 2 Apr 2024 67,949.40 | 4 | $70,780.50 |
| long | 6 Apr 2024 67,820.60 | 7 Apr 2024 68,896.00 | 1 | $26,884.20 |
| long | 6 Apr 2024 67,820.60 | 7 Apr 2024 69,177.00 | 1 | $33,910.20 |
| long | 6 Apr 2024 67,820.60 | 7 Apr 2024 69,855.30 | 1 | $50,865.50 |
| long | 6 Apr 2024 67,820.60 | 8 Apr 2024 70,533.50 | 2 | $67,820.80 |
| short | 16 Apr 2024 63,420.00 | 17 Apr 2024 62,785.80 | 1 | $15,855.00 |
| short | 16 Apr 2024 63,420.00 | 17 Apr 2024 62,151.60 | 1 | $31,710.00 |
| short | 16 Apr 2024 63,420.00 | 17 Apr 2024 61,517.40 | 1 | $47,565.00 |
| short | 16 Apr 2024 63,420.00 | 17 Apr 2024 60,883.20 | 1 | $63,420.00 |
| long | 19 May 2024 66,915.20 | 20 May 2024 67,584.40 | 1 | $16,728.80 |
| long | 19 May 2024 66,915.20 | 20 May 2024 68,253.50 | 1 | $33,457.50 |
| long | 19 May 2024 66,915.20 | 20 May 2024 68,922.70 | 1 | $50,186.50 |
| long | 19 May 2024 66,915.20 | 20 May 2024 69,591.80 | 1 | $66,915.30 |
| short | 17 Jun 2024 66,676.90 | 18 Jun 2024 66,010.10 | 1 | $16,669.30 |
| short | 17 Jun 2024 66,676.90 | 18 Jun 2024 65,343.30 | 1 | $33,338.50 |
| short | 17 Jun 2024 66,676.90 | 18 Jun 2024 64,676.60 | 1 | $50,007.70 |
| short | 17 Jun 2024 66,676.90 | 21 Jun 2024 64,009.80 | 4 | $66,676.80 |
| long | 21 Jul 2024 67,140.00 | 22 Jul 2024 68,165.40 | 1 | $25,634.50 |
| long | 21 Jul 2024 67,140.00 | 23 Jul 2024 65,797.20 | 2 | −$33,570.00 |
| long | 21 Jul 2024 67,140.00 | 23 Jul 2024 65,797.20 | 2 | −$33,570.00 |
| long | 21 Jul 2024 67,140.00 | 23 Jul 2024 65,797.20 | 2 | −$33,570.00 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$163,806.00 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$163,806.00 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$163,806.00 |
| short | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | −$163,806.00 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$85,475.00 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$85,475.00 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$85,475.00 |
| long | 27 Aug 2024 62,834.00 | 28 Aug 2024 59,415.00 | 1 | −$85,475.00 |
| short | 7 Sep 2024 53,963.00 | 8 Sep 2024 55,042.20 | 1 | −$26,981.50 |
| short | 7 Sep 2024 53,963.00 | 8 Sep 2024 55,042.20 | 1 | −$26,981.50 |
| short | 7 Sep 2024 53,963.00 | 8 Sep 2024 55,042.20 | 1 | −$26,981.50 |
| short | 7 Sep 2024 53,963.00 | 8 Sep 2024 55,042.20 | 1 | −$26,981.50 |
| long | 22 Sep 2024 63,349.00 | 23 Sep 2024 63,982.50 | 1 | $15,837.20 |
| long | 22 Sep 2024 63,349.00 | 23 Sep 2024 64,615.90 | 1 | $31,674.50 |
| long | 22 Sep 2024 63,349.00 | 26 Sep 2024 65,249.40 | 4 | $47,511.80 |
| long | 22 Sep 2024 63,349.00 | 27 Sep 2024 65,882.90 | 5 | $63,349.00 |
| short | 12 Oct 2024 62,540.00 | 14 Oct 2024 63,790.80 | 2 | −$31,270.00 |
| short | 12 Oct 2024 62,540.00 | 14 Oct 2024 63,790.80 | 2 | −$31,270.00 |
| short | 12 Oct 2024 62,540.00 | 14 Oct 2024 63,790.80 | 2 | −$31,270.00 |
| short | 12 Oct 2024 62,540.00 | 14 Oct 2024 63,790.80 | 2 | −$31,270.00 |
| long | 18 Oct 2024 67,421.80 | 19 Oct 2024 68,428.00 | 1 | $25,155.30 |
| long | 18 Oct 2024 67,421.80 | 20 Oct 2024 68,770.20 | 2 | $33,711.00 |
| long | 18 Oct 2024 67,421.80 | 21 Oct 2024 69,444.40 | 3 | $50,566.20 |
| long | 18 Oct 2024 67,421.80 | 23 Oct 2024 66,073.30 | 5 | −$33,711.00 |
| short | 30 Dec 2024 93,738.20 | 31 Dec 2024 92,792.10 | 1 | $23,653.50 |
| short | 30 Dec 2024 93,738.20 | 31 Dec 2024 95,612.90 | 1 | −$46,869.00 |
| short | 30 Dec 2024 93,738.20 | 31 Dec 2024 95,612.90 | 1 | −$46,869.00 |
| short | 30 Dec 2024 93,738.20 | 31 Dec 2024 95,612.90 | 1 | −$46,869.00 |
| long | 15 Jan 2025 96,560.90 | 16 Jan 2025 100,497.00 | 1 | $98,412.50 |
| long | 15 Jan 2025 96,560.90 | 16 Jan 2025 100,497.00 | 1 | $98,412.50 |
| long | 15 Jan 2025 96,560.90 | 16 Jan 2025 100,497.00 | 1 | $98,412.50 |
| long | 15 Jan 2025 96,560.90 | 16 Jan 2025 100,497.00 | 1 | $98,412.50 |
| short | 8 Feb 2025 96,506.80 | 9 Feb 2025 95,541.70 | 1 | $24,126.80 |
| short | 8 Feb 2025 96,506.80 | 11 Feb 2025 98,436.90 | 3 | −$48,253.50 |
| short | 8 Feb 2025 96,506.80 | 11 Feb 2025 98,436.90 | 3 | −$48,253.50 |
| short | 8 Feb 2025 96,506.80 | 11 Feb 2025 98,436.90 | 3 | −$48,253.50 |
| long | 31 Mar 2025 82,390.00 | 1 Apr 2025 83,213.90 | 1 | $20,597.50 |
| long | 31 Mar 2025 82,390.00 | 1 Apr 2025 84,037.80 | 1 | $41,195.00 |
| long | 31 Mar 2025 82,390.00 | 1 Apr 2025 84,861.70 | 1 | $61,792.50 |
| long | 31 Mar 2025 82,390.00 | 2 Apr 2025 85,685.60 | 2 | $82,390.00 |
| short | 8 Apr 2025 79,163.20 | 9 Apr 2025 76,322.40 | 1 | $71,020.50 |
| short | 8 Apr 2025 79,163.20 | 9 Apr 2025 76,322.40 | 1 | $71,020.50 |
| short | 8 Apr 2025 79,163.20 | 9 Apr 2025 76,322.40 | 1 | $71,020.50 |
| short | 8 Apr 2025 79,163.20 | 9 Apr 2025 75,996.70 | 1 | $79,163.20 |
| long | 22 Apr 2025 87,516.20 | 23 Apr 2025 93,443.00 | 1 | $148,169.00 |
| long | 22 Apr 2025 87,516.20 | 23 Apr 2025 93,443.00 | 1 | $148,169.00 |
| long | 22 Apr 2025 87,516.20 | 23 Apr 2025 93,443.00 | 1 | $148,169.00 |
| long | 22 Apr 2025 87,516.20 | 23 Apr 2025 93,443.00 | 1 | $148,169.00 |
| short | 9 Jun 2025 105,734.00 | 10 Jun 2025 110,263.00 | 1 | −$113,225.00 |
| short | 9 Jun 2025 105,734.00 | 10 Jun 2025 110,263.00 | 1 | −$113,225.00 |
| short | 9 Jun 2025 105,734.00 | 10 Jun 2025 110,263.00 | 1 | −$113,225.00 |
| short | 9 Jun 2025 105,734.00 | 10 Jun 2025 110,263.00 | 1 | −$113,225.00 |
| long | 20 Jun 2025 104,659.00 | 21 Jun 2025 102,565.00 | 1 | −$52,329.20 |
| long | 20 Jun 2025 104,659.00 | 21 Jun 2025 102,565.00 | 1 | −$52,329.20 |
| long | 20 Jun 2025 104,659.00 | 21 Jun 2025 102,565.00 | 1 | −$52,329.20 |
| long | 20 Jun 2025 104,659.00 | 21 Jun 2025 102,565.00 | 1 | −$52,329.20 |
| short | 24 Jun 2025 105,334.00 | 25 Jun 2025 107,441.00 | 1 | −$52,667.00 |
| short | 24 Jun 2025 105,334.00 | 25 Jun 2025 107,441.00 | 1 | −$52,667.00 |
| short | 24 Jun 2025 105,334.00 | 25 Jun 2025 107,441.00 | 1 | −$52,667.00 |
| short | 24 Jun 2025 105,334.00 | 25 Jun 2025 107,441.00 | 1 | −$52,667.00 |
| long | 5 Jul 2025 107,984.00 | 6 Jul 2025 109,064.00 | 1 | $26,996.00 |
| long | 5 Jul 2025 107,984.00 | 9 Jul 2025 110,144.00 | 4 | $53,992.30 |
| long | 5 Jul 2025 107,984.00 | 9 Jul 2025 111,224.00 | 4 | $80,988.20 |
| long | 5 Jul 2025 107,984.00 | 10 Jul 2025 112,304.00 | 5 | $107,984.00 |
| short | 6 Aug 2025 114,130.00 | 7 Aug 2025 116,412.00 | 1 | −$57,065.00 |
| short | 6 Aug 2025 114,130.00 | 7 Aug 2025 116,412.00 | 1 | −$57,065.00 |
| short | 6 Aug 2025 114,130.00 | 7 Aug 2025 116,412.00 | 1 | −$57,065.00 |
| short | 6 Aug 2025 114,130.00 | 7 Aug 2025 116,412.00 | 1 | −$57,065.00 |
| long | 17 Aug 2025 117,381.00 | 18 Aug 2025 115,033.00 | 1 | −$58,690.30 |
| long | 17 Aug 2025 117,381.00 | 18 Aug 2025 115,033.00 | 1 | −$58,690.30 |
| long | 17 Aug 2025 117,381.00 | 18 Aug 2025 115,033.00 | 1 | −$58,690.30 |
| long | 17 Aug 2025 117,381.00 | 18 Aug 2025 115,033.00 | 1 | −$58,690.30 |
| short | 27 Aug 2025 111,763.00 | 29 Aug 2025 110,646.00 | 2 | $27,940.80 |
| short | 27 Aug 2025 111,763.00 | 29 Aug 2025 109,528.00 | 2 | $55,881.50 |
| short | 27 Aug 2025 111,763.00 | 29 Aug 2025 108,410.00 | 2 | $83,822.50 |
| short | 27 Aug 2025 111,763.00 | 1 Sep 2025 107,293.00 | 5 | $111,763.00 |
| long | 15 Sep 2025 115,268.00 | 16 Sep 2025 116,421.00 | 1 | $28,817.00 |
| long | 15 Sep 2025 115,268.00 | 18 Sep 2025 117,573.00 | 3 | $57,634.00 |
| long | 15 Sep 2025 115,268.00 | 22 Sep 2025 112,963.00 | 7 | −$57,634.00 |
| long | 15 Sep 2025 115,268.00 | 22 Sep 2025 112,963.00 | 7 | −$57,634.00 |
| short | 1 Oct 2025 114,049.00 | 2 Oct 2025 118,595.00 | 1 | −$113,651.00 |
| short | 1 Oct 2025 114,049.00 | 2 Oct 2025 118,595.00 | 1 | −$113,651.00 |
| short | 1 Oct 2025 114,049.00 | 2 Oct 2025 118,595.00 | 1 | −$113,651.00 |
| short | 1 Oct 2025 114,049.00 | 2 Oct 2025 118,595.00 | 1 | −$113,651.00 |
| long | 6 Oct 2025 123,482.00 | 7 Oct 2025 124,717.00 | 1 | $30,870.50 |
| long | 6 Oct 2025 123,482.00 | 7 Oct 2025 121,013.00 | 1 | −$61,741.30 |
| long | 6 Oct 2025 123,482.00 | 7 Oct 2025 121,013.00 | 1 | −$61,741.30 |
| long | 6 Oct 2025 123,482.00 | 7 Oct 2025 121,013.00 | 1 | −$61,741.30 |
| short | 20 Oct 2025 108,643.00 | 21 Oct 2025 107,556.00 | 1 | $27,160.80 |
| short | 20 Oct 2025 108,643.00 | 21 Oct 2025 110,816.00 | 1 | −$54,321.50 |
| short | 20 Oct 2025 108,643.00 | 21 Oct 2025 110,816.00 | 1 | −$54,321.50 |
| short | 20 Oct 2025 108,643.00 | 21 Oct 2025 110,816.00 | 1 | −$54,321.50 |
| long | 11 Dec 2025 92,015.40 | 12 Dec 2025 90,175.10 | 1 | −$46,007.70 |
| long | 11 Dec 2025 92,015.40 | 12 Dec 2025 90,175.10 | 1 | −$46,007.70 |
| long | 11 Dec 2025 92,015.40 | 12 Dec 2025 90,175.10 | 1 | −$46,007.70 |
| long | 11 Dec 2025 92,015.40 | 12 Dec 2025 90,175.10 | 1 | −$46,007.70 |
| short | 20 Dec 2025 88,136.90 | 22 Dec 2025 89,899.70 | 2 | −$44,068.50 |
| short | 20 Dec 2025 88,136.90 | 22 Dec 2025 89,899.70 | 2 | −$44,068.50 |
| short | 20 Dec 2025 88,136.90 | 22 Dec 2025 89,899.70 | 2 | −$44,068.50 |
| short | 20 Dec 2025 88,136.90 | 22 Dec 2025 89,899.70 | 2 | −$44,068.50 |
| long | 7 Jan 2026 93,748.00 | 8 Jan 2026 91,364.20 | 1 | −$59,595.20 |
| long | 7 Jan 2026 93,748.00 | 8 Jan 2026 91,364.20 | 1 | −$59,595.20 |
| long | 7 Jan 2026 93,748.00 | 8 Jan 2026 91,364.20 | 1 | −$59,595.20 |
| long | 7 Jan 2026 93,748.00 | 8 Jan 2026 91,364.20 | 1 | −$59,595.20 |
| short | 29 Jan 2026 89,300.00 | 30 Jan 2026 84,650.20 | 1 | $116,246.00 |
| short | 29 Jan 2026 89,300.00 | 30 Jan 2026 84,650.20 | 1 | $116,246.00 |
| short | 29 Jan 2026 89,300.00 | 30 Jan 2026 84,650.20 | 1 | $116,246.00 |
| short | 29 Jan 2026 89,300.00 | 30 Jan 2026 84,650.20 | 1 | $116,246.00 |
| long | 10 Mar 2026 68,432.20 | 11 Mar 2026 69,948.60 | 1 | $37,912.00 |
| long | 10 Mar 2026 68,432.20 | 11 Mar 2026 69,948.60 | 1 | $37,912.00 |
| long | 10 Mar 2026 68,432.20 | 11 Mar 2026 70,485.10 | 1 | $51,324.00 |
| long | 10 Mar 2026 68,432.20 | 11 Mar 2026 71,169.40 | 1 | $68,432.20 |
| short | 31 Mar 2026 66,797.40 | 1 Apr 2026 68,284.50 | 1 | −$37,177.80 |
| short | 31 Mar 2026 66,797.40 | 1 Apr 2026 68,284.50 | 1 | −$37,177.80 |
| short | 31 Mar 2026 66,797.40 | 1 Apr 2026 68,284.50 | 1 | −$37,177.80 |
| short | 31 Mar 2026 66,797.40 | 1 Apr 2026 68,284.50 | 1 | −$37,177.80 |
| long | 14 Apr 2026 74,418.00 | 15 Apr 2026 75,162.20 | 1 | $18,604.50 |
| long | 14 Apr 2026 74,418.00 | 17 Apr 2026 75,906.40 | 3 | $37,209.00 |
| long | 14 Apr 2026 74,418.00 | 17 Apr 2026 76,650.50 | 3 | $55,813.50 |
| long | 14 Apr 2026 74,418.00 | 17 Apr 2026 77,394.70 | 3 | $74,418.00 |
| short | 24 May 2026 76,752.00 | 26 May 2026 75,984.50 | 2 | $19,188.00 |
| short | 24 May 2026 76,752.00 | 27 May 2026 75,217.00 | 3 | $38,376.00 |
| short | 24 May 2026 76,752.00 | 27 May 2026 74,449.40 | 3 | $57,564.00 |
| short | 24 May 2026 76,752.00 | 28 May 2026 73,681.90 | 4 | $76,752.00 |
| long | 14 Jul 2026 62,334.50 | 15 Jul 2026 65,044.00 | 1 | $67,736.80 |
| long | 14 Jul 2026 62,334.50 | 15 Jul 2026 65,044.00 | 1 | $67,736.80 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Multiple -- profit exits example this page | — | v4 strategy | −457.3% | 172 | 197.1% |
| Follow the Crypto Shorts by xtradernet | sma | v4 strategy | No trades on this market | ||
| buy down and sell high trend 200 sma and ma cross by willi130503 | sma | v4 strategy | No trades on this market | ||
| Mayer Multiple Strategy by xtradernet | sma | v4 strategy | No trades on this market | ||
| Moving Average Cross Strategy early Closing by Geduldtrader | sma | v4 strategy | +73.8% | 20 | 151.5% |
| MFI Simple Strategy by OztheWoz | sma | v5 strategy | −0.2% | 28 | 3.2% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 14 ms | Yes 1,000 bars in 37 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. 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/// © adolgov//@version=4strategy("Multiple %% profit exits example", overlay=false, default_qty_value = 100)longCondition = crossover(sma(close, 14), sma(close, 28))if (longCondition) strategy.entry("My Long Entry Id", strategy.long)shortCondition = crossunder(sma(close, 14), sma(close, 28))if (shortCondition) strategy.entry("My Short Entry Id", strategy.short)percentAsPoints(pcnt) => strategy.position_size != 0 ? round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)lossPnt = percentAsPoints(2)strategy.exit("x1", qty_percent = 25, profit = percentAsPoints(1), loss = lossPnt)strategy.exit("x2", qty_percent = 25, profit = percentAsPoints(2), loss = lossPnt)strategy.exit("x3", qty_percent = 25, profit = percentAsPoints(3), loss = lossPnt)strategy.exit("x4", profit = percentAsPoints(4), loss = lossPnt)profitPercent(price) => posSign = strategy.position_size > 0 ? 1 : strategy.position_size < 0 ? -1 : 0 (price - strategy.position_avg_price) / strategy.position_avg_price * posSign * 100p1 = plot(profitPercent(high), style=plot.style_linebr, title = "open profit % upper bound")p2 = plot(profitPercent(low), style=plot.style_linebr, title = "open profit % lower bound")fill(p1, p2, color = color.red)