OPEN-SOURCE SCRIPT

EMA Strategy with Long/Short Signals

//version=5
indicator("EMA Strategy with Long/Short Signals", overlay=true)

// Input for EMAs
ema22 = ta.ema(close, 22)
ema55 = ta.ema(close, 55)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)

// Plot EMAs
plot(ema22, color=color.blue, title="EMA 22", linewidth=2)
plot(ema55, color=color.orange, title="EMA 55", linewidth=2)
plot(ema100, color=color.purple, title="EMA 100", linewidth=2)
plot(ema200, color=color.red, title="EMA 200", linewidth=2)

// Long condition: Price above all EMAs and trending upward
longCondition = close > ema22 and ema22 > ema55 and ema55 > ema100 and ema100 > ema200

// Short condition: Price below all EMAs and trending downward
shortCondition = close < ema22 and ema22 < ema55 and ema55 < ema100 and ema100 < ema200

// Plot Long/Short signals
plotshape(longCondition, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(shortCondition, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")

免責聲明