Double_Based_EMA_v2
// 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_EMA_v2",overlay=true)
ph = low+(high-low)*0.80
pl = low+(high-low)*0.20
pf = close>ph ? ph : close<pl ? pl : close
P1 = input.int(defval=8)
a1 = ta.highest(high,P1)
b1 = ta.lowest(low,P1)
c1 = b1+(a1-b1)*0.80
d1 = b1+(a1-b1)*0.20
e1 = b1+(a1-b1)*0.50
f1 = pf > c1 ? c1 : pf < e1 ? e1 : pf
g1 = pf > e1 ? e1 : pf < d1 ? d1 : pf
cors1 = pf > e1 ? color.silver : #FF000000
cori1 = pf < e1 ? color.silver : #FF000000
h1 = ta.ema(f1,P1)
i1 = ta.ema(g1,P1)
plot(h1,color=cors1)
plot(i1,color=cori1)
plot((h1+i1)/2,color=color.white)
//---
P2 = input.int(defval=34)
a2 = ta.highest(high,P2)
b2 = ta.lowest(low,P2)
c2 = b2+(a2-b2)*0.80
d2 = b2+(a2-b2)*0.20
e2 = b2+(a2-b2)*0.50
f2 = pf > c2 ? c2 : pf < e2 ? e2 : pf
g2 = pf > e2 ? e2 : pf < d2 ? d2 : pf
cors2 = pf > e2 ? color.green : #FF000000
cori2 = pf < e2 ? color.green : #FF000000
h2 = ta.ema(f2,P2)
i2 = ta.ema(g2,P2)
plot(h2,color=cors2)
plot(i2,color=cori2)
plot((h2+i2)/2,color=color.lime)
//---
P3 = input.int(defval=144)
a3 = ta.highest(high,P3)
b3 = ta.lowest(low,P3)
c3 = b3+(a3-b3)*0.80
d3 = b3+(a3-b3)*0.20
e3 = b3+(a3-b3)*0.50
f3 = pf > c3 ? c3 : pf < e3 ? e3 : pf
g3 = pf > e3 ? e3 : pf < d3 ? d3 : pf
cors3 = pf > e3 ? color.orange : #FF000000
cori3 = pf < e3 ? color.orange : #FF000000
h3 = ta.ema(f3,P3)
i3 = ta.ema(g3,P3)
plot(h3,color=cors3)
plot(i3,color=cori3)
plot((h3+i3)/2,color=color.yellow)
//---
P4 = input.int(defval=610)
a4 = ta.highest(high,P4)
b4 = ta.lowest(low,P4)
c4 = b4+(a4-b4)*0.80
d4 = b4+(a4-b4)*0.20
e4 = b4+(a4-b4)*0.50
f4 = pf > c4 ? c4 : pf < e4 ? e4 : pf
g4 = pf > e4 ? e4 : pf < d4 ? d4 : pf
cors4 = pf > e4 ? color.maroon : #FF000000
cori4 = pf < e4 ? color.maroon : #FF000000
h4 = ta.ema(f4,P4)
i4 = ta.ema(g4,P4)
plot(h4,color=cors4)
plot(i4,color=cori4)
plot((h4+i4)/2,color=color.red)