EMA Cross

Pine Script indicator by Chart GT · Published

Fast and slow EMAs with markers where they cross.

Tags: trend, moving-average, crossover

Source code

//@version=6
// @name EMA Cross
// @description Fast and slow EMAs with markers where they cross.
// @tags trend,moving-average,crossover
indicator("EMA Cross", overlay=true)
fastLen = input.int(9, "Fast EMA", minval=1)
slowLen = input.int(21, "Slow EMA", minval=1)
fast = ta.ema(close, fastLen)
slow = ta.ema(close, slowLen)
plot(fast, "Fast EMA", color=color.teal, linewidth=2)
plot(slow, "Slow EMA", color=color.orange, linewidth=2)
bull = ta.crossover(fast, slow)
bear = ta.crossunder(fast, slow)
plotshape(bull, "Bullish cross", style=shape.triangleup, location=location.belowbar, color=color.teal, size=size.small)
plotshape(bear, "Bearish cross", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
alertcondition(bull, "EMA bullish cross", "Fast EMA crossed above slow EMA")
alertcondition(bear, "EMA bearish cross", "Fast EMA crossed below slow EMA")

License: MPL-2.0

Open the chart to add it, or browse more community scripts.