This script calculates the 9, 21, and 50-period EMAs, plots them on the chart, and generates buy signals when the 9 EMA crosses above the 21 EMA while being above the 50 EMA, and sell signals when the 9 EMA crosses below the 21 EMA while being below the 50 EMA. You can customize the colors and styles as needed. ```pinescript //version=5 indicator("EMA Crossover Strategy", overlay=true)
// Define the EMAs ema9 = ta.ema(close, 9) ema21 = ta.ema(close, 21) ema50 = ta.ema(close, 50)
// Plot the EMAs plot(ema9, color=color.blue, title="EMA 9") plot(ema21, color=color.red, title="EMA 21") plot(ema50, color=color.green, title="EMA 50")
// Define buy and sell conditions buySignal = ta.crossover(ema9, ema21) and ema9 > ema50 sellSignal = ta.crossunder(ema9, ema21) and ema9 < ema50