Make The Hull MA Into A Strategy

stone

Member
I'm so impressed with you coders. Can a strategy be made for the Hull Moving Average?
 
Last edited by a moderator:
Solution
@mansor
Here is the script that prints an arrow on the UP and Down condition as you requested:
Ruby:
plot UpArrow = HMA > HMA[1] ;
plot DnArrow = HMA <= HMA[1] ;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
It results in a chart that looks like:
8D3FkSC.png


That is a lot of arrows.
Perhaps it would be better if the arrows are defined as triggering only on the change of trend?

SkHvnzP.png

Ruby:
plot UpArrow = if HMA[1]<HMA[2] and HMA > HMA[1] then HMA else double.NaN ;
plot DnArrow = if HMA[1]>HMA[2] and HMA < HMA[1] then HMA else double.NaN...
Last edited:
Hi @MerryDay

I am trying to make a scanner based on mtf hma. I can't seem to get to set a condition where "UP is true" is scannable.

Below is the code for the indicator:




Code:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


 declare lower;
#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));

 
input length =10;
def displace = 0;

plot HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));
 
Hi @MerryDay

I am trying to make a scanner based on mtf hma. I can't seem to get to set a condition where "UP is true" is scannable.

Below is the code for the indicator:




Code:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


 declare lower;
#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));

 
input length =10;
def displace = 0;

plot HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));

can't usd 2nd aggregation in scans
https://usethinkscript.com/threads/...t-scanner-based-on-daily-atr.8528/#post-79595
 
I understand, however, if I change the aggregation & set it to "day" & change the setting to "day" in the scanner (after adding this script as study) I do get the options under edit conditions; "is true", "is below", "is above" with "hma" as the only plot & not the arrows "up" "down" is "is true", you know what I mean. I need the arrows to show up besides just "hma" in plot in the scanner.
 
Last edited:
@mansor
Here is the script that prints an arrow on the UP and Down condition as you requested:
Ruby:
plot UpArrow = HMA > HMA[1] ;
plot DnArrow = HMA <= HMA[1] ;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
It results in a chart that looks like:
8D3FkSC.png


That is a lot of arrows.
Perhaps it would be better if the arrows are defined as triggering only on the change of trend?

SkHvnzP.png

Ruby:
plot UpArrow = if HMA[1]<HMA[2] and HMA > HMA[1] then HMA else double.NaN ;
plot DnArrow = if HMA[1]>HMA[2] and HMA < HMA[1] then HMA else double.NaN;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;
UpArrow.SetLineWeight(3);

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
DnArrow.SetLineWeight(3);
OR To save on real estate, it can be plotted as an upper chart:
KRMWGyt.png

Ruby:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));
def Approx200 = x /100 * close ;

 
input length =10;
def displace = 0;

def HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

plot UpArrow = if HMA[1]<HMA[2] and HMA > HMA[1] then low else double.NaN ;
plot DnArrow = if HMA[1]>HMA[2] and HMA < HMA[1] then high else double.NaN;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;
UpArrow.SetLineWeight(3);

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
DnArrow.SetLineWeight(3);


To give back to the community, would you post your chart and explain how this helps your trading?
 
Last edited:
Solution
@mansor
Here is the script that prints an arrow on the UP and Down condition as you requested:
Ruby:
plot UpArrow = HMA > HMA[1] ;
plot DnArrow = HMA <= HMA[1] ;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
It results in a chart that looks like:
8D3FkSC.png


That is a lot of arrows.
Perhaps it would be better if the arrows are defined as triggering only on the change of trend?

SkHvnzP.png

Ruby:
plot UpArrow = if HMA[1]<HMA[2] and HMA > HMA[1] then HMA else double.NaN ;
plot DnArrow = if HMA[1]>HMA[2] and HMA < HMA[1] then HMA else double.NaN;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;
UpArrow.SetLineWeight(3);

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
DnArrow.SetLineWeight(3);
OR To save on real estate, it can be plotted as an upper chart:
KRMWGyt.png

