You are on page 1of 1

//@version=5

indicator("EMA Bollinger MACD Signal", overlay=true)

// Define the length of the Exponential Moving Averages (EMAs)


ema20Length = input(20, title="EMA 20 Length")
ema50Length = input(50, title="EMA 50 Length")

// Calculate EMAs
ema20 = ta.ema(close, ema20Length)
ema50 = ta.ema(close, ema50Length)

// Calculate Bollinger Bands


length = input(20, title="Bollinger Bands Length")
src = input(close, title="Bollinger Bands Source")
mult = input(2.0, title="Bollinger Bands Multiplier")
basis = ta.sma(src, length)
upper = basis + mult * ta.stdev(src, length)
lower = basis - mult * ta.stdev(src, length)
bollingerMiddle = (upper + lower) / 2

// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9) // Specify fastlen, slowlen,
and siglen parameters

// Condition for the signal


emaCrossAbove = ema20 > bollingerMiddle and bollingerMiddle > ema50 and close >
ema20 and macdLine > 0 and ta.crossover(ema20, bollingerMiddle) and ema20 > ema50

// Plot the signal on the chart


plotshape(emaCrossAbove ? true : na, color=color.green, style=shape.triangleup,
location=location.belowbar, size=size.small)

You might also like