Simple Pinescript Indicator
Simple Pinescript Indicator
// Inputs
fast = input.int(9, "Fast EMA")
slow = input.int(21, "Slow EMA")
// Calculate EMAs
ema_fast = ta.ema(close, fast)
ema_slow = ta.ema(close, slow)
// Plot EMAs
plot(ema_fast, color=color.blue, title="Fast EMA")
plot(ema_slow, color=color.red, title="Slow EMA")
// Signals
bullish = ta.crossover(ema_fast, ema_slow)
bearish = ta.crossunder(ema_fast, ema_slow)
// Plot signals
plotshape(bullish, style=shape.triangleup, location=location.belowbar,
color=color.green, size=size.small)
plotshape(bearish, style=shape.triangledown, location=location.abovebar,
color=color.red, size=size.small)
// Alerts
alertcondition(bullish, "Bull Cross", "Fast EMA crossed above Slow EMA")
alertcondition(bearish, "Bear Cross", "Fast EMA crossed below Slow EMA")