Ruby:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));
def Approx200 = x /100 * close ;

 
input length =10;
def displace = 0;

def HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

plot UpArrow = if HMA[1]<HMA[2] and HMA > HMA[1] then low else double.NaN ;
plot DnArrow = if HMA[1]>HMA[2] and HMA < HMA[1] then high else double.NaN;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;
UpArrow.SetLineWeight(3);

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
DnArrow.SetLineWeight(3);


To give back to the community, would you post your chart and explain how this helps your trading?
@MerryDay thanks for taking the time to produce these variations.

I am trying to use the initial script (post #3) in a scanner.

When I install it as a custom study, having the script agg & scanner agg aligned, it works. However, "under edit conditions" plot is just showing "hma" & arrows can't be selected. So I want the condition to show "up" is true.

thanks again for taking the time
 
I am trying to use the initial script (post #3) in a scanner.

When I install it as a custom study, having the script agg & scanner agg aligned, it works. However, "under edit conditions" plot is just showing "hma" & arrows can't be selected. So I want the condition to show "up" is true.

thanks again for taking the time
It works fine for me. By definition, all plots statements show up in the scanner. So if you cannot select the arrows you are not referencing the study with the arrows in it.
LzmtBsD.png


Ruby:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


 declare lower;
#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));

 
input length =10;
def displace = 0;

plot HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));

plot UpArrow = HMA > HMA[1] ;
plot DnArrow = HMA <= HMA[1] ;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
 
It works fine for me. By definition, all plots statements show up in the scanner. So if you cannot select the arrows you are not referencing the study with the arrows in it.
LzmtBsD.png


Ruby:
input agg = AggregationPeriod.day ;
def c = close(period = agg);
def h = high(period = agg);


 declare lower;
#100 * (h / AVGC200)
def x=100 * (h / Average(length = 200, data = c));

 
input length =10;
def displace = 0;

plot HMA = MovingAverage(AverageType.wEIGHTED, x, length)[-displace];

HMA.DefineColor("Up", GetColor(1));
HMA.DefineColor("Down", GetColor(0));
HMA.AssignValueColor(if HMA > HMA[1] then HMA.color("Up") else HMA.color("Down"));

plot UpArrow = HMA > HMA[1] ;
plot DnArrow = HMA <= HMA[1] ;

UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_up);
UpArrow.SetDefaultColor(color.blue) ;

DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_down);
DnArrow.SetDefaultColor(color.magenta) ;
Hi MerryDay, first thank you for the infos. would you please be able to post the pictures for the custom study steps? thanks again
 
Hi MerryDay, first thank you for the infos. would you please be able to post the pictures for the custom study steps? thanks again
Step one: cut&pasted the script in your post.
(don't know how to cut&paste a study, here are directions: https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
Step two: click on Scan Hacker
Step three: click on the pencil
Step four: click on the thinkscript editor tab
Step five: type in the name you just gave the study
Step six: append the following to the name you just typed in: ()."UpArrow" is true
4H7hJUT.png
 
Step one: cut&pasted the script in your post.
(don't know how to cut&paste a study, here are directions: https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/
Step two: click on Scan Hacker
Step three: click on the pencil
Step four: click on the thinkscript editor tab
Step five: type in the name you just gave the study
Step six: append the following to the name you just typed in: ()."UpArrow" is true
4H7hJUT.png
Thanks fr the reply. tell me if i did it right please.
study : custom , Creat condition: study: Pulled my study name : offset0" plot uparrow"agg day:length 10 MIDDLE BOX = is true Save
 
Thanks fr the reply. tell me if i did it right please.
study : custom , Creat condition: study: Pulled my study name : offset0" plot uparrow"agg day:length 10 MIDDLE BOX = is true Save
Please edit your post to include an image of your scanner. Make sure it looks just like my image.
Unsure of how to upload screenshots to the forum, Here are directions.
 

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
490 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