Hull MAs Crossover

Scrambledeggs

New member
Hi, This is my first request for help with a script, but it should be an easy one for most you. I would like a crossover alert. I use 2 Hull MAs in the price chart. One set to default with a length of 30 and the other with a length of 20, up color is green and down color is orange. An option for an alert at the crossover. That's it. Please help. Thanks.
 
Solution
Hi, This is my first request for help with a script, but it should be an easy one for most you. I would like a crossover alert. I use 2 Hull MAs in the price chart. One set to default with a length of 30 and the other with a length of 20, up color is green and down color is orange. An option for an alert at the crossover. That's it. Please help. Thanks.

something like this ?

Code:
# hull_avg_cross

#https://usethinkscript.com/threads/hull-mas-crossover.16698/
#Hull MAs Crossover

def na = Double.NaN;
def bn = BarNumber();
def price = close;

input show_lines = yes;
input show_arrows = yes;
input enable_crossing_alerts = yes;

input ma1_len = 20;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.HULL;
def...
Hi, This is my first request for help with a script, but it should be an easy one for most you. I would like a crossover alert. I use 2 Hull MAs in the price chart. One set to default with a length of 30 and the other with a length of 20, up color is green and down color is orange. An option for an alert at the crossover. That's it. Please help. Thanks.

something like this ?

Code:
# hull_avg_cross

#https://usethinkscript.com/threads/hull-mas-crossover.16698/
#Hull MAs Crossover

def na = Double.NaN;
def bn = BarNumber();
def price = close;

input show_lines = yes;
input show_arrows = yes;
input enable_crossing_alerts = yes;

input ma1_len = 20;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.HULL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 30;
input ma2_type =  AverageType.HULL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


plot z1 = if show_lines and ma1_len > 0 then ma1 else na;
z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();

plot z2 = if show_lines and ma2_len > 0 then ma2 else na;
z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

def xup = ma1 crosses above ma2;
def xdwn = ma1 crosses below ma2;

plot zup = if xup and show_arrows then low * 0.9995 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if xdwn and show_arrows then high * 1.0005 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();


# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert((enable_crossing_alerts and xup), "crossed up" ,alert.BAR, sound.DING);
alert((enable_crossing_alerts and xdwn), "crossed down" ,alert.BAR, sound.bell);
#
 
Solution
something like this ?

Code:
# hull_avg_cross

#https://usethinkscript.com/threads/hull-mas-crossover.16698/
#Hull MAs Crossover

def na = Double.NaN;
def bn = BarNumber();
def price = close;

input show_lines = yes;
input show_arrows = yes;
input enable_crossing_alerts = yes;

input ma1_len = 20;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.HULL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 30;
input ma2_type =  AverageType.HULL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


plot z1 = if show_lines and ma1_len > 0 then ma1 else na;
z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();

plot z2 = if show_lines and ma2_len > 0 then ma2 else na;
z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

def xup = ma1 crosses above ma2;
def xdwn = ma1 crosses below ma2;

plot zup = if xup and show_arrows then low * 0.9995 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if xdwn and show_arrows then high * 1.0005 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();


# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert((enable_crossing_alerts and xup), "crossed up" ,alert.BAR, sound.DING);
alert((enable_crossing_alerts and xdwn), "crossed down" ,alert.BAR, sound.bell);
#
Hi, Thanks for the code. I will check it out now.
John S
 
something like this ?

Code:
# hull_avg_cross

#https://usethinkscript.com/threads/hull-mas-crossover.16698/
#Hull MAs Crossover

def na = Double.NaN;
def bn = BarNumber();
def price = close;

input show_lines = yes;
input show_arrows = yes;
input enable_crossing_alerts = yes;

input ma1_len = 20;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.HULL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 30;
input ma2_type =  AverageType.HULL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


plot z1 = if show_lines and ma1_len > 0 then ma1 else na;
z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();

plot z2 = if show_lines and ma2_len > 0 then ma2 else na;
z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

def xup = ma1 crosses above ma2;
def xdwn = ma1 crosses below ma2;

plot zup = if xup and show_arrows then low * 0.9995 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if xdwn and show_arrows then high * 1.0005 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();


# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert((enable_crossing_alerts and xup), "crossed up" ,alert.BAR, sound.DING);
alert((enable_crossing_alerts and xdwn), "crossed down" ,alert.BAR, sound.bell);
#
Thanks, It looks good. I will try and tweak it to get the other 2 colors used for direction. Also, both moving averages price should be based off VWAP. I will let you know how I do.
John S
 
something like this ?

Code:
# hull_avg_cross

#https://usethinkscript.com/threads/hull-mas-crossover.16698/
#Hull MAs Crossover

def na = Double.NaN;
def bn = BarNumber();
def price = close;

input show_lines = yes;
input show_arrows = yes;
input enable_crossing_alerts = yes;

input ma1_len = 20;
#input ma1_type =  AverageType.EXPONENTIAL;
input ma1_type =  AverageType.HULL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input ma2_len = 30;
input ma2_type =  AverageType.HULL;
def ma2 = MovingAverage(ma2_type, price, ma2_len);


plot z1 = if show_lines and ma1_len > 0 then ma1 else na;
z1.SetDefaultColor(GetColor(1));
#z1.setlineweight(1);
z1.HideBubble();

plot z2 = if show_lines and ma2_len > 0 then ma2 else na;
z2.SetDefaultColor(GetColor(2));
#z2.setlineweight(1);
z2.HideBubble();

def xup = ma1 crosses above ma2;
def xdwn = ma1 crosses below ma2;

plot zup = if xup and show_arrows then low * 0.9995 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if xdwn and show_arrows then high * 1.0005 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();


# Sound.Ding,  higher , up sound
# Sound.Bell,  lower , down sound
alert((enable_crossing_alerts and xup), "crossed up" ,alert.BAR, sound.DING);
alert((enable_crossing_alerts and xdwn), "crossed down" ,alert.BAR, sound.bell);
#
Hi, Code works great. I changed "def price=close" to "def price=vwap". Then I changed the transparency of the colors of the lines to 100%. Now I was able to show plot of the original Hull MAs. with the different colors and still hear the alert. Works great on any time frame for the QQQs.
Thanks for your help.
John S
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
405 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top