Pine Script v4 · Strategy
simple but effective
A Pine Script v4 strategy built on Crossover or SMA (high, v1high, open, v2open) and Crossunder or SMA (low, v1low, open, v2open). 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. 3 settings; defaults include V1low 3, V1high 3 and V2open 9.
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 simple but effective repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 16 of 16 trades.
- How did simple but effective do on BTCUSDT 1D with default settings?
- −16.81%
- From 26 Jan 2024 to 21 Oct 2026, over 61 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can simple but effective 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 simple but effective use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does simple but effective run in Zeal Terminal?
- Yes
- It compiles in 19 ms and runs 1,000 bars in 45 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −16.81%
- −$16,805.40
- Buy and hold
- +102.5%
- same period
- Closed trades
- 61
- 31 won · 30 lost
- Profitable
- 50.8%
- of closed trades
- Profit factor
- 0.90
- gross profit ÷ gross loss
- Max drawdown
- 59.78%
- −$78,681.10
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long 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
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
3 settings have no label
In the settings dialog v1low (line 5), v1high (line 6), v2open (line 7) show an empty name. The labels on this page come from the variable names.
-
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 sma → ta.sma, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
VerifiedSame 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 8: sma → ta.sma
- Line 9: sma → ta.sma
- Line 10: sma → ta.sma
- Line 11: crossover → ta.crossover
- Line 11: sma → ta.sma
4 more edits
- Line 11: sma → ta.sma
- Line 14: crossunder → ta.crossunder
- Line 14: sma → ta.sma
- Line 14: sma → ta.sma
⋯// © tucomprend-//@version=4+//@version=5strategy("simple but effective", overlay=true)⋯v2open = input(9, minval=1)-plot (sma(open, v2open))+plot (ta.sma(open, v2open))-plot (sma(high, v1high))+plot (ta.sma(high, v1high))-plot (sma(low, v1low))+plot (ta.sma(low, v1low))-longCondition = crossover(sma(high, v1high), sma(open, v2open))+longCondition = ta.crossover(ta.sma(high, v1high), ta.sma(open, v2open))if (longCondition) strategy.entry("My Long Entry Id", strategy.long)-shortCondition = crossunder(sma(low, v1low), sma(open, v2open))+shortCondition = ta.crossunder(ta.sma(low, v1low), ta.sma(open, v2open))if (shortCondition)⋯Same 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 7: input() → input.int()
⋯strategy("simple but effective", overlay=true)-v1low = input(3, minval=1)+v1low = input.int(3, minval=1)-v1high = input(3, minval=1)+v1high = input.int(3, minval=1)-v2open = input(9, minval=1)+v2open = input.int(9, minval=1)plot (ta.sma(open, v2open))⋯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: 61 before, 60 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.
⋯// © tucomprend-//@version=5+//@version=6strategy("simple but effective", overlay=true)⋯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 |
|---|---|---|---|
| V1low (no label in the script) | 3 | int · min 1 | shortCondition plot |
| V1high (no label in the script) | 3 | int · min 1 | longCondition plot |
| V2open (no label in the script) | 9 | int · min 1 | longCondition shortCondition plot |
What it calculates
- Crossover / SMA (
crossover,ta.crossoverin v5)sma(high, v1high), sma(open, v2open)longCondition · line 11 - Crossunder / SMA (
crossunder,ta.crossunderin v5)sma(low, v1low), sma(open, v2open)shortCondition · line 14
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 | 13 |
| Open My Short Entry Id short | (shortCondition) | On | 16 |
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 | −16.8% | +102.5% | 61 | 51% | 0.90 | 59.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +12.9% | +5.5% | 67 | 57% | 1.33 | 16.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −3.4% | +9.8% | 61 | 48% | 0.65 | 4.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.2% | +8.4% | 65 | 63% | 1.12 | 0.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.1% | +16.7% | 63 | 51% | 0.82 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 70 | 63% | 1.50 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −1.0% | +148.3% | 71 | 46% | 0.45 | 1.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.2% | +17.1% | 66 | 64% | 1.49 | 0.1% | 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 | 21 | 57% | $38,652.20 |
| Sideways market | 25 | 48% | −$9,081.18 |
| Falling market | 15 | 47% | −$46,376.50 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
64.1%
The 95th percentile of the worst drawdown when the same 61 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 37.4% to 64.1%; the tick is what actually happened, 56.9%. Order luck alone moves it this much.
All 61 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 5 Feb 2024 42,582.90 | 24 Mar 2024 63,990.00 | 48 | −$21,407.10 |
| long | 24 Mar 2024 63,990.00 | 2 Apr 2024 69,649.80 | 9 | $5,659.79 |
| short | 2 Apr 2024 69,649.80 | 7 Apr 2024 68,896.00 | 5 | $753.81 |
| long | 7 Apr 2024 68,896.00 | 26 Apr 2024 64,498.30 | 19 | −$4,397.67 |
| short | 26 Apr 2024 64,498.30 | 5 May 2024 63,892.00 | 9 | $606.30 |
| long | 5 May 2024 63,892.00 | 9 May 2024 61,193.00 | 4 | −$2,699.00 |
| short | 9 May 2024 61,193.00 | 15 May 2024 61,577.50 | 6 | −$384.46 |
| long | 15 May 2024 61,577.50 | 25 May 2024 68,550.00 | 10 | $6,972.50 |
| short | 25 May 2024 68,550.00 | 1 Jul 2024 62,772.00 | 37 | $5,777.98 |
| long | 1 Jul 2024 62,772.00 | 4 Jul 2024 60,208.60 | 3 | −$2,563.44 |
| short | 4 Jul 2024 60,208.60 | 11 Jul 2024 57,725.80 | 7 | $2,482.72 |
| long | 11 Jul 2024 57,725.80 | 25 Jul 2024 65,376.00 | 14 | $7,650.16 |
| short | 25 Jul 2024 65,376.00 | 10 Aug 2024 60,838.00 | 16 | $4,538.02 |
| long | 10 Aug 2024 60,838.00 | 14 Aug 2024 60,587.20 | 4 | −$250.83 |
| short | 14 Aug 2024 60,587.20 | 5 Sep 2024 57,970.90 | 22 | $2,616.26 |
| long | 5 Sep 2024 57,970.90 | 18 Sep 2024 60,314.00 | 13 | $2,343.09 |
| short | 18 Sep 2024 60,314.00 | 8 Oct 2024 62,224.00 | 20 | −$1,910.02 |
| long | 8 Oct 2024 62,224.00 | 24 Oct 2024 66,668.60 | 16 | $4,444.64 |
| short | 24 Oct 2024 66,668.60 | 7 Nov 2024 75,572.00 | 14 | −$8,903.34 |
| long | 7 Nov 2024 75,572.00 | 27 Nov 2024 91,965.20 | 20 | $16,393.20 |
| short | 27 Nov 2024 91,965.20 | 27 Dec 2024 95,791.60 | 30 | −$3,826.44 |
| long | 27 Dec 2024 95,791.60 | 9 Jan 2025 95,060.60 | 13 | −$730.99 |
| short | 9 Jan 2025 95,060.60 | 15 Jan 2025 96,560.90 | 6 | −$1,500.24 |
| long | 15 Jan 2025 96,560.90 | 22 Jan 2025 106,144.00 | 7 | $9,582.97 |
| short | 22 Jan 2025 106,144.00 | 12 Feb 2025 95,778.20 | 21 | $10,365.60 |
| long | 12 Feb 2025 95,778.20 | 29 Mar 2025 84,424.40 | 45 | −$11,353.80 |
| short | 29 Mar 2025 84,424.40 | 3 Apr 2025 82,516.30 | 5 | $1,908.10 |
| long | 3 Apr 2025 82,516.30 | 21 Apr 2025 85,179.20 | 18 | $2,662.96 |
| short | 21 Apr 2025 85,179.20 | 6 Jun 2025 101,509.00 | 46 | −$16,329.40 |
| long | 6 Jun 2025 101,509.00 | 14 Jun 2025 106,067.00 | 8 | $4,557.90 |
| short | 14 Jun 2025 106,067.00 | 17 Jun 2025 106,795.00 | 3 | −$727.94 |
| long | 17 Jun 2025 106,795.00 | 3 Jul 2025 108,850.00 | 16 | $2,055.06 |
| short | 3 Jul 2025 108,850.00 | 7 Aug 2025 114,992.00 | 35 | −$6,142.68 |
| long | 7 Aug 2025 114,992.00 | 16 Aug 2025 117,342.00 | 9 | $2,349.77 |
| short | 16 Aug 2025 117,342.00 | 24 Aug 2025 115,438.00 | 8 | $1,903.98 |
| long | 24 Aug 2025 115,438.00 | 10 Sep 2025 111,546.00 | 17 | −$3,891.68 |
| short | 10 Sep 2025 111,546.00 | 30 Sep 2025 114,312.00 | 20 | −$2,765.59 |
| long | 30 Sep 2025 114,312.00 | 10 Oct 2025 121,662.00 | 10 | $7,350.44 |
| short | 10 Oct 2025 121,662.00 | 22 Oct 2025 108,298.00 | 12 | $13,364.80 |
| long | 22 Oct 2025 108,298.00 | 31 Oct 2025 108,323.00 | 9 | $25.21 |
| short | 31 Oct 2025 108,323.00 | 11 Nov 2025 106,011.00 | 11 | $2,311.74 |
| long | 11 Nov 2025 106,011.00 | 2 Dec 2025 86,286.00 | 21 | −$19,725.10 |
| short | 2 Dec 2025 86,286.00 | 20 Dec 2025 88,136.90 | 18 | −$1,850.94 |
| long | 20 Dec 2025 88,136.90 | 24 Dec 2025 87,486.00 | 4 | −$650.95 |
| short | 24 Dec 2025 87,486.00 | 14 Jan 2026 95,414.00 | 21 | −$7,927.99 |
| long | 14 Jan 2026 95,414.00 | 20 Jan 2026 92,631.00 | 6 | −$2,783.00 |
| short | 20 Jan 2026 92,631.00 | 29 Jan 2026 89,300.00 | 9 | $3,330.99 |
| long | 29 Jan 2026 89,300.00 | 9 Mar 2026 65,971.20 | 39 | −$23,328.80 |
| short | 9 Mar 2026 65,971.20 | 26 Mar 2026 71,336.50 | 17 | −$5,365.33 |
| long | 26 Mar 2026 71,336.50 | 21 Apr 2026 75,841.00 | 26 | $4,504.44 |
| short | 21 Apr 2026 75,841.00 | 24 May 2026 76,752.00 | 33 | −$911.03 |
| long | 24 May 2026 76,752.00 | 19 Jun 2026 62,958.00 | 26 | −$13,794.00 |
| short | 19 Jun 2026 62,958.00 | 23 Jun 2026 64,020.00 | 4 | −$1,062.00 |
| long | 23 Jun 2026 64,020.00 | 9 Jul 2026 62,290.00 | 16 | −$1,730.00 |
| short | 9 Jul 2026 62,290.00 | 1 Aug 2026 62,887.90 | 23 | −$597.87 |
| long | 1 Aug 2026 62,887.90 | 12 Aug 2026 63,600.00 | 11 | $712.13 |
| short | 12 Aug 2026 63,600.00 | 18 Aug 2026 64,532.10 | 6 | −$932.10 |
| long | 18 Aug 2026 64,532.10 | 30 Aug 2026 78,230.00 | 12 | $13,697.90 |
| short | 30 Aug 2026 78,230.00 | 16 Sep 2026 75,644.50 | 17 | $2,585.52 |
| long | 16 Sep 2026 75,644.50 | 28 Sep 2026 84,472.00 | 12 | $8,827.53 |
| short | 28 Sep 2026 84,472.00 | 14 Oct 2026 83,169.00 | 16 | $1,303.00 |
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 |
|---|---|---|---|---|---|
| simple but effective this page | — | v4 strategy | −16.8% | 61 | 59.8% |
| 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 19 ms | Yes 1,000 bars in 45 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/// © tucomprend//@version=4strategy("simple but effective", overlay=true)v1low = input(3, minval=1)v1high = input(3, minval=1)v2open = input(9, minval=1)plot (sma(open, v2open))plot (sma(high, v1high))plot (sma(low, v1low))longCondition = crossover(sma(high, v1high), sma(open, v2open))if (longCondition) strategy.entry("My Long Entry Id", strategy.long)shortCondition = crossunder(sma(low, v1low), sma(open, v2open))if (shortCondition) strategy.entry("My Short Entry Id", strategy.short)