MIDAS Line v.1
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PhysioGuy

//@version=5
indicator("Midas line v.1", overlay=true)
//source
len = input.int(89, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)


//create macd
fast = ta.ema(close,12)
slow = ta.ema(close,26)
macd = fast - slow
signal = ta.ema(macd,9)

//condition macd
bull = macd >= 0 and macd >= signal
weakbull = macd >=0 and macd < signal
weakbear = macd < 0 and macd > signal
bear = macd < 0 and macd < signal

//colorful
col = bull ? color.lime : weakbull ? #FFC300 : weakbear ? color.blue : bear ? color.red : na 
//create ema
ema = ta.ema(src,len)

//colorful ema
plot(ema, linewidth=4, color = col,title="Midas line")

//barcolor
barcolor(color=col)

//signal
plotshape(macd > 0 and macd[1] < 0,style=shape.triangleup,location=location.belowbar,size=size.tiny, color=color.green,text="Buy")
plotshape(macd < 0 and macd[1] > 0,style=shape.triangledown,location=location.abovebar,size=size.tiny, color=color.red,text="Sell")




