// © TheProfessorDev
//@version=4
study(title="Black Dog System v1.0 by Prof. D", overlay=true)
//EMA 1
emaplot = input (true, title="Show EMA on chart")
len = input(15, minval=1, title="EMA Length")
src = close
out = ema(src, len)
up = out > out[1]
down = out < out[1]
mycolor = up ? color.green : down ? color.red : color.blue
plot(out and emaplot ? out :na, title="EMA", color=mycolor, linewidth=4)
//EMA 2
emaplot2 = input (true, title="Show EMA on chart")
len2 = input(50, minval=1, title="EMA High Length")
src2 = high
out2 = ema(src2, len2)
up2 = out2 > out2[1]
down2 = out2 < out2[1]
mycolor2 = up2 ? color.white : down2 ? color.yellow : color.blue
plot(out2 and emaplot ? out2 :na, title="EMA", color=mycolor2, linewidth=2)
//EMA 3
emaplot3 = input (true, title="Show EMA on chart")
len3 = input(50, minval=1, title="EMA Low Length")
src3 = low
out3 = ema(src3, len3)
up3 = out3 > out3[1]
down3 = out3 < out3[1]
mycolor3 = up3 ? color.white : down3 ? color.yellow : color.blue
plot(out3 and emaplot3 ? out3 :na, title="EMA", color=mycolor3, linewidth=2)
// MACD 1
fastLength = input(10)
slowlength = input(20)
MACDLength = input(7)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD
// Entry Exit
trendup = crossover(ema(close,2),ema(close,15)) and close>ema(low,50) and (delta>0)
trenddown = crossunder(ema(close,2),ema(close,15)) and close<ema(high,50) and (delta<0)
// Plotting
plotshape(trendup, title="LONG", text="BUY", textcolor=color.white, style=shape.labelup, location=location.belowbar, color=color.green, transp=0, size=size.tiny)
plotshape(trenddown, title="SHORT", text="SELL", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.red, transp=0, size=size.tiny)
// Alerts
alertcondition(trendup, title="LONG", message="LONG")
alertcondition(trenddown, title="SHORT", message="SHORT")