switchfire
Member
I guess maybe that's one reason back testing showed more profitable using MA_Min/MA_Max vs the orginal signal
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
script ConcavityDivergence {
#
# Hull Moving Average Concavity Divergence
# or
# The Second Derivative of the Hull Moving Average
#
# Author: Seth Urion (Mahsume)
# Version: 2020-02-21 Initial Public
#
# This code is licensed (as applicable) under the GPL v3
#
# ----------------------
declare lower;
input price = HL2;
input HMA_length = 34;
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;
plot zero = 0;
zero.setdefaultcolor(color.gray);
zero.setpaintingstrategy(PaintingStrategy.DASHES);
plot divergence = displacer(-1, 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);
}
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]);
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]);
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.Are the values in this script set up for daily
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);
@mashume are there major difference between the versions? Because i use the first one
Can't get it to work? Can you please give instructions on how to install it to the scan tab
Says Concavity ("hma length") =55 is invalid@asragov et al,
Links to new (faster versions):
UPPER
https://tos.mx/ljjgn40
LOWER
https://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:
- Add a Filter
- Choose Study
- In the left-most dropdown which defaults to ADX Crossover or something select Custom...
- Click ThinkScript Editor near the top of the window
- 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
Concavity("price" = close, "hma length" = 55)."buy" is true
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.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Exponential Hull Moving Average (EHMA) for ThinkorSwim | Indicators | 8 | |
Safe Hull Moving Average Indicator for ThinkorSwim | Indicators | 3 | ||
Hull Format, Label, Watchlist, Scan for ThinkorSwim | Indicators | 115 | ||
L | A Volume Pressure Moving Average For ThinkOrSwim | Indicators | 15 | |
T | Mega Moving Average For ThinkOrSwim | Indicators | 26 |
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.