Pine Script v4 · Strategy
ATR with EOM and VORTEX
A Pine Script v4 strategy built on ATR (10), EMA (atrvalue, 5) and SMA or Change (10). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.01% commission. 4 settings; defaults include ATR lenght 10, EMA atr length 5 and Length EOM 10.
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 ATR with EOM and VORTEX repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
- How did ATR with EOM and VORTEX do on BTCUSDT 1D with default settings?
- +66.16%
- From 26 Jan 2024 to 21 Oct 2026, over 22 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can ATR with EOM and VORTEX 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 ATR with EOM and VORTEX use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does ATR with EOM and VORTEX run in Zeal Terminal?
- Yes
- It compiles in 7 ms and runs 1,000 bars in 32 ms, in the browser.
BTCUSDT · 1D · default settings
- ATR
- EMA
- SMA
- ATR
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +66.16%
- $661.59
- Buy and hold
- +102.5%
- same period
- Closed trades
- 22
- 7 won · 15 lost
- Profitable
- 31.8%
- of closed trades
- Profit factor
- 1.62
- gross profit ÷ gross loss
- Max drawdown
- 29.93%
- −$675.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.
-
Likely bug
atr(1) ignores the settings line 21
Line 21 hard-codes 1 where line 7 uses “ATR lenght”. Changing those settings moves one band but not this one.
atr(1)atr(atr_lenght) -
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
3 settings have no label
In the settings dialog atr_lenght (line 6), ema_atr_length (line 9), lengthEOM (line 13) 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.
-
Note
Uses an argument v6 removed
when = on line 28, 30. The upgraded version below moves each call inside an if block.
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 atr → ta.atr, ema → ta.ema, sma → ta.sma, change → ta.change, sum → math.sum, abs → math.abs.
- 2 strategy calls use the when = argument (line 28, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 22 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: atr → ta.atr
- Line 10: ema → ta.ema
- Line 15: sma → ta.sma
- Line 15: change → ta.change
- Line 19: sum → math.sum
6 more edits
- Line 19: abs → math.abs
- Line 20: sum → math.sum
- Line 20: abs → math.abs
- Line 21: sum → math.sum
- Line 21: atr → ta.atr
- Line 28: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy("atr+eom+vortex strat", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.01 )⋯atr_lenght=input(10)-atrvalue = atr(atr_lenght)+atrvalue = ta.atr(atr_lenght)//plot(atrvalue)ema_atr_length=input(5)-ema_atr = ema(atrvalue,ema_atr_length)+ema_atr = ta.ema(atrvalue,ema_atr_length)//plot(ema_atr,color=color.white)⋯div = 10//input(10000, title="Divisor", minval=1)-eom = sma(div * change(hl2) * (high - low) / volume, lengthEOM)+eom = ta.sma(div * ta.change(hl2) * (high - low) / volume, lengthEOM)// + - 0 long/short⋯period_ = input(10, title="Length", minval=2)-VMP = sum( abs( high - low[1]), period_ )+VMP = math.sum( math.abs( high - low[1]), period_ )-VMM = sum( abs( low - high[1]), period_ )+VMM = math.sum( math.abs( low - high[1]), period_ )-STR = sum( atr(1), period_ )+STR = math.sum( ta.atr(1), period_ )VIP = VMP / STR⋯short=atrvalue < ema_atr and eom < 0 and avg_vortex<1 -strategy.entry("long",1,when=long)+strategy.entry("long",strategy.long,when=long)//strategy.entry("short",0,when=short)⋯Same 22 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 9: input() → input.int()
- Line 13: input() → input.int()
- Line 18: input() → input.int()
- Line 28: when = long → if block
- Line 30: when = short → if block
⋯//atr and ema-atr_lenght=input(10)+atr_lenght=input.int(10)atrvalue = ta.atr(atr_lenght)//plot(atrvalue)-ema_atr_length=input(5)+ema_atr_length=input.int(5)ema_atr = ta.ema(atrvalue,ema_atr_length)⋯//EOM and ema-lengthEOM = input(10, minval=1)+lengthEOM = input.int(10, minval=1)div = 10//input(10000, title="Divisor", minval=1)⋯//VORTEX-period_ = input(10, title="Length", minval=2)+period_ = input.int(10, title="Length", minval=2)VMP = math.sum( math.abs( high - low[1]), period_ )⋯short=atrvalue < ema_atr and eom < 0 and avg_vortex<1 -strategy.entry("long",strategy.long,when=long)+if long+ strategy.entry("long",strategy.long)//strategy.entry("short",0,when=short)-strategy.close("long",when=short)+if short+ strategy.close("long")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: 22 before, 26 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.
⋯// © SoftKill21-//@version=5+//@version=6strategy("atr+eom+vortex strat", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.01 )⋯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 |
|---|---|---|---|
| ATR lenght (no label in the script) | 10 | int | atrvalue |
| EMA atr length (no label in the script) | 5 | int | ema_atr |
| Length EOM (no label in the script) | 10 | int · min 1 | eom |
| Length | 10 | int · min 2 | VMP VMM STR |
What it calculates
- ATR (
atr,ta.atrin v5)ATR lenght (10)atrvalue · line 7 - EMA (
ema,ta.emain v5)atrvalue, EMA atr length (5)ema_atr · line 10 - SMA / Change (
sma,ta.smain v5)div * change(hl2) * (high - low) / volume, Length EOM (10)eom · line 15 - ATR (
atr,ta.atrin v5)1STR · line 21
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 | longatrvalue > ema_atr and eom > 0 and avg_vortex>1 | On | 28 |
| Close long | shortatrvalue < ema_atr and eom < 0 and avg_vortex<1 | On | 30 |
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 | +66.2% | +102.5% | 22 | 32% | 1.62 | 29.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −14.1% | +5.5% | 19 | 26% | 0.60 | 27.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +21.9% | +9.8% | 14 | 57% | 1.15 | 57.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.6% | +8.4% | 21 | 29% | 1.02 | 16.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.1% | +16.7% | 23 | 43% | 1.00 | 54.2% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +25.2% | +21.5% | 20 | 40% | 1.70 | 23.3% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +154.2% | +148.3% | 16 | 50% | 4.59 | 15.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +9.2% | +17.1% | 19 | 53% | 1.50 | 7.6% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (ATR lenght 7, EMA atr length 3) made +141.3% before 26 Dec 2025 and −18.8% after it, worse than the defaults' −10.4% after. Tuning on the past did not carry forward. 100% of the 48 combinations made money in-sample and 8% out-of-sample.
| EMA atr length ↓ · ATR lenght → | 5 | 6 | 7 | 9 | 10 | 12 | 14 | 17 |
|---|---|---|---|---|---|---|---|---|
| 3 | +94% | +106% | +141% | +96% | +100% | +90% | +80% | +78% |
| 4 | +126% | +93% | +93% | +93% | +87% | +81% | +92% | +63% |
| 5 | +84% | +84% | +67% | +75% | +77% | +82% | +68% | +56% |
| 6 | +74% | +73% | +68% | +93% | +86% | +61% | +69% | +60% |
| 7 | +67% | +64% | +68% | +66% | +66% | +69% | +65% | +58% |
| 9 | +65% | +68% | +66% | +97% | +75% | +65% | +60% | +48% |
| EMA atr length ↓ · ATR lenght → | 5 | 6 | 7 | 9 | 10 | 12 | 14 | 17 |
|---|---|---|---|---|---|---|---|---|
| 3 | +9% | −13% | −19% | −23% | −23% | −22% | −23% | −26% |
| 4 | +3% | −18% | −18% | −11% | −11% | −12% | −6% | −23% |
| 5 | +4% | −7% | −3% | −1% | −10% | −15% | −16% | −22% |
| 6 | +4% | −3% | −1% | −0% | −13% | −13% | −24% | −22% |
| 7 | −3% | −1% | −1% | −8% | −12% | −14% | −23% | −22% |
| 9 | −1% | −0% | −8% | −14% | −12% | −20% | −22% | −21% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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 | 6 | 50% | $17.70 |
| Sideways market | 9 | 44% | $940.45 |
| Falling market | 7 | 0% | −$296.56 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
36.7%
The 95th percentile of the worst drawdown when the same 22 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 17.2% to 36.7%; the tick is what actually happened, 28.0%. Order luck alone moves it this much.
All 22 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 9 Feb 2024 45,288.70 | 24 Mar 2024 63,990.00 | 44 | $412.65 |
| long | 26 Mar 2024 69,880.00 | 6 Apr 2024 67,820.60 | 11 | −$41.91 |
| long | 5 May 2024 63,892.00 | 20 Jun 2024 64,974.40 | 46 | $22.94 |
| long | 18 Jul 2024 64,088.00 | 12 Aug 2024 58,712.60 | 25 | −$117.15 |
| long | 16 Aug 2024 57,541.10 | 21 Aug 2024 59,013.80 | 5 | $32.41 |
| long | 20 Sep 2024 62,948.00 | 8 Oct 2024 62,224.00 | 18 | −$15.31 |
| long | 12 Oct 2024 62,540.00 | 3 Dec 2024 95,840.60 | 52 | $688.42 |
| long | 8 Dec 2024 99,832.00 | 24 Dec 2024 94,881.50 | 16 | −$98.66 |
| long | 11 Jan 2025 94,726.10 | 29 Jan 2025 101,336.00 | 18 | $131.01 |
| long | 7 Mar 2025 89,931.90 | 19 Mar 2025 82,715.00 | 12 | −$162.02 |
| long | 24 Apr 2025 93,691.10 | 4 Aug 2025 114,209.00 | 102 | $405.21 |
| long | 16 Aug 2025 117,342.00 | 3 Sep 2025 111,240.00 | 18 | −$117.83 |
| long | 3 Oct 2025 120,529.00 | 24 Oct 2025 110,078.00 | 21 | −$185.93 |
| long | 4 Dec 2025 93,429.90 | 8 Dec 2025 90,395.30 | 4 | −$63.84 |
| long | 12 Dec 2025 92,513.40 | 16 Dec 2025 86,432.10 | 4 | −$124.59 |
| long | 9 Jan 2026 91,100.00 | 28 Jan 2026 89,250.00 | 19 | −$36.20 |
| long | 27 Feb 2026 67,485.20 | 9 Mar 2026 65,971.20 | 10 | −$39.13 |
| long | 20 Mar 2026 69,930.00 | 22 Mar 2026 68,918.10 | 2 | −$24.79 |
| long | 18 Apr 2026 77,072.00 | 19 May 2026 77,001.90 | 31 | −$1.85 |
| long | 25 Jul 2026 64,140.00 | 29 Jul 2026 63,915.00 | 4 | −$6.17 |
| long | 5 Sep 2026 79,660.80 | 15 Sep 2026 78,189.20 | 10 | −$30.94 |
| long | 20 Sep 2026 81,250.00 | 21 Oct 2026 83,028.10 | 31 | $35.26 |
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 |
|---|---|---|---|---|---|
| ATR with EOM and VORTEX this page | — | v4 strategy | +66.2% | 22 | 29.9% |
| cATRpillar Strategy by Obi-wanClintobe | atr sma ema | v4 strategy | +1.02827e+24% | 27 | 88,097.2% |
| Optimized Zhaocaijinbao strategy by fzj20020403 | sma ema atr | v5 strategy | +15.6% | 12 | 9.8% |
| EMA & Supertrend by bhavikmota | ema sma atr | v4 strategy | +2,123.6% | 13 | 980.9% |
| Koala System EURUSD 15min by SoftKill21 | sma ema atr | v4 strategy | No trades on this market | ||
| Buy&Sell Bullish Engulfing - The Quant Science by thequantscience | sma ema atr | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 7 ms | With a workaround 1,000 bars in 32 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 28) so the engine trades the way the script says.
“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/// © SoftKill21//@version=4strategy("atr+eom+vortex strat", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.01 )//atr and emaatr_lenght=input(10)atrvalue = atr(atr_lenght)//plot(atrvalue)ema_atr_length=input(5)ema_atr = ema(atrvalue,ema_atr_length)//plot(ema_atr,color=color.white)//EOM and emalengthEOM = input(10, minval=1)div = 10//input(10000, title="Divisor", minval=1)eom = sma(div * change(hl2) * (high - low) / volume, lengthEOM)// + - 0 long/short//VORTEXperiod_ = input(10, title="Length", minval=2)VMP = sum( abs( high - low[1]), period_ )VMM = sum( abs( low - high[1]), period_ )STR = sum( atr(1), period_ )VIP = VMP / STRVIM = VMM / STRavg_vortex=(VIP+VIM)/2//plot(avg_vortex)long= atrvalue > ema_atr and eom > 0 and avg_vortex>1 short=atrvalue < ema_atr and eom < 0 and avg_vortex<1 strategy.entry("long",1,when=long)//strategy.entry("short",0,when=short)strategy.close("long",when=short)