Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Simple Ema_ATR Strategy HulkTrading

A Pine Script v4 strategy built on EMA (close, 21) and ATR (14). It has 4 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 one contract and pays no commission. 1 setting; defaults include ATR Multiplier 2.

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 Ema_ATR Strategy HulkTrading repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Simple Ema_ATR Strategy HulkTrading do on BTCUSDT 1D with default settings?
+2.20%
From 26 Jan 2024 to 21 Oct 2026, over 14 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Simple Ema_ATR Strategy HulkTrading 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 Ema_ATR Strategy HulkTrading use a stop loss?
Yes
strategy.exit sets a stop on line 24, 26.
Does Simple Ema_ATR Strategy HulkTrading run in Zeal Terminal?
Yes
It compiles in 10 ms and runs 1,000 bars in 24 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • ATR
  • ATR
  • ATR
  • ATR
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (1)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$102,199$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+2.20%
$2,199.84
Buy and hold
+102.5%
same period
Closed trades
14
7 won · 7 lost
Profitable
50.0%
of closed trades
Profit factor
1.06
gross profit ÷ gross loss
Max drawdown
15.55%
−$15,913.80

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.

  • Note

    Uses an argument v6 removed

    when = on line 23, 25. 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 ema → ta.ema, abs → math.abs, atr → ta.atr.
  • 2 strategy calls use the when = argument (line 23, 25). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 14 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 4: //@version=4 → //@version=5
  • Line 7: ema → ta.ema
  • Line 8: ema → ta.ema
  • Line 14: abs → math.abs
  • Line 14: atr → ta.atr
  • Line 16: abs → math.abs
5 more edits
  • Line 16: atr → ta.atr
  • Line 18: atr → ta.atr
  • Line 19: atr → ta.atr
  • Line 20: atr → ta.atr
  • Line 21: atr → ta.atr
⋯// Simple EMA strategy, based on ema55+ema21 and ATR(Average True Range) and it enters a deal from ema55 when the other entry conditions are met-//@version=4+//@version=5strategy("Simple Ema_ATR Strategy HulkTrading", overlay=true)atr_multiplier = input(2, minval=1, title="ATR Multiplier") // ATR Multiplier. Recommended values between 1..4-emaFast=ema(close,21)+emaFast=ta.ema(close,21)-emaSlow=ema(close,55)+emaSlow=ta.ema(close,55)//Basically long and short conditions⋯// 3) Difference between emaFast and emaSlow must be greater than ATR(14) - for excluding flat-longCond = close < open and emaFast > emaSlow and abs(emaSlow-emaFast) > atr(14)  +longCond = close < open and emaFast > emaSlow and math.abs(emaSlow-emaFast) > ta.atr(14)  //For short conditions are opposite-shortCond = close > open and emaFast < emaSlow and abs(emaSlow-emaFast) > atr(14) +shortCond = close > open and emaFast < emaSlow and math.abs(emaSlow-emaFast) > ta.atr(14) //Stop levels and take profits, based on ATR multiplier-stop_level_long = strategy.position_avg_price - atr_multiplier*atr(14)+stop_level_long = strategy.position_avg_price - atr_multiplier*ta.atr(14)-take_level_long = strategy.position_avg_price + atr_multiplier*atr(14)+take_level_long = strategy.position_avg_price + atr_multiplier*ta.atr(14)-stop_level_short = strategy.position_avg_price + atr_multiplier*atr(14)+stop_level_short = strategy.position_avg_price + atr_multiplier*ta.atr(14)-take_level_short = strategy.position_avg_price - atr_multiplier*atr(14)+take_level_short = strategy.position_avg_price - atr_multiplier*ta.atr(14)//Entries and exits ⋯

Clean v5

VerifiedDownload the v5 script

Same 14 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 23: when = longCond → if block
  • Line 25: when = shortCond → if block
⋯strategy("Simple Ema_ATR Strategy HulkTrading", overlay=true)-atr_multiplier = input(2, minval=1, title="ATR Multiplier") // ATR Multiplier. Recommended values between 1..4+atr_multiplier = input.int(2, minval=1, title="ATR Multiplier") // ATR Multiplier. Recommended values between 1..4emaFast=ta.ema(close,21)⋯//Entries and exits -strategy.entry("Long", strategy.long, when=longCond, limit = emaSlow)+if longCond+    strategy.entry("Long", strategy.long, limit = emaSlow)strategy.exit("Stop Loss/TP","Long", stop=stop_level_long, limit = take_level_long)-strategy.entry("Short", strategy.short, when=shortCond, limit = emaSlow)+if shortCond+    strategy.entry("Short", strategy.short, limit = emaSlow)strategy.exit("Stop Loss/TP","Short", stop=stop_level_short, limit = take_level_short)

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: 14 before, 16 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.

⋯// Simple EMA strategy, based on ema55+ema21 and ATR(Average True Range) and it enters a deal from ema55 when the other entry conditions are met-//@version=5+//@version=6strategy("Simple Ema_ATR Strategy HulkTrading", overlay=true)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
ATR Multiplier2int · min 1stop_level_long take_level_long stop_level_short take_level_short

What it calculates

  • EMA (ema, ta.ema in v5)close, 21emaFast · line 7
  • EMA (ema, ta.ema in v5)close, 55emaSlow · line 8
  • ATR (atr, ta.atr in v5)14stop_level_long · line 18
  • ATR (atr, ta.atr in v5)14take_level_long · line 19
  • ATR (atr, ta.atr in v5)14stop_level_short · line 20
  • ATR (atr, ta.atr in v5)14take_level_short · 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.

