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

M

mashume

Active member
Try this, you're script is a bit out of date

Code:
script ConcavityDivergence {
#
# Hull Moving Average Concavity Divergence
#  or
# The Second Derivative of the Hull Moving Average
#
# Author: Seth Urion (Mahsume)
# Version: 2020-03-23 V4
#
# 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;
plot next_bar = HMA[1] + delta_per_bar;

plot concavity = if HMA > next_bar then 1 else -1;
}

def signal = ConcavityDivergence("hma length" = 55)."concavity";
def HMA = ConcavityDivergence("hma length" = 55)."HMA";
def next = ConcavityDivergence("hma length" = 55)."next_bar";

plot buy = signal < 0 and (HMA - next) > (HMA[1] - next[1]);

This is a hacked down version just for a scanner. Don't use this script as a plotting indicator.
-mashume
 
Last edited:
M

mashume

Active member
Are the values in this script set up for daily
In the SCAN tab, if you click the pencil for the line with the custom script on it, at the top left of the popup is an AGGREGATION dropdown. You can pick your aggregation period there.

:)

mashume
 
madeinnyc

madeinnyc

Member
@mashume ....the last version for the upper study I have is: Version: 2020-02-21 Initial Public.
Is that still the current Upper study?
 
M

mashume

Active member
@madeinnyc
The current version is Version: 2020-02-23 V3
You can find the code in post 1 of this thread.

I'm not sure whether the shared link is up to date (I'm fairly sure it's not), but the code is. Copy and paste it over the code in the indicator and you should be good.

mashume
 
T

tem2005

New member
Warehouse
VIP
@mashume are there major difference between the versions? Because i use the first one
 
B

bobomatic

New member
Watchlist code in post #94 is not working for me. All I get is dark green for all securities in my watchlist. It doesn't sync with the upper code. BTW, awesome code.

 
Last edited by a moderator:
M

mashume

