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

Repaints
Status
Not open for further replies.
Okay it just erased one. "/ES" at the 11:03am on the 1 min chart, the bar closed and it gave a buy signal, than as the bar was moving and went the other direction on the 11:04 am bar the signal is now gone from the 11:03am bar. The MA part of this regardless if on mobile or pc it will in fact change what it printed on prior bars. Mobile has the same issue.
 
@toopoor88 You are right! I spotted 2!! Max appeared after 1 candle closed, but the signal then disappeared as the 2nd following candle is forming. Once it goes against the direction of the Max, the 1st candle Max signal disappeared! However, the HMA lines did not change colour yet.
I think this script needs the 2nd candle to form completely before confirming the 1st Max signal?
Also to add, 7 signals did not repaint and stayed. Only 2 disappeared over the past 6 hours. Eyes are killing me.
@mashume can you confirm?
@YungTraderFromMontana something to take note of.
 
This is likely super basic to most of you expert traders here. But I just wanted to give something back to the community since its been such a great value for me so far. On the 5 min chart, volume average at the default 50 period filters out most of the false signals with this indicator . The two in combination , along with common sense of course, can be a "one stop shop" for all your trading needs. Good luck to all next week.
@technicallydreaming Can you be more clear and state where you're seeing the option to change to 50 period volume average on this indicator...because all I am seeing is HMA length which is set to 21 and look back set to 2. Not seeing where you can even change the volume average. Thanks.
 
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);


hmm i just tried this code but i think there's something wrong, nothing is showing up.
Capture.jpg
 
this is weird, the alert don't work on max and min. anyone can verify?
And btw, on mobile will also repaint.
 
Last edited:
It seems regarding the repaint issues, it depends on the bar after the arrow signal bar............if the prices go wayward then the signal disappears etc.

Any backtesting should be done only on the closing price of the bar after the signal bar. Many a times too much price movement has already taken place by the end of the "next" bar.
 
This indicator cannot be used in its current form. The signal changes or decided after the fact.

It can be in combination to other tools and indicators. If the price of the "next" bar after the "arrow/signal" bar has not moved by much then there is no repainting. Most important thing of this indicator is the "confidence boost" that it gives you while in the trade, especially for those who trade manually and not use any algo.
 
@mashume By any chance you can make the lower study plot arrow/dot/etc on the price chart when the Divergence line crosses the zero line in the lower study?
 
@mashume By any chance you can make the lower study plot arrow/dot/etc on the price chart when the Divergence line crosses the zero line in the lower study?

Sorry, I'm not sure how to have a lower study plot on the upper. I'm not even sure it's possible. You can run two studies with identical settings and only have the Concavity upper plot buy and sell signals (they should coincide with the crossovers on the lower)

-mashume
 
Sorry, I'm not sure how to have a lower study plot on the upper. I'm not even sure it's possible. You can run two studies with identical settings and only have the Concavity upper plot buy and sell signals (they should coincide with the crossovers on the lower)

-mashume

Actually, that was what I did. I place a copy of the indicator in the upper study. I didn’t like the zeroline and the divergence line plotting across the middle of my price chart so I replaced “plot””with “def” in the code for the zero line and the divergence line. After I had done that, nothing was showing.

--EDITED--

Nevermind. I figured it out. Under the plots for cx_up and cx_down, I had to replace "0" with "price" when the condition is true so tht it shows the arrows at the 'price' instead of at '0'.
 
Last edited:
Actually, that was what I did. I place a copy of the indicator in the upper study. I didn’t like the zeroline and the divergence line plotting across the middle of my price chart so I replaced “plot””with “def” in the code for the zero line and the divergence line. After I had done that, nothing was showing.

Couldn't tell if you got it working or not.
Try this:
I've only hacked it in a text editor, not in thinkorswim as it's not logging me in at the moment. Down for updates perhaps.

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

declare upper;

input price = HL2;

input HMA_length = 55;
input lookback = 2;

def 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;

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

plot cx_up = if divergence crosses above 0 then LOW else double.nan;
cx_up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
cx_up.SetDefaultColor(Color.LIGHT_GREEN);
cx_up.SetLineWeight(3);

plot cx_down = if divergence crosses below 0 then HIGH else double.nan;
cx_down.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
cx_down.SetDefaultColor(Color.RED);
cx_down.SetLineWeight(3);

mashume
 
I actually posted my edit right before you posted your reply. I got it working. LOW and HIGH make sense. More than one way to skin a cat I guess. Thanks!
 
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
353 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