S

S

I use the divergence label on every chart, in every scan.. Thank you.Good question @technicallydreaming ,

It's kind of my early-warning system. It lets me know what the slope of the lower indicator is, whether it's moving away from flipping or toward flipping, if I don't want to take up screen real estate with the lower indicator.

BTW, for anyone who finds the numbers annoyingly small, change

toCode:`addLabel(yes, concat("DIVERGENCE: " , divergence), color = if concavity < 0 then if divergence[1] > divergence then Color.RED else color.PINK else if divergence[1] < divergence then color.green else color.yellow);`

See what I did there? just multiply the displayed value by 10,000 and it gives nicer human-domain numbers (generally 1 to 200). The bigger the number, the more it's curving away from or toward a flip. the smaller the number, the less it's curving (more straight line).Code:`addLabel(yes, concat("DIVERGENCE: " , divergence * 10000), color = if concavity < 0 then if divergence[1] > divergence then Color.RED else color.PINK else if divergence[1] < divergence then color.green else color.yellow);`

For those who get frustrated with the downtrending 'false signal flips', watching how far it's curving away may be telltale. If the lower indicator, and by extension the lable above, isn't moving very far from zero, it may not really be about to make a nice big move. It's perhaps analagous to a strength-of-change-in-trend meter. Maybe. Your mileage will, of course, vary. Considerably probably.

Have fun with it,

-mashume

EDIT

Not for the mathematically disinterested, but perhaps worth a read.

After playing around with this a bit to see if I could write a better explanation, I threw another label together. This one gives you the standard deviation over n periods of the concavity divergence. You can use this, compared with the value of the divergence label to decide whether the shift in divergence is large enough for you to play. It is not able to predict how fast it will turn in the future even a bar or two, but it can tell you how the turnthis barcompares with a standard turn based over the last some bars.

Ponder, discover, trade, learn.

I have no idea, currently, what value to use for stddev_len. I took a guess at 21. If you make it longer, it may encompass large swings in volitile trading conditions and you'll miss trades. If you make it short, it may be overly sensitive and you'll take too many trades. It's not a buy/sell trigger. It's just information. Use with intelligence.Code:`input stddev_len = 21; def divergence_stddev = StandardDeviation(price = divergence, length = stddev_len); addLabel(yes, concat("STDDEV: " , divergence_stddev * 10000), color = if absValue(divergence) > absValue(divergence_stddev) then color.blue else color.dark_gray);`

-mashume

What exactly is the look back period changing , particularly when it comes to the MA_Max MA_Min ? Also would setting this to "Close" wait for the next candle to form before painting those signals?

Last edited:

T

I love this setup. Can you share this screenshot please

Like Mashume said, You need to rename the study you downloaded or copy codes to Concavity study, then you can scan.

I have the Scan worked now. . Let me know if you still have questions

I

@mashume hi Mashume, do you have this version in Ninja? Thx

G

I have a very basic question about strategies.

In this strategy and others Buy/sell signals are calculated on the last known period, and the scripts also fills orders on that same period (buy to open/sell to close).

I’m unsure if this reflect real trading conditions. So to reflect better trading conditions, I was wondering if it was possible to change the way orders are filled. Orders should be filled at open and close prices on the next period (next period relative to the last know period exhibiting the buy/sell signal).

Is there something fundamental I don’t understand?

I'm not sure about everyone else using this indicator, but personally I prefer to use the Ma_Min/Max as the buy sell signals. There are very few false signals this way. However rarely, they do disappear /repaint. I turned off the reg buy/sell signals.

I have a very basic question about strategies.

In this strategy and others Buy/sell signals are calculated on the last known period, and the scripts also fills orders on that same period (buy to open/sell to close).

I’m unsure if this reflect real trading conditions. So to reflect better trading conditions, I was wondering if it was possible to change the way orders are filled. Orders should be filled at open and close prices on the next period (next period relative to the last know period exhibiting the buy/sell signal).

Is there something fundamental I don’t understand?

M

No, sorry I don't have. I'm just in ToS.@mashume hi Mashume, do you have this version in Ninja? Thx

-mashume

C

Does anyone have a scan for the first green HMA and or bright green HMA on candle close.

T

Really surprised it hasn't been done yet (or maybe I missed it somewhere along inside this thread) but why not take the lower indicator format and throw a moving average on top? Purpose is to show change of momentum, not necessarily for entries, but decent for exits of trends. In the below code there are 2 moving averages: LegacyEMA and HMA2. HMA2 is currently just "def", change to "plot" and change LegacyEMA to "def" to switch if you wish. Current settings on 5min TF are: close, 200, 50, 100, 0.

