EMA scalping - Papamallis
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LefterisPapamallis

//@version=5
indicator("simple scalping - papamallis", overlay=false)

loockback= input(22)
ema_input   =   input(21)
loockback_hl    =   input(1)
ema21   =   ta.ema(close, ema_input)
emah    =   ta.ema(ta.highest(high,loockback_hl), ema_input)
emal    =   ta.ema(ta.lowest(loockback_hl), ema_input)

h   =   plot(emah, color= emah > emah[loockback] ? color.green: color.red, linewidth=2)
l   =   plot(emal, color=emal<emal[loockback] ? color.red : color.green,  linewidth=2)


// plot(ema21, color=ema21 > emah ? color.green : ema21<emal ? color.red : color.black)

plot(close, title="close")


plotshape(ta.crossover(close, emah) and emah > emah[loockback] , style=shape.labelup, location=location.bottom, size=size.tiny, color=color.green, textcolor=color.black)
plotshape(ta.crossunder(close, emal) and emal<emal[loockback] , style=shape.labeldown,  location=location.top, size=size.tiny, color=color.red, textcolor=color.white)

fill(h,l, color=  close>emah and emah > emah[loockback] and emal > emal[loockback]? color.green :
     close<emal and emal<emal[loockback] and emah<emah[loockback]  ? color.red : color.black, transp=30)

///macd///

fastMA = ta.ema(close, 12)
slowMA = ta.ema(close, 26)

macd = fastMA - slowMA
signal = ta.sma(macd, 9)
macd_long   = ta.crossover(macd,signal)  and close > emah and emah > emah[loockback] and emal > emal[loockback]
macd_short   = ta.crossunder(macd,signal)   and close<emal and emal<emal[loockback] and emah<emah[loockback]

plot(macd_long or macd_short ? close : na, style=plot.style_circles, color=macd_long ? color.yellow : color.red, linewidth=4, display=display.none, title="macd")