Double_based_ema
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jacobfabris

//@version=5
indicator("Double_based",overlay=true)
P = input.int(defval=21,minval = 4,maxval=999)
a = ta.highest(high,P)
b = ta.lowest(low,P)
c = ta.atr(P)
ls = a-c/2
li = b+c/2
lm = (a+b)/2
ps = close > ls ? ls : close < lm ? lm : close
pi = close > lm ? lm : close < li ? li : close
ms = ta.ema(ps,P)
mi = ta.ema(pi,P)
cors = close > lm ? color.green : #FF000000
cori = close < lm ? color.orange : #FF000000
plot(ms,color=cors)
plot(mi,color=cori)





