mohamed982

Hull MA

4637 views
1506
4637 15
Remove from Favorite Scripts Add to Favorite Scripts
study("HullMA",overlay=true)
n=input(title="period",type=integer,defval=16)


n2ma=2*wma(close,round(n/2))
nma=wma(close,n)
diff=n2ma-nma
sqn=round(sqrt(n))


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


n1=wma(diff,sqn)
n2=wma(diff1,sqn)
c=n1>n2?green:red
ma=plot(n1,color=c)


Hey! Why does the hull ma change from red to green back to red. What moving average crosses are they to have them switch colors? I am trying to code a bot that buys when the hullma is green and sells when the hullma is red, and was wondering which moving averages cause them to change colors. Thanks!
Reply
great indicator. Thank you. Question: If I wanted to add a LONG alert condition to an existing script in which the alert fires ONLY IF the Candle Opening price is BELOW the HMA, or ONLY if the HMA is showing GREEN, do you have any guidance for this? I'm new to coding and can't seem to figure it out
Reply
hello, what is the purpose of line 14 in your code? I don't see the variable sqn1 being used anywhere. Should it be in line 18 instead of sqn?
+1 Reply
mohamed982 pmcrypto
@pmcrypto, are you interested in coding or in using the Indicator ? heheheheheh . and line 14 sqn stands for the square root of n . but you know you are right i didn't use it i don't know why i created this variable , but this is how the average is calculated we always use SQR
Reply
mohamed982 pmcrypto
@pmcrypto, and actually yea it should have been placed on line 18 , but if you notice both sqn & sqn1 are the square root of the same number which is n so they are equal , that is why i just ignored using it again and instead used sqn for consistency
Reply
pmcrypto mohamed982
@mohamed982, Thanks man! I was trying to understand the code and this was throwing me off :)
Reply
Is it possible to get this indicator for metatrader? I use it everyday that I trade. This is the best indicator I have used since I discovered Bollinger Bands!!
+1 Reply
@jamjan33, Did you ever get an answer for this? I really really like the single color changing line but cant seem to find anything similar for my MT4 chart.....
Reply
mohamed982 Mactormind
@Mactormind, it's easy to do for MT4
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Get Help Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing TradingView Coins My Support Tickets Get Help Ideas Published Followers Following Private Messages Chat Sign Out