mohamed982

Hull MA

14249 lượt xem
2211
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
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)


Bình luận

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!
+12 Phản hồi
@p298,
Hello , All you need to do is to just copy my script that calculates the HMA without hving to worry about the math stuff . generally HMA is based on weighted MA . any way start copying from the second line n=input …… all the way down to n2 >>>>>> Then compare the values of n2 against n1 . like this way
strategy(n1>n2 , long)
strategy(n2>n1 , short)
Compare values don't look at colors , colors are just for visual representation of signal
+3 Phản hồi
Your Hull MA is the best !! Try to daytrade US stock with this one, give the better result .
+6 Phản hồi
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?
+3 Phản hồi
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
Phản hồi
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
Phản hồi
pmcrypto mohamed982
@mohamed982, Thanks man! I was trying to understand the code and this was throwing me off :)
Phản hồi
hi, thanks for sharing
can i ask u about my beginning in pine script?
+2 Phản hồi
mohamed982 polo974
@polo974,
Hi Pole , pine script langue is relatively easy if you have basic knowledge of programming with any other programming lanuge . however if you don't have any experience yet it's easy . please refer to pice script tutorials and you will find all what you need . this is how I learerned it
+2 Phản hồi
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 Phản hồi