Repaints Hull Moving Average Turning Points and Concavity (2nd Derivatives)

Repaints
Status
Not open for further replies.
@mashume I've done some basic back testing, using instead MA_Min as a Buy and MA_Max as a sell signal, with Close and 21 length. Seems pretty good so far. Have you tried back testing with those? What are your thoughts on using those MAs as signals?

Thanks again for all your effort and time!
 
manual eye back test Friday market on futures.
Singular ticker purely using concavity total possible trades at 31 = 8 losses vs. 23 wins.
25% of the time lose vs. 75% wins of the time.
Combined with AMM. only 3 trades in 1 day, but 100% win.
This isn't the holy grail, but it's close. You just need other signals to support the move.
A pity the HMA colors don't work on mobile.
 
Now that the busy week is over and great trading I had free time to test out version 3 of this. Glad to see it no longer has the 1-3 bar delay in printing. Love you kept my request to have alerts in :) . So far I think it's pretty nice indicator if you want to quickly see where the market it is. Tomorrow will look more into it but good work.
 
manual eye back test Friday market on futures.
Singular ticker purely using concavity total possible trades at 31 = 8 losses vs. 23 wins.
25% of the time lose vs. 75% wins of the time.
Combined with AMM. only 3 trades in 1 day, but 100% win.
This isn't the holy grail, but it's close. You just need other signals to support the move.
A pity the HMA colors don't work on mobile.

Yep. Shame. That's why I put together the lower study. It graphs the change in slope of the HMA, so that zero crossings on the lower are the concavity changes shown on the HMA upper. Same data, different way to view it. when the lower goes from negative to positive, the concavity has changed. I have both on mobile, and it seems to work OK. Not perhaps as artistically satisfying, but then I do like the Bauhaus ethic of form following function.

As a bonus, the lower can give you a preview of when things might be approaching a concavity shift, and how quickly or perhaps decisively they are crossing.

mashume
 
Just skimmed chat but if you want to change colors in a mobile version, write 2 different conditions for the colors.
ex
plot upCond = If(Value>Value[1], Value, Double.NaN);
plot dnCond = If(Value<Value[1], Value, Double.NaN);
upCond.SetDefaultColor(Color.CYAN);
dnCond.SetDefaultColor(Color.MAGENTA);

then in the mobile app, just assign a different color to each plot and this is what you get:
513033C9-F8D5-4B6C-86E1-32E6AD40348F.jpeg
 
Last edited:
@amalia

Great idea!
This is why I like to share things here at usethinkscript. Feedback that's constructive, and great extension ideas.

This code will apply (or set you up to apply) colors to all four conditions of the HMA line

Code:
plot CCD_D = if concavity == -1 and HMA < HMA[1] then HMA else double.nan;
CCD_D.SetDefaultColor(Color.RED);
CCD_D.SetLineWeight(3);

plot CCD_I = if concavity == -1 and HMA >= HMA[1] then HMA else double.nan;
CCD_I.SetDefaultColor(Color.DARK_ORANGE);
CCD_I.SetLineWeight(3);

plot CCU_D = if concavity == 1 and HMA <= HMA[1] then HMA else double.nan;
CCU_D.SetDefaultColor(COLOR.DARK_GREEN);
CCU_D.SetLineWeight(3);

plot CCU_I = if concavity == 1 and HMA > HMA[1] then HMA else double.nan;
CCU_I.SetDefaultColor(COLOR.GREEN);
CCU_I.SetLineWeight(3);

It leaves an annoying gap in the HMA line at some points around turning points, but the turning point plot itself is undisturbed. I just appended this to the end of the study and turned off the HMA plot. Instant colors on mobile.

:)

-Mashume

P.S.
CCD = concave down
CCU = concave up
I = increasing
D = decreasing

Also,

What is the other indicator you're using to draw horizontal lines?
 
I opted for the ConcavityDivergence code, as it's more compact and has a plot that's more easily accessed for this purpose. Watchlist Column coloured to match the indicator. I think. :)

