Pine Script v5 · Strategy
EMA Cloud Intraday Strategy
A Pine Script v5 strategy built on EMA (close, 9). It has 7 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. 4 settings; defaults include Trade Quantity 100, Pull Back Trigger 1.00 and Fast EMA Length 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 EMA Cloud Intraday Strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did EMA Cloud Intraday Strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. On ETHUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Does EMA Cloud Intraday Strategy 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: 64 before, 0 after on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does EMA Cloud Intraday Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does EMA Cloud Intraday Strategy run in Zeal Terminal?
- Yes
- It compiles in 26 ms and runs 1,000 bars in 39 ms, in the browser.
BTCUSDT · 1D · default settings
- FastEMA
- SlowEMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $1,000,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 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 |
|---|---|---|---|
| Trade Quantity | 100 | int · min 1 | entry Long_Entry entry Short_Entry |
| Pull Back Trigger | 1.00 | float · min 0.01 | longExit shortExit |
| Fast EMA Length | 9 | int | fastEMA |
| Slow EMA Length | 20 | int | slowEMA |
What it calculates
- EMAclose, Fast EMA Length (9)
fastEMA · line 11 - EMAclose, Slow EMA Length (20)
slowEMA · line 12
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_Entry long | (longCondition) | On | 20 |
| Close Long_Entry | (longExit) | On | 23 |
| Open Short_Entry short | (shortCondition) | On | 27 |
| Close Short_Entry | (shortExit) | On | 30 |
| Close Short_Entry | ( hour(time) == 15 and minute(time) > 50 ) | On | 38 |
| Close Long_Entry | ( hour(time) == 15 and minute(time) > 50 ) | On | 41 |
| Close | validSession == 0 | On | 44 |
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.
- 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.
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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −1.4% | +8.4% | 64 | 41% | 0.69 | 1.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.1% | +21.5% | 69 | 52% | 1.38 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.6% | +17.1% | 75 | 40% | 0.62 | 0.9% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| EMA Cloud Intraday Strategy this page | — | v5 strategy | 0.0% | 0 | 0.0% |
| EMA Slope AyE by fajardoarelys | ema | v4 strategy | No trades on this market | ||
| ROoT by realisticDove62527 | ema | v5 strategy | −4.7% | 225 | 9.4% |
| sachin5986 by mohitesachin78 | ema | v4 strategy | +32.1% | 35 | 17.6% |
| sonu1997 by Sonu1997 | ema | v4 strategy | +960.7% | 2 | 1,103.8% |
| Moving Average Crossover by Muh4mm4d | ema | v4 strategy | +19,990.1% | 30 | 1,274.2% |
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.
- 2 settings use the untyped input() (line 9, 10). 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 64 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 9: input() → input.int()
- Line 10: input() → input.int()
⋯validSession=(na(session) ? 0 : 1)-fastLen = input(title = "Fast EMA Length", defval = 9)+fastLen = input.int(title = "Fast EMA Length", defval = 9)-slowLen = input(title = "Slow EMA Length", defval = 20)+slowLen = input.int(title = "Slow EMA Length", defval = 20)fastEMA = ta.ema(close, fastLen)⋯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: 64 before, 0 after on ETHUSDT 4h, 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.
⋯// © rwestbrookjr-//@version=5+//@version=6strategy("EMA Cloud Intraday Strategy", overlay=true, margin_long=100, margin_short=100, process_orders_on_close=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 26 ms | With a workaround 1,000 bars in 39 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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/// © rwestbrookjr//@version=5strategy("EMA Cloud Intraday Strategy", overlay=true, margin_long=100, margin_short=100, process_orders_on_close=true)i_trdQty = input.int(100, "Trade Quantity", minval = 1)pbTrig = input.float(1.00, "Pull Back Trigger", minval = 0.01)session = time(timeframe.period, "0930-1555:23456")validSession=(na(session) ? 0 : 1)fastLen = input(title = "Fast EMA Length", defval = 9)slowLen = input(title = "Slow EMA Length", defval = 20)fastEMA = ta.ema(close, fastLen)slowEMA = ta.ema(close, slowLen)fema = plot(fastEMA, title = "FastEMA", color = color.green, linewidth = 1, style = plot.style_line)sema = plot(slowEMA, title = "SlowEMA", color = color.red, linewidth = 1, style = plot.style_line)Bull = fastEMA > slowEMABear = fastEMA < slowEMAfill(fema, sema, color = fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title = "Cloud")longCondition = close > fastEMA and close[1] > fastEMA and validSession == 1if (longCondition) strategy.entry("Long_Entry", strategy.long, qty=i_trdQty)longExit = (close < fastEMA and close[1] < fastEMA) or close < (close[1] - pbTrig) or validSession == 0if (longExit) strategy.close("Long_Entry") //strategy.exit("exit", "My Long Entry Id", trail_points=1.5, trail_offset=0)shortCondition = close < fastEMA and close[1] < fastEMA and validSession == 1if (shortCondition) strategy.entry("Short_Entry", strategy.short, qty=i_trdQty)shortExit = (close > fastEMA and close[1] > fastEMA) or close > (close[1] + pbTrig) or validSession == 0if (shortExit) strategy.close("Short_Entry") //strategy.exit("exit", "My Short Entry Id", trail_points=1.5, trail_offset=0) // Close all trades at end of trading daybarOpenTime = time tt=timestamp(year(time), month(time), dayofmonth(time), hour(time), 2) if ( hour(time) == 15 and minute(time) > 50 ) strategy.close("Short_Entry", comment="SCM") if ( hour(time) == 15 and minute(time) > 50 ) strategy.close("Long_Entry", comment="SCM")if validSession == 0// and strategy.opentrades != 0 //if strategy.opentrades > 0 strategy.close_all(comment="SC") //if strategy.opentrades < 0 //strategy.close("Short_Entry", comment="SC")