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



// Original Indicator Script for calculation and color change Hull Ma written and published by huyfibo
// I found his version preferable and superior due to the method of mathematics used to get the Hull Ma

// This indicator was written for a study to replace multiple SMA's with Hull MAs to compare accuracy as the Hull has much less lag
// Default values are as such so that the user can have 5 min values displayed on a 1 min chart, as well as the equiv of 200 on the 30 min for the 2 and 4 hour.
// This is a simply a matter of convenience for the study and can be unchecked to be hidden. 
// Coded colors and lengths are to visually discern comparable values. Both 1 and 5 min timeframes are the same color, but 1 min timeframe value has larger linewidth

//@version=5


// Hull MA 0 Original script by huyfibo

indicator("Multi HMA",overlay = true )

src = input(defval=close, title="Source")

n=input(title="Hull MA Period", defval=14)
n2ma=2*ta.wma(close,math.round(n/2))
nma=ta.wma(close,n)
diff=n2ma-nma
sqn=math.round(math.sqrt(n))


n2ma1=2*ta.wma(close[1],math.round(n/2))
nma1=ta.wma(close[1],n)
diff1=n2ma1-nma1
sqn1=math.round(math.sqrt(n))

n1=ta.wma(diff,sqn)
n2=ta.wma(diff1,sqn)
c=n1>n2? color.green : color.red
hma=plot(n1, "Hull MA 14", color=c, linewidth=3)




// Hull 1

n_h1=input(title="Hull MA Period", defval=25)
n2ma_h1=2*ta.wma(close,math.round(n_h1/2))
nma_h1=ta.wma(close,n_h1)
diff_h1=n2ma_h1-nma_h1
sqn_h1=math.round(math.sqrt(n_h1))


n2ma1_h1=2*ta.wma(close[1],math.round(n_h1/2))
nma1_h1=ta.wma(close[1],n_h1)
diff1_h1=n2ma1_h1-nma1_h1
sqn1_h1=math.round(math.sqrt(n_h1))

n1_h1=ta.wma(diff_h1,sqn_h1)
n2_h1=ta.wma(diff1_h1,sqn_h1)
c_h1=n1_h1>n2_h1? color.fuchsia : color.purple
hma_h1=plot(n1_h1, "Hull MA 25", color=c_h1, linewidth=3)



// Hull 2
n_h2=input(title="Hull MA Period", defval=50)
n2ma_h2=2*ta.wma(close,math.round(n_h2/2))
nma_h2=ta.wma(close,n_h2)
diff_h2=n2ma_h2-nma_h2
sqn_h2=math.round(math.sqrt(n_h2))


n2ma1_h2=2*ta.wma(close[1],math.round(n_h2/2))
nma1_h2=ta.wma(close[1],n_h2)
diff1_h2=n2ma1_h2-nma1_h2
sqn1_h2=math.round(math.sqrt(n_h2))

n1_h2=ta.wma(diff_h2,sqn_h2)
n2_h2=ta.wma(diff1_h2,sqn_h2)
c_h2=n1_h2>n2_h2? color.blue : color.navy
hma_h2=plot(n1_h2, "Hull MA 50", color=c_h2, linewidth=3)



// Hull 3
n_h3=input(title="Hull MA Period", defval=70)
n2ma_h3=2*ta.wma(close,math.round(n_h3/2))
nma_h3=ta.wma(close,n_h3)
diff_h3=n2ma_h3-nma_h3
sqn_h3=math.round(math.sqrt(n_h3))


n2ma1_h3=2*ta.wma(close[1],math.round(n_h3/2))
nma1_h3=ta.wma(close[1],n_h3)
diff1_h3=n2ma1_h3-nma1_h3
sqn1_h3=math.round(math.sqrt(n_h3))

n1_h3=ta.wma(diff_h3,sqn_h3)
n2_h3=ta.wma(diff1_h3,sqn_h3)
c_h3=n1_h3>n2_h3? color.green : color.red
hma_h3=plot(n1_h3, "Hull MA 70", color=c_h3)


// Hull 4
n_h4=input(title="Hull MA Period", defval=100)
n2ma_h4=2*ta.wma(close,math.round(n_h4/2))
nma_h4=ta.wma(close,n_h4)
diff_h4=n2ma_h4-nma_h4
sqn_h4=math.round(math.sqrt(n_h4))


n2ma1_h4=2*ta.wma(close[1],math.round(n_h4/2))
nma1_h4=ta.wma(close[1],n_h4)
diff1_h4=n2ma1_h4-nma1_h4
sqn1_h4=math.round(math.sqrt(n_h4))

n1_h4=ta.wma(diff_h4,sqn_h4)
n2_h4=ta.wma(diff1_h4,sqn_h4)
c_h4=n1_h4>n2_h4? color.aqua : color.teal
hma_h4=plot(n1_h4, "Hull MA 100", color=c_h4, linewidth=3)



// Hull 5

n_h5=input(title="Hull MA Period", defval=125)
n2ma_h5=2*ta.wma(close,math.round(n_h5/2))
nma_h5=ta.wma(close,n_h5)
diff_h5=n2ma_h5-nma_h5
sqn_h5=math.round(math.sqrt(n_h5))


n2ma1_h5=2*ta.wma(close[1],math.round(n_h5/2))
nma1_h5=ta.wma(close[1],n_h5)
diff1_h5=n2ma1_h5-nma1_h5
sqn1_h5=math.round(math.sqrt(n_h5))