closecloseprice datahigh · low · closehigh · low · closeprice dataatr_multiplierATR Multipliersetting · 2openopenprice dataemaFastEMA→ emaFastemaSlowEMA→ emaSlowstop_level_longATR→ stop_level_longtake_level_longATR→ take_level_longstop_level_shortATR→ stop_level_shorttake_level_shortATR→ take_level_shortlongCondlongCondconditionshortCondshortCondconditionentry:LongOpen Longstrategy.entryexit:Stop Loss/TPexit Stop Loss/TPstrategy.exitentry:ShortOpen Shortstrategy.entry

Order rules

OrderFires whenBy defaultLine
Open Long longlongCondclose < open and emaFast > emaSlow and abs(emaSlow-emaFast) > atr(14)On23
Exit Stop Loss/TP stop and limitevery barOn24
Open Short shortshortCondclose > open and emaFast < emaSlow and abs(emaSlow-emaFast) > atr(14)On25
Exit Stop Loss/TP stop and limitevery barOn26

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.

6/6trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+2.2%+102.5%1450%1.0615.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−1.7%+5.5%1338%0.835.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.4%+9.8%1242%0.811.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%1377%3.210.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%1258%1.170.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1080%5.150.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%933%0.900.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%1155%0.850.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 barsTradesWonP&L
Rising market580%$15,557.30
Sideways market633%−$9,149.10
Falling market333%−$4,208.32

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

23.6%

The 95th percentile of the worst drawdown when the same 14 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 10.4% to 23.6%; the tick is what actually happened, 14.7%. Order luck alone moves it this much.

0%27%
All 14 trades
SideEntryExitBarsP&L
long13 Apr 2024 62,931.101 May 2024 56,697.1018−$6,234.03
long11 Jun 2024 66,578.5024 Jun 2024 62,960.8013−$3,617.77
short15 Jul 2024 62,479.5019 Jul 2024 67,374.504−$4,895.03
long30 Dec 2024 92,333.806 Jan 2025 99,116.607$6,782.79
short2 Apr 2025 88,358.303 Apr 2025 81,420.201$6,938.04
long20 Jun 2025 102,617.0029 Jun 2025 108,143.009$5,526.21
long2 Aug 2025 112,265.007 Aug 2025 117,588.005$5,323.41
long19 Aug 2025 114,296.0029 Aug 2025 107,967.0010−$6,329.32
short5 Jan 2026 92,163.3014 Jan 2026 97,233.809−$5,070.44
short13 Mar 2026 73,729.7022 Mar 2026 67,860.709$5,869.08
short7 Apr 2026 70,964.1017 Apr 2026 75,971.0010−$5,006.96
long18 May 2026 76,522.1029 May 2026 72,545.4011−$3,976.69
short15 Jul 2026 65,556.7014 Aug 2026 62,825.0030$2,731.67
long15 Oct 2026 79,802.2021 Oct 2026 83,961.106$4,158.88

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Simple Ema_ATR Strategy HulkTrading this page—v4 strategy+2.2%1415.6%
Trend Reversal - Potential pressure by BardiaB2atr emav4 strategy+133,960.0%51,504.8%
Keltner Breakout Strategy by Zeal Terminalema atrv5 strategy+3.5%212.3%
[EKIN] ATR Exit Strategy by ekinbasarkomurema atrv5 strategy+781.7%302,960.8%
DEMA-EMA & VOLATILITY (VAMS) by Qorbanjfema atrv4 strategy+2,833,450.0%1915,721.0%
Super Z strategy - Thanks to Rafael Zioni by 03.freemanema atrv4 strategy−404,823.0%562,951,790.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 10 msYes 1,000 bars in 24 msNot measured
PineTSNo 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/// © TheHulkTrading// Simple EMA strategy, based on ema55+ema21 and ATR(Average True Range) and it enters a deal from ema55 when the other entry conditions are met//@version=4strategy("Simple Ema_ATR Strategy HulkTrading", overlay=true)atr_multiplier = input(2, minval=1, title="ATR Multiplier") // ATR Multiplier. Recommended values between 1..4emaFast=ema(close,21)emaSlow=ema(close,55)//Basically long and short conditions//If long: // 1) close must be less than open (because we are searching for a pullback)// 2) emaFast(21) must be bigger than emaSlow(55) - for a trend detection// 3) Difference between emaFast and emaSlow must be greater than ATR(14) - for excluding flatlongCond = close < open and emaFast > emaSlow and abs(emaSlow-emaFast) > atr(14)  //For short conditions are oppositeshortCond = close > open and emaFast < emaSlow and abs(emaSlow-emaFast) > atr(14) //Stop levels and take profits, based on ATR multiplierstop_level_long = strategy.position_avg_price - atr_multiplier*atr(14)take_level_long = strategy.position_avg_price + atr_multiplier*atr(14)stop_level_short = strategy.position_avg_price + atr_multiplier*atr(14)take_level_short = strategy.position_avg_price - atr_multiplier*atr(14)//Entries and exits strategy.entry("Long", strategy.long, when=longCond, limit = emaSlow)strategy.exit("Stop Loss/TP","Long", stop=stop_level_long, limit = take_level_long)strategy.entry("Short", strategy.short, when=shortCond, limit = emaSlow)strategy.exit("Stop Loss/TP","Short", stop=stop_level_short, limit = take_level_short)