Skip to content

Free TradingView indicator

EMA Cloud Trend

Fast 8/21 and slow 50/200 EMA clouds with a combined trend state, alignment labels and slow-cloud cross alerts.

Trendv1.0TradingView (Pine Script v6) Non-repainting signals Alerts

What it does

EMA Cloud Trend draws two shaded clouds on the price chart. The fast cloud, between the 8 and 21 EMAs, tracks short-term direction. The slow cloud, between the 50 and 200 EMAs, tracks the broader trend. Each cloud is green when its faster EMA is on top and red when it is below.

The script combines the two into a single trend state: bullish when both clouds are green, bearish when both are red, and mixed when they disagree. Labels mark the first bar of each new aligned state.

How it works

  • Four exponential moving averages are calculated from the chosen source.
  • Fast cloud is bullish when EMA 8 > EMA 21. Slow cloud is bullish when EMA 50 > EMA 200.
  • Trend state = 1 when both are bullish, −1 when both are bearish, 0 otherwise.
  • A Bull or Bear label prints when the state changes to 1 or −1.
  • A small diamond marks the slow cloud itself flipping (EMA 50 crossing EMA 200), the event often called a golden or death cross.

Every signal is checked on a closed bar, so labels do not flicker on the live candle. Each cloud can be hidden on its own.

How to use it

  • Use the slow cloud as the backdrop. When it is green, many traders only consider long ideas; when red, only shorts. The fast cloud then shows pullbacks (fast cloud turns against the slow one) and resumptions (fast cloud turns back).
  • A new aligned label after a pullback is a common point to look for an entry setup, ideally near a level such as a prior swing or a trendline.
  • Price trading inside the slow cloud usually means the broader trend is in transition. Treat signals there with extra caution.
  • Works on most liquid markets from M15 to D1. On higher timeframes the 200 EMA needs plenty of history to be meaningful. For background on how EMAs differ from simple averages, see moving averages.

Settings

InputDefaultWhat it changes
SourceclosePrice used for all four EMAs.
Fast cloud EMA 1 / 28 / 21Sensitivity of the short-term cloud.
Slow cloud EMA 1 / 250 / 200Sensitivity of the long-term cloud.
Show fast cloud / slow cloudOn / OnHide either cloud.
Show trend-state labelsOnBull/Bear labels on new aligned states.
Show slow cloud crossesOnDiamonds when EMA 50 crosses EMA 200.
Color bars by trend stateOffCandle coloring by the combined state.

Limitations

  • Moving averages lag. Aligned labels appear after a trend has already started, sometimes close to its end.
  • In sideways markets the fast cloud flips often and the combined state can bounce between aligned and mixed.
  • The 50/200 cross is a slow, infrequent event and says little about timing on its own.
  • The first 200 bars of a chart do not have a reliable slow cloud, so states there should be ignored.

Pine Script source

In TradingView open Pine Editor, paste the code, click Save and then Add to chart.

FXP_EmaCloudTrend.pine

64 lines

// © FXPIPS ONLINE — https://fxpips.online/tradingview-indicators/ema-cloud-trend/
// License: MIT. Educational tool — not financial advice. Trading involves substantial risk.
//@version=6
// Two EMA clouds: a fast 8/21 cloud for short-term direction and a slow 50/200 cloud for the
// broader trend. The trend state is bullish or bearish only when both clouds agree.
indicator("FXP EMA Cloud Trend", shorttitle = "FXP EMA Cloud", overlay = true)

// ── Inputs ─────────────────────────────────────────────────────────────
grpE  = "EMA lengths"
src   = input.source(close, "Source", group = grpE)
lenF1 = input.int(8, "Fast cloud EMA 1", minval = 1, group = grpE)
lenF2 = input.int(21, "Fast cloud EMA 2", minval = 1, group = grpE)
lenS1 = input.int(50, "Slow cloud EMA 1", minval = 1, group = grpE)
lenS2 = input.int(200, "Slow cloud EMA 2", minval = 1, group = grpE)

