I primarily trade trends and reversals intraday. A problem that I would find myself running into frequently was beginning my day having missed the beginning of a trend and then trying to get a reversal entrance before there was a meaningful breakdown in trend quality to support a reversal entrance. My next problem was that I would exit trades well before there was a meaningful reason to do so.
I wanted to make an indicator that would help to identify the current trend direction and quality, my requirements were that I didn't want anything that would be visually overwhelming/clutter my charts (like having lots of moving averages plotted) and that I could immediately interpret even from a distance to understand the current market bias/direction. I ultimately wanted something simple and readable while still being customizable to the market conditions
I ended up settling on two HMA on different lengths, a fast HMA that would plot early signs of trend weakening and a long HMA that would plot the bigger momentum in action. I pair it with bollinger bands to help identify chop vs trend market conditions to decide if I need early trend direction indicators (i.e. we're chopping and the Fast HMA should be used as the lead in determining direction) or if I need to wait until there is a meaningful breakdown in trend quality before I enter/exit (i.e. we're trending and the Slow HMA should be used as the lead in determining direction). The Chop option can also be used if you're more of a scalper and the Trend if you're more of a momentum-er.
This is a screenshot showing what the trend condition recolors as using a 2000 tick chart
This is a screenshot that shows how the chop conditions recolor on a 2000 tick chart
You can of course change the fast and slow lengths to whatever your preference is for your strategy and can use it on what ever time frame that you typically use, although please optimize the settings to capture your trading strategy and style best. The bright red and cyan areas indicate strong trend directions while the muted red and cyan indicates weakening (this alters depending on if you've chosen Chop or Trend market conditions).
I wanted to make an indicator that would help to identify the current trend direction and quality, my requirements were that I didn't want anything that would be visually overwhelming/clutter my charts (like having lots of moving averages plotted) and that I could immediately interpret even from a distance to understand the current market bias/direction. I ultimately wanted something simple and readable while still being customizable to the market conditions
I ended up settling on two HMA on different lengths, a fast HMA that would plot early signs of trend weakening and a long HMA that would plot the bigger momentum in action. I pair it with bollinger bands to help identify chop vs trend market conditions to decide if I need early trend direction indicators (i.e. we're chopping and the Fast HMA should be used as the lead in determining direction) or if I need to wait until there is a meaningful breakdown in trend quality before I enter/exit (i.e. we're trending and the Slow HMA should be used as the lead in determining direction). The Chop option can also be used if you're more of a scalper and the Trend if you're more of a momentum-er.
This is a screenshot showing what the trend condition recolors as using a 2000 tick chart
This is a screenshot that shows how the chop conditions recolor on a 2000 tick chart
You can of course change the fast and slow lengths to whatever your preference is for your strategy and can use it on what ever time frame that you typically use, although please optimize the settings to capture your trading strategy and style best. The bright red and cyan areas indicate strong trend directions while the muted red and cyan indicates weakening (this alters depending on if you've chosen Chop or Trend market conditions).
Code:
############################################################
# Fast and Slow HMA Oscillator - Trend and Chop Conditions #
############################################################
# Last updated 6/12/2025
# Trend: Ideal for identifying longer enduring changes in trend direction, also helpful if you're trying to capture longer trades
# Chop: Ideal for identifying early changes in trend within a range bound/choppy market, also helpful if you're scalping
############
# Fast HMA
############
input colorBars = yes;
input showMarketBiasLabel = yes;
input MarketConditions = {default Trend, Chop};
input HMAFastprice = HL2;
input HMAFast_Length = 22;
def FastHMA = HullMovingAvg(price = HMAFastPrice, length = HMAFast_Length);
def FastHMAUp = FastHMA > FastHMA[1];
def FastHMADown = FastHMA < FastHMA[1];
############
# Slow HMA
############
input HMASlowprice = HL2;
input HMASlow_Length = 80;
def SlowHMA = HullMovingAvg(price = HMASlowprice, length = HMASlow_Length);
def SlowHMAUp = SlowHMA > SlowHMA[1];
def SlowHMADown = SlowHMA < SlowHMA[1];
############
# Colors
############
DefineGlobalColor("StrongCyan" , CreateColor(33, 166, 153));
DefineGlobalColor("MutedCyan" , CreateColor(24, 104, 96));
DefineGlobalColor("StrongRed" , CreateColor(166, 38, 51));
DefineGlobalColor("MutedRed" , CreateColor(104, 24, 32));
def isrealtime = !isNaN(close);
def signalcolor;
switch(MarketConditions) {
case Trend:
signalcolor = if isrealtime then
if (SlowHMAup) and (FastHMAUp) then 2 else
if (SlowHMAup) and (FastHMADown) then 1 else
if (SlowHMADown) and (FastHMADown) then -2 else
if (SlowHMADown) and (FastHMAUp) then -1 else signalcolor[1] else signalcolor[1];
case Chop:
signalcolor = if isrealtime then
if (SlowHMAUp) and (FastHMAUp) then 2 else
if (SlowHMADown) and (FastHMAUp) then 1 else
if (SlowHMADown) and (FastHMADown) then -2 else
if (SlowHMAUp) and (FastHMADown) then -1 else signalcolor[1] else signalcolor[1];
}
############
# Bias Labels
############
AddLabel(showMarketBiasLabel,
if signalcolor == 2 then "Strong Bullish Bias" else
if signalcolor == 1 then "Weak Bullish Bias" else
if signalcolor ==-2 then "Strong Bearish Bias" else
if signalcolor ==-1 then "Weak Bearish Bias" else "No Bias",
if signalcolor == 2 then Color.GREEN else
if signalcolor == 1 then Color.DARK_GREEN else
if signalcolor ==-2 then Color.RED else
if signalcolor ==-1 then Color.DARK_RED else Color.GRAY);
############
# Recolor Bars
############
AssignPriceColor(if !colorBars then Color.CURRENT else
if signalcolor == 2 then GlobalColor("StrongCyan") else
if signalcolor == 1 then GlobalColor("MutedCyan") else
if signalcolor == -2 then GlobalColor("StrongRed") else
if signalcolor == -1 then GlobalColor("MutedRed") else Color.GRAY);
# End of Code