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) ;
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...
Can a strategy be made for the Hull Moving Average?
Read more: https://usethinkscript.com/resources/thinkscript-addorder-turn-a-study-into-a-strategy.15/def BuyTrigger = however you define your buy signal ;
def SellTrigger = however you define your sell signal ;
AddOrder(OrderType.BUY_AUTO, BuyTrigger );
AddOrder(OrderType.Sell_AUTO, SellTrigger );
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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"));
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.can't usd 2nd aggregation in scans
https://usethinkscript.com/threads/...t-scanner-based-on-daily-atr.8528/#post-79595
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) ;
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);
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);
@MerryDay thanks for taking the time to produce these variations.@mansor
Here is the script that prints an arrow on the UP and Down condition as you requested:
It results in a chart that looks like: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) ;
That is a lot of arrows.
Perhaps it would be better if the arrows are defined as triggering only on the change of trend?
OR To save on real estate, it can be plotted as an upper chart: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);
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?
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.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
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 againIt 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.
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) ;
Step one: cut&pasted the script in your post.Hi MerryDay, first thank you for the infos. would you please be able to post the pictures for the custom study steps? thanks again
Thanks fr the reply. tell me if i did it right please.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
Please edit your post to include an image of your scanner. Make sure it looks just like my image.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.will do, thanks!
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
R | Need Help: Hull Di+ Di- Strategy | Questions | 3 | |
A | Create a custom strategy from Hull moving average | Questions | 29 | |
Help with Adding 5 min plots for this 2 minute Hull MA? | Questions | 5 | ||
Hull MAs Crossover | Questions | 4 | ||
C | MTF with Hull MA | Questions | 6 |
Start a new thread and receive assistance from our community.
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.
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.