grpV        = "Display"
showFast    = input.bool(true, "Show fast cloud", group = grpV)
showSlow    = input.bool(true, "Show slow cloud", group = grpV)
showSignals = input.bool(true, "Show trend-state labels", group = grpV)
showCross   = input.bool(true, "Show slow cloud crosses", group = grpV)
colorBars   = input.bool(false, "Color bars by trend state", group = grpV)
colBull     = input.color(#26a69a, "Bullish color", group = grpV)
colBear     = input.color(#ef5350, "Bearish color", group = grpV)
colMixed    = input.color(#9e9e9e, "Mixed color", group = grpV)

// ── Calculation ────────────────────────────────────────────────────────
emaF1 = ta.ema(src, lenF1)
emaF2 = ta.ema(src, lenF2)
emaS1 = ta.ema(src, lenS1)
emaS2 = ta.ema(src, lenS2)

fastBull = emaF1 > emaF2
slowBull = emaS1 > emaS2

// 1 = both clouds bullish, -1 = both bearish, 0 = clouds disagree
int state = fastBull and slowBull ? 1 : not fastBull and not slowBull ? -1 : 0
prevState = nz(state[1])
stateColor = state == 1 ? colBull : state == -1 ? colBear : colMixed

bullStart   = state == 1 and prevState != 1 and barstate.isconfirmed
bearStart   = state == -1 and prevState != -1 and barstate.isconfirmed
slowCrossUp = ta.crossover(emaS1, emaS2) and barstate.isconfirmed
slowCrossDn = ta.crossunder(emaS1, emaS2) and barstate.isconfirmed

// ── Plots ──────────────────────────────────────────────────────────────
pF1 = plot(showFast ? emaF1 : na, "Fast EMA 1", color = color.new(fastBull ? colBull : colBear, 40))
pF2 = plot(showFast ? emaF2 : na, "Fast EMA 2", color = color.new(fastBull ? colBull : colBear, 40))
pS1 = plot(showSlow ? emaS1 : na, "Slow EMA 1", color = color.new(slowBull ? colBull : colBear, 30), linewidth = 2)
pS2 = plot(showSlow ? emaS2 : na, "Slow EMA 2", color = color.new(slowBull ? colBull : colBear, 30), linewidth = 2)
fill(pF1, pF2, color = color.new(fastBull ? colBull : colBear, 70), title = "Fast cloud")
fill(pS1, pS2, color = color.new(slowBull ? colBull : colBear, 82), title = "Slow cloud")
barcolor(colorBars ? stateColor : na, title = "Trend state bar color")

plotshape(showSignals and bullStart, "Bullish trend state", style = shape.labelup, location = location.belowbar, color = colBull, text = "Bull", textcolor = color.white, size = size.small)
plotshape(showSignals and bearStart, "Bearish trend state", style = shape.labeldown, location = location.abovebar, color = colBear, text = "Bear", textcolor = color.white, size = size.small)
plotshape(showCross and slowCrossUp, "Slow cloud turns bullish", style = shape.diamond, location = location.belowbar, color = colBull, size = size.tiny)
plotshape(showCross and slowCrossDn, "Slow cloud turns bearish", style = shape.diamond, location = location.abovebar, color = colBear, size = size.tiny)

// ── Alerts ─────────────────────────────────────────────────────────────
alertcondition(bullStart, "EMA clouds aligned bullish", "Both EMA clouds turned bullish on {{ticker}} ({{interval}})")
alertcondition(bearStart, "EMA clouds aligned bearish", "Both EMA clouds turned bearish on {{ticker}} ({{interval}})")
alertcondition(slowCrossUp, "Slow cloud bullish cross", "Slow EMA cloud turned bullish on {{ticker}} ({{interval}})")
alertcondition(slowCrossDn, "Slow cloud bearish cross", "Slow EMA cloud turned bearish on {{ticker}} ({{interval}})")

Key inputs

Key inputs of EMA Cloud Trend
InputDefaultDescription
Fast cloud EMA 18Faster EMA of the short-term cloud.
Fast cloud EMA 221Slower EMA of the short-term cloud.
Slow cloud EMA 150Faster EMA of the long-term cloud.
Slow cloud EMA 2200Slower EMA of the long-term cloud.
Color bars by trend stateOffPaints candles green, red or grey by the combined state.

Educational tools, not advice. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related tradingview indicators