Calculation and confirmation guide

Trend cloud indicators: read the boundaries before the color

A trend cloud shades the area between calculated lines. An EMA cloud shows the separation of two moving averages; an ATR envelope shows a multiple of a volatility measure. The same color or width can therefore mean different things. Neither calculation identifies institutional orders or establishes that a shaded price zone will hold.

Explore custom indicator coding

Three cloud types encode different information

A fill adds no new market data. Its meaning comes from the two plotted boundaries.

CloudBoundary calculationWhat width meansLimit
EMA cloudTwo exponential averages of the same sourceAbsolute difference between the averagesNot an ATR estimate, fair value or measured support strength
ATR envelopeChosen baseline plus and minus k × ATRFull width is 2 × k × ATRCan widen during volatile sideways movement
Ichimoku cloudLeading spans derived from high-low midpointsDifference between the two spans at their displayed positionsForward display displacement is not future price data

Recalculate width before calling it strength

For invented values, fast EMA 102 and slow EMA 100 produce a width of 2 price units. That is 2% of the slow EMA. With ATR 1, the spread is 2 ATR; with ATR 4, the identical cloud is only 0.5 ATR wide. These normalizations answer different questions.

  • An ATR envelope with baseline 100, ATR 2 and multiplier 1.5 has boundaries 103 and 97: full width 6. It is not the same construction as a two-EMA cloud.
  • EMA separation can persist after price begins reversing because both averages retain earlier observations. A wide cloud does not guarantee continuation.
  • Treat a close inside the cloud as a location observation. Calling it fair value or defended institutional support needs evidence outside the moving averages.

Pine Script v6: confirmed EMA cloud and crossover alerts

This example uses fixed opacity, not a gradient. It hides values on the developing chart bar and starts displaying after at least slowLength chart bars. EMAs still depend on the available starting history. Equal averages have a neutral state. Alerts require the current chart bar to close and the prior bar to have passed the history gate.

EMA boundaries and confirmed chart-bar crossingspinescript
//@version=6
indicator("Confirmed EMA Cloud [Pineify]", overlay=true)
int fastLength = input.int(20, "Fast EMA length", minval=1)
int slowLength = input.int(50, "Slow EMA length", minval=2)
if fastLength >= slowLength
    runtime.error("Fast length must be smaller than slow length.")
float fastEma = ta.ema(close, fastLength)
float slowEma = ta.ema(close, slowLength)
bool ready = bar_index >= slowLength - 1 and not na(fastEma) and not na(slowEma)
bool confirmed = ready and barstate.isconfirmed
int state = fastEma > slowEma ? 1 : fastEma < slowEma ? -1 : 0
color shade = state == 1 ? color.new(color.teal, 70) : state == -1 ? color.new(color.orange, 70) : color.new(color.gray, 85)
pFast = plot(confirmed ? fastEma : na, "Fast EMA", color=color.teal, style=plot.style_linebr)
pSlow = plot(confirmed ? slowEma : na, "Slow EMA", color=color.orange, style=plot.style_linebr)
fill(pFast, pSlow, color=confirmed ? shade : na, title="Confirmed EMA cloud", fillgaps=false)
bool crossesUp = ta.crossover(fastEma, slowEma)
bool crossesDown = ta.crossunder(fastEma, slowEma)
bool bullFlip = confirmed and ready[1] and crossesUp
bool bearFlip = confirmed and ready[1] and crossesDown
plotshape(bullFlip, title="Confirmed bullish cross", style=shape.triangleup, location=location.belowbar, color=color.teal, size=size.tiny)
plotshape(bearFlip, title="Confirmed bearish cross", style=shape.triangledown, location=location.abovebar, color=color.orange, size=size.tiny)
alertcondition(bullFlip, "Bullish EMA cross", "Fast EMA crossed above slow EMA on a closed chart bar.")
alertcondition(bearFlip, "Bearish EMA cross", "Fast EMA crossed below slow EMA on a closed chart bar.")

Create and check the alert

Add the indicator to a standard candle chart, then create a TradingView alert using one of its named crossover conditions. Choose Once Per Bar Close. Script code makes conditions available; it does not create a running alert for you.

  • Compare fast and slow EMA values in the Data Window with the chosen lengths. The default 20/50 pair is an example, not an optimal setting.
  • Watch the open bar: this version intentionally leaves its cloud and markers blank. At the close, a strict crossing can produce a marker. Equality alone does not.
  • Recreate alerts after changing script inputs because TradingView saves a snapshot when an alert is created.
  • This script has no higher-timeframe request, orders or trailing stop. Confirmation controls intrabar fluctuations; feed revisions and different history can still affect calculations.

If you use a cloud as an exit reference

Write the execution rule separately. For example, a long-position study might exit at the next open after a confirmed close below both averages. That differs from a stop-market order active inside the bar.

  • If testing a trailing stop, define when its level updates and whether it may ever move away from price. A falling average is not automatically a valid ratcheting stop.
  • Record gaps, slippage, exposure and costs. Compare a frozen rule on a later period; neither the cloud image nor syntax success is a performance result.
Where Pineify fits

Pine Script AI Coding Agent

Adapt the stated calculation, inputs and confirmation rule into a Pine Script draft, then inspect the result on your chart.

Explore custom indicator coding

Frequently asked questions

Educational examples, not investment advice or tested trading strategies. Indicators describe supplied historical and developing prices. Syntax validation does not establish profitability or live execution.

Sources and verification