n1_h5=ta.wma(diff_h5,sqn_h5)
n2_h5=ta.wma(diff1_h5,sqn_h5)
c_h5=n1_h5>n2_h5? color.fuchsia : color.purple
hma_h5=plot(n1_h5, "Hull MA 125", color=c_h5)

// Hull 6

n_h6=input(title="Hull MA Period", defval=200)
n2ma_h6=2*ta.wma(close,math.round(n_h6/2))
nma_h6=ta.wma(close,n_h6)
diff_h6=n2ma_h6-nma_h6
sqn_h6=math.round(math.sqrt(n_h6))


n2ma1_h6=2*ta.wma(close[1],math.round(n_h6/2))
nma1_h6=ta.wma(close[1],n_h6)
diff1_h6=n2ma1_h6-nma1_h6
sqn1_h6=math.round(math.sqrt(n_h6))

n1_h6=ta.wma(diff_h6,sqn_h6)
n2_h6=ta.wma(diff1_h6,sqn_h6)
c_h6=n1_h6>n2_h6? color.yellow : color.orange
hma_h6=plot(n1_h6, "Hull MA 200", color=c_h6, linewidth=3)




// Hull 7
n_h7=input(title="Hull MA Period", defval=250)
n2ma_h7=2*ta.wma(close,math.round(n_h7/2))
nma_h7=ta.wma(close,n_h7)
diff_h7=n2ma_h7-nma_h7
sqn_h7=math.round(math.sqrt(n_h7))


n2ma1_h7=2*ta.wma(close[1],math.round(n_h7/2))
nma1_h7=ta.wma(close[1],n_h7)
diff1_h7=n2ma1_h7-nma1_h7
sqn1_h7=math.round(math.sqrt(n_h7))

n1_h7=ta.wma(diff_h7,sqn_h7)
n2_h7=ta.wma(diff1_h7,sqn_h7)
c_h7=n1_h7>n2_h7? color.blue : color.navy
hma_h7=plot(n1_h7, "Hull MA 250", color=c_h7)


// Hull 8
n_h8=input(title="Hull MA Period", defval=500)
n2ma_h8=2*ta.wma(close,math.round(n_h8/2))
nma_h8=ta.wma(close,n_h8)
diff_h8=n2ma_h8-nma_h8
sqn_h8=math.round(math.sqrt(n_h8))


n2ma1_h8=2*ta.wma(close[1],math.round(n_h8/2))
nma1_h8=ta.wma(close[1],n_h8)
diff1_h8=n2ma1_h8-nma1_h8
sqn1_h8=math.round(math.sqrt(n_h8))

n1_h8=ta.wma(diff_h8,sqn_h8)
n2_h8=ta.wma(diff1_h8,sqn_h8)
c_h8=n1_h8>n2_h8? color.aqua : color.teal
hma_h8=plot(n1_h8, "Hull MA 500", color=c_h8)



// Hull 9
n_h9=input(title="Hull MA Period", defval=1000)
n2ma_h9=2*ta.wma(close,math.round(n_h9/2))
nma_h9=ta.wma(close,n_h9)
diff_h9=n2ma_h9-nma_h9
sqn_h9=math.round(math.sqrt(n_h9))


n2ma1_h9=2*ta.wma(close[1],math.round(n_h9/2))
nma1_h9=ta.wma(close[1],n_h9)
diff1_h9=n2ma1_h9-nma1_h9
sqn1_h9=math.round(math.sqrt(n_h9))

n1_h9=ta.wma(diff_h9,sqn_h9)
n2_h9=ta.wma(diff1_h9,sqn_h9)
c_h9=n1_h9>n2_h9? color.yellow : color.orange
hma_h9=plot(n1_h9, "Hull MA 1000", color=c_h9)


// Hull 10
n_h10=input(title="Hull MA Period", defval=400)
n2ma_h10=2*ta.wma(close,math.round(n_h10/2))
nma_h10=ta.wma(close,n_h10)
diff_h10=n2ma_h10-nma_h10
sqn_h10=math.round(math.sqrt(n_h10))


n2ma1_h10=2*ta.wma(close[1],math.round(n_h10/2))
nma1_h10=ta.wma(close[1],n_h10)
diff1_h10=n2ma1_h10-nma1_h10
sqn1_h10=math.round(math.sqrt(n_h10))

n1_h10=ta.wma(diff_h10,sqn_h10)
n2_h10=ta.wma(diff1_h10,sqn_h10)
c_h10=n1_h10>n2_h10? color.yellow : color.orange
hma_h10=plot(n1_h10, "Hull MA 400", color=c_h10)




// Hull 11
n_h11=input(title="Hull MA Period", defval=800)
n2ma_h11=2*ta.wma(close,math.round(n_h11/2))
nma_h11=ta.wma(close,n_h11)
diff_h11=n2ma_h11-nma_h11
sqn_h11=math.round(math.sqrt(n_h11))


n2ma1_h11=2*ta.wma(close[1],math.round(n_h11/2))
nma1_h11=ta.wma(close[1],n_h11)
diff1_h11=n2ma1_h11-nma1_h11
sqn1_h11=math.round(math.sqrt(n_h11))

n1_h11=ta.wma(diff_h11,sqn_h11)
n2_h11=ta.wma(diff1_h11,sqn_h11)
c_h11=n1_h11>n2_h11? color.yellow : color.orange
hma_h11=plot(n1_h11, "Hull MA 800", color=c_h11)

