Pine Script v5 · Strategy
Vortex Cross w-MA Confirmation
A Pine Script v5 strategy built on ATR (1) and SMA (close, 9). 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. 6 settings; defaults include Vortex Length 14, MA Length 9 and Source close.
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 Vortex Cross w-MA Confirmation repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 17 of 17 trades.
- How did Vortex Cross w-MA Confirmation do on BTCUSDT 1D with default settings?
- +2.41%
- From 26 Jan 2024 to 21 Oct 2026, over 52 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Vortex Cross w-MA Confirmation 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: 52 before, 47 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 Vortex Cross w-MA Confirmation use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Vortex Cross w-MA Confirmation run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 36 ms, in the browser.
BTCUSDT · 1D · default settings
- VI +
- VI -
- MA
- Smoothing Line
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +2.41%
- $24,125.70
- Buy and hold
- +102.5%
- same period
- Closed trades
- 52
- 21 won · 31 lost
- Profitable
- 40.4%
- of closed trades
- Profit factor
- 1.21
- gross profit ÷ gross loss
- Max drawdown
- 4.71%
- −$47,054.60
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
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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Vortex Length | 14 | int · min 2 | VMP VMM STR |
| MA Length | 9 | int · min 1 | out |
| Source | close | source | out |
| Offset | 0 | int · min -500 · max 500 | MA Smoothing Line |
| Smoothing | |||
| Method | SMA | string · options ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] | smoothingLine |
| Length | 5 | int · min 1 · max 100 | smoothingLine |
What it calculates
- ATR1
STR · line 9 - SMASource (close), MA Length (9)
out · line 17
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 Long long | longCondition | On | 36 |
| Open Short short | shortCondition | 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 | +2.4% | +102.5% | 52 | 40% | 1.21 | 4.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.8% | +5.5% | 53 | 32% | 1.20 | 1.1% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.2% | +9.8% | 61 | 21% | 0.73 | 0.3% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 69 | 32% | 1.31 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 52 | 38% | 1.29 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 53 | 30% | 1.75 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 56 | 39% | 1.28 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 65 | 35% | 1.25 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 15 | 33% | −$35,177.30 |
| Sideways market | 22 | 55% | $40,044.50 |
| Falling market | 15 | 27% | $19,258.50 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
6.5%
The 95th percentile of the worst drawdown when the same 52 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 3.2% to 6.5%; the tick is what actually happened, 4.1%. Order luck alone moves it this much.
All 52 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 21 Mar 2024 67,840.50 | 30 Mar 2024 69,850.50 | 9 | −$2,010.02 |
| long | 30 Mar 2024 69,850.50 | 13 Apr 2024 67,116.50 | 14 | −$2,734.01 |
| short | 13 Apr 2024 67,116.50 | 6 Jun 2024 71,108.00 | 54 | −$3,991.48 |
| long | 6 Jun 2024 71,108.00 | 12 Jun 2024 67,314.20 | 6 | −$3,793.77 |
| short | 12 Jun 2024 67,314.20 | 17 Jul 2024 65,044.00 | 35 | $2,270.23 |
| long | 17 Jul 2024 65,044.00 | 2 Aug 2024 65,354.00 | 16 | $310.02 |
| short | 2 Aug 2024 65,354.00 | 14 Sep 2024 60,498.00 | 43 | $4,856.03 |
| long | 14 Sep 2024 60,498.00 | 4 Oct 2024 60,752.70 | 20 | $254.73 |
| short | 4 Oct 2024 60,752.70 | 15 Oct 2024 66,084.00 | 11 | −$5,331.28 |
| long | 15 Oct 2024 66,084.00 | 4 Nov 2024 68,776.00 | 20 | $2,691.99 |
| short | 4 Nov 2024 68,776.00 | 4 Jan 2025 98,174.20 | 61 | −$29,398.20 |
| long | 4 Jan 2025 98,174.20 | 9 Jan 2025 95,060.60 | 5 | −$3,113.56 |
| short | 9 Jan 2025 95,060.60 | 15 Jan 2025 96,560.90 | 6 | −$1,500.24 |
| long | 15 Jan 2025 96,560.90 | 2 Feb 2025 100,636.00 | 18 | $4,074.81 |
| short | 2 Feb 2025 100,636.00 | 21 Feb 2025 98,305.00 | 19 | $2,330.65 |
| long | 21 Feb 2025 98,305.00 | 22 Feb 2025 96,182.00 | 1 | −$2,123.02 |
| short | 22 Feb 2025 96,182.00 | 24 Mar 2025 86,082.50 | 30 | $10,099.50 |
| long | 24 Mar 2025 86,082.50 | 30 Mar 2025 82,648.50 | 6 | −$3,433.97 |
| short | 30 Mar 2025 82,648.50 | 13 Apr 2025 85,276.90 | 14 | −$2,628.38 |
| long | 13 Apr 2025 85,276.90 | 2 Jun 2025 105,643.00 | 50 | $20,366.00 |
| short | 2 Jun 2025 105,643.00 | 11 Jun 2025 110,274.00 | 9 | −$4,631.46 |
| long | 11 Jun 2025 110,274.00 | 14 Jun 2025 106,067.00 | 3 | −$4,207.80 |
| short | 14 Jun 2025 106,067.00 | 27 Jun 2025 106,947.00 | 13 | −$880.47 |
| long | 27 Jun 2025 106,947.00 | 26 Jul 2025 117,614.00 | 29 | $10,667.30 |
| short | 26 Jul 2025 117,614.00 | 9 Aug 2025 116,675.00 | 14 | $939.57 |
| long | 9 Aug 2025 116,675.00 | 21 Aug 2025 114,271.00 | 12 | −$2,403.51 |
| short | 21 Aug 2025 114,271.00 | 9 Sep 2025 112,065.00 | 19 | $2,206.00 |
| long | 9 Sep 2025 112,065.00 | 25 Sep 2025 113,307.00 | 16 | $1,241.78 |
| short | 25 Sep 2025 113,307.00 | 2 Oct 2025 118,595.00 | 7 | −$5,287.98 |
| long | 2 Oct 2025 118,595.00 | 15 Oct 2025 113,028.00 | 13 | −$5,566.86 |
| short | 15 Oct 2025 113,028.00 | 27 Oct 2025 114,559.00 | 12 | −$1,531.28 |
| long | 27 Oct 2025 114,559.00 | 30 Oct 2025 110,021.00 | 3 | −$4,538.11 |
| short | 30 Oct 2025 110,021.00 | 4 Dec 2025 93,429.90 | 35 | $16,591.40 |
| long | 4 Dec 2025 93,429.90 | 13 Dec 2025 90,268.40 | 9 | −$3,161.52 |
| short | 13 Dec 2025 90,268.40 | 27 Feb 2026 67,485.20 | 76 | $22,783.20 |
| long | 27 Feb 2026 67,485.20 | 28 Feb 2026 65,872.10 | 1 | −$1,613.10 |
| short | 28 Feb 2026 65,872.10 | 5 Mar 2026 72,666.80 | 5 | −$6,794.68 |
| long | 5 Mar 2026 72,666.80 | 8 Mar 2026 67,262.90 | 3 | −$5,403.86 |
| short | 8 Mar 2026 67,262.90 | 10 Mar 2026 68,432.20 | 2 | −$1,169.25 |
| long | 10 Mar 2026 68,432.20 | 20 Mar 2026 69,930.00 | 10 | $1,497.85 |
| short | 20 Mar 2026 69,930.00 | 8 Apr 2026 71,924.20 | 19 | −$1,994.21 |
| long | 8 Apr 2026 71,924.20 | 17 May 2026 78,148.10 | 39 | $6,223.83 |
| short | 17 May 2026 78,148.10 | 8 Jul 2026 63,364.00 | 52 | $14,784.10 |
| long | 8 Jul 2026 63,364.00 | 26 Jul 2026 64,375.00 | 18 | $1,011.01 |
| short | 26 Jul 2026 64,375.00 | 27 Jul 2026 65,400.00 | 1 | −$1,024.99 |
| long | 27 Jul 2026 65,400.00 | 29 Jul 2026 63,915.00 | 2 | −$1,485.00 |
| short | 29 Jul 2026 63,915.00 | 8 Aug 2026 64,923.20 | 10 | −$1,008.20 |
| long | 8 Aug 2026 64,923.20 | 11 Aug 2026 63,970.00 | 3 | −$953.19 |
| short | 11 Aug 2026 63,970.00 | 18 Aug 2026 64,532.10 | 7 | −$562.10 |
| long | 18 Aug 2026 64,532.10 | 9 Sep 2026 78,455.80 | 22 | $13,923.70 |
| short | 9 Sep 2026 78,455.80 | 20 Sep 2026 81,250.00 | 11 | −$2,794.19 |
| long | 20 Sep 2026 81,250.00 | 8 Oct 2026 83,321.80 | 18 | $2,071.82 |
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 |
|---|---|---|---|---|---|
| Vortex Cross w-MA Confirmation this page | — | v5 strategy | +2.4% | 52 | 4.7% |
| I11L - Better Buy Low Volatility or High Volatility- by I11L | atr sma | v5 strategy | +19.2% | 83 | 37.4% |
| Configurable Multi MA Crossover Voting System by levieux | sma atr | v5 strategy | +28.5% | 5 | 39.4% |
| Swing Trend Strategy by Inkedlau | sma atr | v5 strategy | +11.2% | 5 | 16.2% |
| SSL Backtester With ATR SL TP and Money Management by JBTrippin | sma atr | v4 strategy | +8.5% | 55 | 3.9% |
| Baseline Cross Qualifier Volatility Strategy with HMA Trend Bias by sevencampbell | sma atr | v5 strategy | −1.4% | 214 | 1.8% |
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.
- 1 setting uses the untyped input() (line 15). 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 52 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 15: input() → input.source()
⋯len = input.int(9, minval=1, title="MA Length")-src = input(close, title="Source")+src = input.source(close, title="Source")offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)⋯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: 52 before, 47 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.
⋯// © DraftVenture-//@version=5+//@version=6strategy("Vortex + Moving Average Strategy", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 36 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/// © DraftVenture//@version=5strategy("Vortex + Moving Average Strategy", overlay=true)//Vortex settingsperiod_ = input.int(14, title="Vortex Length", minval=2)VMP = math.sum( math.abs( high - low[1]), period_ )VMM = math.sum( math.abs( low - high[1]), period_ )STR = math.sum( ta.atr(1), period_ )VIP = VMP / STRVIM = VMM / STRplot(VIP, title="VI +", color=color.white)plot(VIM, title="VI -", color=color.white)len = input.int(9, minval=1, title="MA Length")src = input(close, title="Source")offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)out = ta.sma(src, len)plot(out, color=color.blue, title="MA", offset=offset)ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length)typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")smoothingLine = ma(out, smoothingLength, typeMA)plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)// Determine long and short conditionslongCondition = ta.crossover(VIP, VIM) and close > smoothingLineshortCondition = ta.crossunder(VIP, VIM) and close < smoothingLinecrossCondition = ta.crossunder(VIP, VIM) or ta.crossunder(VIM, VIP)// Strategy entry and exit logicif longCondition strategy.entry("Long", strategy.long)if shortCondition strategy.entry("Short", strategy.short)bgcolor(crossCondition ? color.new(color.white, 80) : na)// Strategy by KP