OPEN-SOURCE SCRIPT

EMA Cross BUY SELL

62



ema1Length = input.int(10, "EMA1 Periyodu")
ema2Length = input.int(20, "EMA2 Periyodu")
emaLineWidth = input.int(3, "EMA Çizgi Kalınlığı", minval=1, maxval=10)
bgTransparency = input.int(85, "Arka Plan Saydamlığı", minval=0, maxval=100)


ema1 = ta.ema(close, ema1Length)
ema2 = ta.ema(close, ema2Length)


longSignal = ta.crossover(ema1, ema2)
shortSignal = ta.crossunder(ema1, ema2)


var int trend = 0
trend := longSignal ? 1 : shortSignal ? -1 : trend


barcolor(trend == 1 ? color.green : trend == -1 ? color.red : na)


bgcolor(trend == 1 ? color.new(color.green, bgTransparency) : trend == -1 ? color.new(color.red, bgTransparency) : na)
plot(ema1, color=trend == 1 ? color.green : trend == -1 ? color.red : color.gray, linewidth=emaLineWidth, title="EMA1")
plot(ema2, color=trend == 1 ? color.green : trend == -1 ? color.red : color.gray, linewidth=emaLineWidth, title="EMA2")

plotshape(longSignal, title="Al Ok", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.large)
plotshape(shortSignal, title="Sat Ok", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.large)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.