I'd like to have an overlay on 2 Moving Averages when they cross each other, sth. like here shown:
But it's not working, now getting an error "end of line w/o line continuation"... Any ideas? Thank you!
//@version=5
indicator("Moving Average Cross", shorttitle="MA Cross", overlay=true, timeframe="", timeframe_gaps=true)
ma(source, length, type) =>
type == "SMA" ? ta.sma(source, length) :
type == "EMA" ? ta.ema(source, length) :
type == "SMMA (RMA)" ? ta.rma(source, length) :
type == "WMA" ? ta.wma(source, length) :
type == "VWMA" ? ta.vwma(source, length) :
na
show_ma1 = input(true , "MA №1", inline="MA #1")
ma1_type = input.string("SMA" , "" , inline="MA #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
ma1_source = input(close , "" , inline="MA #1")
ma1_length = input.int(20 , "" , inline="MA #1", minval=1)
ma1_color = input(#f6c309, "" , inline="MA #1")
ma1 = ma(ma1_source, ma1_length, ma1_type)
plot(show_ma1 ? ma1 : na, color = ma1_color, title="MA №1")
show_ma2 = input(true , "MA №2", inline="MA #2")
ma2_type = input.string("SMA" , "" , inline="MA #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
ma2_source = input(close , "" , inline="MA #2")
ma2_length = input.int(50 , "" , inline="MA #2", minval=1)
ma2_color = input(#fb9800, "" , inline="MA #2")
ma2 = ma(ma2_source, ma2_length, ma2_type)
plot(show_ma2 ? ma2 : na, color = ma2_color, title="MA №2")
longCond = ta.crossover(ma1 > ma2)
shortCond = ta.crossunder(ma1 < ma2)
plotshape(series=longCond, title="Long", style=shape.triangleup, location=location.belowbar, color.green, text="LONG", size=size.normal)
plotshape(series=shortCond, title="Short", style=shape.triangledown, location=location.abovebar, color.red, text="SHORT", size=size.normal)
