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.
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);
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);
Looks great man. Thanks again!!Code above has been fixed.
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.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.
What settings and timeframe did you backtest? Thanksmanual 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.
@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?
Hi Amalia, Is it possible to post inside bar line code here?insideBar study = )
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.