Active member
@bobomatic
That is odd. They work for me. Do check that the aggregation period
1. set it by clicking the gear icon in your watchlist,
2. select 'customize...'
3. click the scroll next to Concavity and then
4. select the period to match your chart (or whatever you'd like it to be) from the dropdown at the top left of the script window.

If it still isn't working for you, we can try some further investigation. The values it's showing seem kinda big for some reason. You can also try pasting this code into that script window from step 4. I modded the text colors to be clearer, and multiplied the number displayed by a large factor to make it more human readable (fewer 0.0 kind of things, as the numbers can be REALLY small... 5x10^-5)

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-24 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 * 10000;
def HMA = ConcavityDivergence().HMA;

data.AssignValueColor(if data >= 0 then if HMA > HMA[1] then Color.BLACK else Color.WHITE else if HMA > HMA[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);
 
M

mashume

Active member
@mashume are there major difference between the versions? Because i use the first one
The largest difference is that the original version compared the current bar to the next bar. The current version compares the current bar to the last bar. It's a minor technical niggle, but it seemed to speed up the response for whatever reason. If you're happy with the signals from the Inital Public V1, you're welcome to continue using it. There are no fundamental changes to the nature of the indicator.

mashume
 
B

bobomatic

New member
@mashume It was a period problem. Had the wrong value in there, duh. Working great now. Very much appreciated!
 
M

mailbagman2000

New member
@asragov et al,
Links to new (faster versions):

UPPER
http://tos.mx/ljjgn40

LOWER
http://tos.mx/Y8VY8RA

Upper includes alert, lower does not.

@codydog, thank you for your kind words. I'm intrigued with the Leavitt Convolution... Homework. :) I do this a lot for the maths I'm afraid. It means a lot that the tool I've shared here is both somewhat useful, but also extensible -- that the math behind it works given any reasonable input.

SCANS
AFTER loading the new versions, and being careful with the names. %-\ You should be able to create new filter scans.
In the scans tab:
  1. Add a Filter
  2. Choose Study
  3. In the left-most dropdown which defaults to ADX Crossover or something select Custom...
  4. Click ThinkScript Editor near the top of the window
  5. Paste this code:
Code:
Concavity("hma length" = 55)."buy" is true within 1 bars
or this code:

Code:
def signal = ConcavityDivergence("hma length" = 55)."concavity";
def HMA = ConcavityDivergence("hma length" = 55)."HMA";
def next = ConcavityDivergence("hma length" = 55)."next_bar";

plot buy = signal < 0 and (HMA - next) > (HMA[1] - next[1]);
Adjust as needed. The second won't show you things that are at a BUY, it shows things that currently have negative concavity, but the moving in a direction that may signal a buy sooner or later (if at all, of course).

Good Luck, and Happy Trading.
Mashume
Says Concavity ("hma length") =55 is invalid
 
M

mashume

Active member
@mailbagman2000
The code I have in my scanner looks like this:

Code:
Concavity("price" = close, "hma length" = 55)."buy" is true
You may adjust close to be HL2 or whatever suits you. The important thing, I think from your last post, is that all the parameters are inside the parenthesis.

Hope that helps.

-mashume
 
J

JB7

New member
Has anyone made any money on this (even paper money is good), Would you be kind enough to share your exact process and entry & exit steps. Also share any specific settings/setup with which you have been able to avoid "multiple quick entry and exit signals in the consolidation phase".
Please share only if you have practised it in realtime and have found consistent profit
P.S Refrain from posting any theoretical systems or hypothetical examples.
 
C

codydog

Member
Has anyone made any money on this (even paper money is good), Would you be kind enough to share your exact process and entry & exit steps. Also share any specific settings/setup with which you have been able to avoid "multiple quick entry and exit signals in the consolidation phase".


P.S Refrain from posting any theoretical systems or hypothetical examples.
@mashume

@JB7 - I use it in conjunction with zscore and it works well. Its not a stand alone tool though.

My style is much more short term, higher trade volume than many others. I also consider break even trades important versus the traditional win/loss many folks go on and on about. I refer you to Greg Laughlin's comment "Insights into high frequency trading...", esp page 3 table for more background.

I use it on a 1 day, 2 min chart, with -
hma length = 13, lookback =1,

I also switched from HMA to EHMA.

imo, if any of the "gurus" try to sell you their stuff, and say how rich they are from using any indicator, I'd ask for their 1040, signed by a reputable CPA firm. And same for me, I may think I know what I'm doing or I may be Bozo's first cousin - you simply don't know - so massive grain of salt with my comments and never forget its your money.

Happy trading!
 
T

Trader Raider

Member
VIP
imo, if any of the "gurus" try to sell you their stuff, and say how rich they are from using any indicator, I'd ask for their 1040, signed by a reputable CPA firm. And same for me, I may think I know what I'm doing or I may be Bozo's first cousin - you simply don't know - so massive grain of salt with my comments and never forget its your money.
Those are important points, @codydog! When I was a newb, I got caught up in the hype of making big money and listening to "gurus." What I learned (after losing a lot of money, LOL) was that there is no substitute for learning market basics, price action, etc. Maybe other newbs are smarter than I was and can make money applying someone else's trading system. I couldn't do it. I had to study price action and then watch charts for months and months to build a trading plan around aspects of price movement that I could see and understand.
 
B

bobomatic

New member
@JB7 I use it quite a bit to confirm my other signals. It's usually spot on. I like it a lot. I concur with what was mentioned above. We're all different so we're gonna pull the trigger differently so I use it in my own personal way. It doesn't work well in channels, but I don't know what indicator does. I paid dearly for my trading education having lost quite a bit in my early years, but I survived and now I'm consistently profitable. It was more about learning who I was rather than the market. I can highly recommend this indicator in parallel with a confirming signal or good 'ol price action if you have the experience.
 
T

Trader Raider

Member
VIP
It was more about learning who I was rather than the market.
Well said! Boy, did I have to learn about myself too! I was impulsive and not waiting for a good entry. Greed prompted me to overtrade and lose. Arrogance made me revenge trade and lose even more. Laziness kept me from holding myself accountable with a trade journal. For me, the hardest part of trading has been self-discipline. Maybe others don't find it an issue, but I have been my own worst enemy.
 
A

Aeteux

New member
@codydog If you don't mind sharing, how did you switch from the HMA to the EHMA in the code?
 

Top