Important to note, change in momentum does not mean change in direction (for the newer traders out there)

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 lower;
input price = CLOSE;
input HMA_length = 200;
input lookback = 50;
input length = 100;
input displace = 0;
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;
plot zero = 0;
zero.setdefaultcolor(color.gray);
zero.setpaintingstrategy(PaintingStrategy.DASHES);
plot divergence = HMA - next_bar;
def HMA2 = MovingAverage(AverageType.HULL, divergence, length)[-displace];
divergence.setDefaultColor(Color.LIME);
divergence.SetLineweight(2);
assert(length > 0, "'length' must be positive: " + length);
def EMA = compoundValue(1, EMA[1] + 2 / (length + 1) * (divergence[-displace] - EMA[1]), divergence[-displace]);
plot LegacyEMA = EMA;
LegacyEMA.SetDefaultColor(GetColor(1));
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);
```

Last edited:

S

Is this what you want -I love this setup. Can you share this screenshot please

C

Another way is to simply add,

plot signal = hma[1]; #or 2 or whatever makes sense to you

plot signal = hma[1]; #or 2 or whatever makes sense to you

S

Another, better example of trader/scalper with HULL and TMO for TSLA, made one small trade this am was n the 25 tick on main chart and 50 tick on bottom left, was a bit fast so dropped back to 50 and 100. Dark blue line in 50 EMA for trend guidance, HULL is 15 period, essentially TMO coming out of green bottom and 2 bricks thru yellow dash is buy, obviously buys work better with blue trend as shown with arrow at open, hope this makes sense and helps
trend working

Last edited:

M

Hey again!

I noticed that sometimes the indicator (after popping up with the white triangle that initiates a light-green trend line) will delete the triangle or move it on to the next candlestick after roughly 30sec-1min of showing up initially.

Is there any way to turn this off or delete any line of code in the settings? I'm still running the initial release version because I've found it to be the most consistent with my strategy.

Thanks again for your persistent hard work!

M

That's the MA_MIN plot. You can un-check it in the indicator settings. No need to edit the code. You can, of course take the tinker-kit out and mod the source code if you really want.

Hey again!

I noticed that sometimes the indicator (after popping up with the white triangle that initiates a light-green trend line) will delete the triangle or move it on to the next candlestick after roughly 30sec-1min of showing up initially.

Is there any way to turn this off or delete any line of code in the settings? I'm still running the initial release version because I've found it to be the most consistent with my strategy.

Thanks again for your persistent hard work!

-mashume

M

Well I actually love that part of the indicator, as it's what I use as an entry. My true question is is there a way to make it stick and not move mid candlestick?That's the MA_MIN plot. You can un-check it in the indicator settings. No need to edit the code. You can, of course take the tinker-kit out and mod the source code if you really want.

-mashume

For example, I used it on the 3m chart for SPY today and it popped at 10:21EST so I entered. About 35seconds later I look back and I do not see the "white triangle" I spoke of earlier. That's where I was a bit confused. If there is no way to keep it once it's been placed regardless, I just thought I'd ask.

Thanks again

M

Oh I see. Repainting is, unfortunately, a part of this indicator occasionally. Less so if you use CLOSE prices, but then it's not as reactive or timely necessarily.Well I actually love that part of the indicator, as it's what I use as an entry. My true question is is there a way to make it stick and not move mid candlestick?

For example, I used it on the 3m chart for SPY today and it popped at 10:21EST so I entered. About 35seconds later I look back and I do not see the "white triangle" I spoke of earlier. That's where I was a bit confused. If there is no way to keep it once it's been placed regardless, I just thought I'd ask.

Thanks again

-mashume

T

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 lower;
input price = CLOSE;
input HMA_length = 200;
input lookback = 50;
input length = 100;
input displace = 0;
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;
plot zero = 0;
zero.setdefaultcolor(color.gray);
zero.setpaintingstrategy(PaintingStrategy.DASHES);
plot divergence = HMA - next_bar;
plot HMA2 = MovingAverage(AverageType.HULL, divergence, length)[-displace];
assert(length > 0, "'length' must be positive: " + length);
input highLowLength = 10;
def multiplier1 = 2 / (length + 1);
def multiplier2 = AbsValue((close - Lowest(low, highLowLength)) - (Highest(high, highLowLength) - close)) / (Highest(high, highLowLength) - Lowest(low, highLowLength));
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (divergence - ma[1]), Average(divergence, length));
plot AEMA = ma;
AEMA.SetDefaultColor(GetColor(1));
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);
divergence.DefineColor("Up", GetColor(1));
divergence.DefineColor("Down", GetColor(0));
divergence.AssignValueColor(if divergence > AEMA then divergence.color("Up") else divergence.color("Down"));
# END
```

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

C | Hull Moving Average Scan? | Questions | 10 | |

S | RSI with Hull Moving Average > 100 or < 0? | Questions | 1 | |

Hull moving average using data created with 9 period exponential MACD line ? | Questions | 11 | ||

S | Modify the Hull Moving Average indicator? | Questions | 21 | |

Y | Hull Moving Average Pack for ThinkorSwim | Questions | 25 |