Code:
script ConcavityDivergence {
# 
# Hull Moving Average Concavity Divergence
#  or
# The Second Derivative of the Hull Moving Average
# 
# Author: Seth Urion (Mahsume)
# Version: 2020-02-23 V3
# Watchlist Column 2020-03-06 V2
# 
# This code is licensed (as applicable) under the GPL v3
# 
# ----------------------

declare lower;

input price = HL2;

input HMA_length = 55;
input lookback = 2;

plot HMA = HullMovingAvg(length = HMA_length, price = price);

def delta = HMA[1] - HMA[lookback + 1];
def delta_per_bar = delta / lookback;

def next_bar = HMA[1] + delta_per_bar;

def concavity = if HMA > next_bar then 1 else -1;

plot zero = 0;
zero.setdefaultcolor(Color.LIGHT_GRAY);
zero.setpaintingstrategy(PaintingStrategy.DASHES);

plot divergence = HMA - next_bar;
divergence.setDefaultColor(Color.LIME);
divergence.SetLineweight(2);

plot cx_up = if divergence crosses above zero then 0 else double.nan;
cx_up.SetPaintingStrategy(PaintingStrategy.POINTS);
cx_up.SetDefaultColor(Color.LIGHT_GREEN);
cx_up.SetLineWeight(4);

plot cx_down = if divergence crosses below zero then 0 else double.nan;
cx_down.SetPaintingStrategy(PaintingStrategy.POINTS);
cx_down.SetDefaultColor(Color.RED);
cx_down.SetLineWeight(4);

plot good_momentum = 0.32 * highest(divergence, HMA_Length * 2);
good_momentum.SetPaintingStrategy(PaintingStrategy.LINE);
good_momentum.SetStyle(Curve.SHORT_DASH);
good_momentum.SetDefaultColor(Color.GREEN);

plot bad_momentum = 0.32 * lowest(divergence, HMA_Length * 2);
bad_momentum.SetPaintingStrategy(PaintingStrategy.LINE);
bad_momentum.SetStyle(Curve.SHORT_DASH);
bad_momentum.SetDefaultColor(Color.RED);


}
plot data = ConcavityDivergence().divergence;
def HMA = ConcavityDivergence().HMA;

data.AssignValueColor(if  data > data[1] then Color.BLACK else Color.WHITE);
AssignBackgroundColor(if data >= 0 then if HMA > HMA[1] then Color.GREEN else Color.DARK_GREEN else if HMA > HMA[1] then color.DARK_ORANGE else color.DARK_RED);
 
Last edited:
Wow you truly are a wizard @mashume !! Thanks a million! My original intention was to have it match the upper indicator, but I really don't wanna ask too much. This gives me an idea of ones at least approaching that (if i understand it correctly)
 
Last edited:
Does anyone know how to remove the values from the watchlist script ? That way I could just have colors on the watchlist and sort by green to red.
Right now, with the values, it sorts by measure of how drastically the curve is bending. the larger the value the more it's curving. very small values indicate lack of will to turn. very large values (both positive and negative) indicate radical turns.

-mashume
 
manual eye back test Friday market on futures.
Singular ticker purely using concavity total possible trades at 31 = 8 losses vs. 23 wins.
25% of the time lose vs. 75% wins of the time.
Combined with AMM. only 3 trades in 1 day, but 100% win.
This isn't the holy grail, but it's close. You just need other signals to support the move.
A pity the HMA colors don't work on mobile.
What settings and timeframe did you backtest? Thanks
 
@mashume If I am not asking for too much, can you update the 1st post in this thread with the latest version of indicator, scan and watchlist code. It will be easy for anyone to try. Thanks for building and sharing this selflessly.
 
@amalia

Great idea!
This is why I like to share things here at usethinkscript. Feedback that's constructive, and great extension ideas.

This code will apply (or set you up to apply) colors to all four conditions of the HMA line

Code:
plot CCD_D = if concavity == -1 and HMA < HMA[1] then HMA else double.nan;
CCD_D.SetDefaultColor(Color.RED);
CCD_D.SetLineWeight(3);

plot CCD_I = if concavity == -1 and HMA >= HMA[1] then HMA else double.nan;
CCD_I.SetDefaultColor(Color.DARK_ORANGE);
CCD_I.SetLineWeight(3);

plot CCU_D = if concavity == 1 and HMA <= HMA[1] then HMA else double.nan;
CCU_D.SetDefaultColor(COLOR.DARK_GREEN);
CCU_D.SetLineWeight(3);

plot CCU_I = if concavity == 1 and HMA > HMA[1] then HMA else double.nan;
CCU_I.SetDefaultColor(COLOR.GREEN);
CCU_I.SetLineWeight(3);

It leaves an annoying gap in the HMA line at some points around turning points, but the turning point plot itself is undisturbed. I just appended this to the end of the study and turned off the HMA plot. Instant colors on mobile.

:)

-Mashume

P.S.
CCD = concave down
CCU = concave up
I = increasing
D = decreasing

Also,

What is the other indicator you're using to draw horizontal lines?


insideBar study = )
 
Status
Not open for further replies.

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