OPEN-SOURCE SCRIPT

EMA Buy/Sell Signals

55
//version=5
indicator("EMA Buy/Sell Signals", overlay=true)

// Calculate the 20-period EMA on the 1-hour chart
ema20 = request.security(syminfo.tickerid, "60", ta.ema(close, 20))

// Calculate the 10-period EMA on the 3-minute chart
ema10 = ta.ema(close, 10)

// Determine the bias based on the 1-hour chart
var float bias = na
if (ema20 != na)
bias := close > ema20 ? 1 : -1

// Identify entry signals on the 3-minute chart
longCondition = (bias == 1) and ta.crossover(close, ema10)
shortCondition = (bias == -1) and ta.crossunder(close, ema10)

// Plot signals on the chart
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")

// Plot EMA lines on the chart
plot(ema20, title="EMA 20", color=color.blue)
plot(ema10, title="EMA 10", color=color.orange)

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。