AGAIG HEIKIN ASHI TREND LABELS
TREND LABEL NARRATIVE:
This indicator uses Heikin Ashi candle math to identify trend direction and strength on any symbol — including indices like SPX where many indicators fall short.TREND LABEL NARRATIVE:
These labels are for use in the AGAIG Trading Strategies:
https://usethinkscript.com/search/2514435/?q=AGAIG&t=post&c[title_only]=1&o=date&g=1
Labels explained:
HA BULL
EXTENDED — orange warning when the trend has run long and may be due for a pause or reversal.
D: BULL / D: BEAR — Daily HA trend so you instantly know if your intraday move has the bigger picture behind it.
W: BULL / W: BEAR — Weekly HA trend for the highest timeframe confirmation. When W, D, and intraday all agree, that's your strongest setup.
STRONG BULL / STRONG BEAR — cyan or magenta, appears when the current candle has no opposing wick — the classic Right Line Trading signal for clean uncontested momentum.
Best use: Focus on 3-4 familiar names and learn their rhythm. Watch for W: BULL + D: BULL + HA BULL + STRONG BULL all aligned — that confluence is your highest conviction entry. A flip in the main label combined with a Daily or Weekly change is your signal to reassess or exit.
shared study link: http://tos.mx/!qPPjTV8O
Code:
# AGAIG Heikin Ashi Trend Tracker
# 3-color label: GREEN=Bullish, RED=Bearish, YELLOW=Neutral
# Includes Weekly + Daily HTF confirmation and extended trend warning
# --- Current Timeframe HA ---
input LabelSize = fontsize.medium;
input LabelLocation = location.bottom_left;
def HA_Close = (open + high + low + close) / 4;
def HA_Open = CompoundValue(1, (HA_Open[1] + HA_Close[1]) / 2, (open + close) / 2);
def HA_High = Max(high, Max(HA_Open, HA_Close));
def HA_Low = Min(low, Min(HA_Open, HA_Close));
def isBullish = HA_Close > HA_Open;
def isBearish = HA_Close < HA_Open;
def isStrongBull = isBullish and HA_Low == HA_Open;
def isStrongBear = isBearish and HA_High == HA_Open;
def trendState = if isBullish then 1 else if isBearish then -1 else 0;
def trendCount = CompoundValue(1, if trendState == trendState[1] then trendCount[1] + 1 else 1, 1);
def barCount = Round(trendCount, 0);
# --- Daily HTF HA ---
def D_Close = Close(period = AggregationPeriod.DAY);
def D_Open = Open(period = AggregationPeriod.DAY);
def D_High = High(period = AggregationPeriod.DAY);
def D_Low = Low(period = AggregationPeriod.DAY);
def D_HA_Close = (D_Open + D_High + D_Low + D_Close) / 4;
def D_HA_Open = CompoundValue(1, (D_HA_Open[1] + D_HA_Close[1]) / 2, (D_Open + D_Close) / 2);
def D_isBullish = D_HA_Close > D_HA_Open;
def D_isBearish = D_HA_Close < D_HA_Open;
# --- Weekly HTF HA ---
def W_Close = Close(period = AggregationPeriod.WEEK);
def W_Open = Open(period = AggregationPeriod.WEEK);
def W_High = High(period = AggregationPeriod.WEEK);
def W_Low = Low(period = AggregationPeriod.WEEK);
def W_HA_Close = (W_Open + W_High + W_Low + W_Close) / 4;
def W_HA_Open = CompoundValue(1, (W_HA_Open[1] + W_HA_Close[1]) / 2, (W_Open + W_Close) / 2);
def W_isBullish = W_HA_Close > W_HA_Open;
def W_isBearish = W_HA_Close < W_HA_Open;
# --- Extended Trend Warning threshold ---
input extendedBars = 10;
def isExtended = barCount >= extendedBars;
# --- Recolor price bars ---
AssignPriceColor(
if isStrongBull then Color.GREEN
else if isBullish then CreateColor(0, 180, 90)
else if isStrongBear then Color.RED
else if isBearish then CreateColor(200, 40, 40)
else Color.YELLOW
);
# --- Current TF Trend Label (orange if extended) ---
AddLabel(isBullish, "HAshi: BULL (" + barCount + ")", if isExtended then Color.ORANGE else Color.GREEN, LabelLocation, LabelSize);
AddLabel(isBearish, "HAshi: BEAR (" + barCount + ")", if isExtended then Color.ORANGE else Color.RED, LabelLocation, LabelSize);
AddLabel(!isBullish and !isBearish, "HAshi: NEUTRAL (" + barCount + ")", Color.YELLOW, LabelLocation, LabelSize);
# --- Extended warning label ---
AddLabel(isExtended, "EXTENDED", Color.ORANGE, LabelLocation, LabelSize );
# --- Daily HTF Label ---
AddLabel(D_isBullish, "D: BULL", Color.GREEN, LabelLocation, LabelSize);
AddLabel(D_isBearish, "D: BEAR", Color.RED, LabelLocation, LabelSize);
AddLabel(!D_isBullish and !D_isBearish, "D: NEUTRAL", Color.YELLOW,LabelLocation, LabelSize);
# --- Weekly HTF Label ---
AddLabel(W_isBullish, "W: BULL", Color.GREEN, LabelLocation, LabelSize);
AddLabel(W_isBearish, "W: BEAR", Color.RED, LabelLocation, LabelSize);
AddLabel(!W_isBullish and !W_isBearish, "W: NEUTRAL", Color.YELLOW, LabelLocation, LabelSize);
# --- Strong Candle Labels ---
AddLabel(isStrongBull, "STRONG BULL", Color.CYAN, LabelLocation, LabelSize);
AddLabel(isStrongBear, "STRONG BEAR", Color.MAGENTA, LabelLocation, LabelSize);
# --- Alerts ---
Alert(trendState == 1 and trendState[1] != 1, "HA Flip BULLISH", Alert.BAR, Sound.Ring);
Alert(trendState == -1 and trendState[1] != -1, "HA Flip BEARISH", Alert.BAR, Sound.Ring);
Alert(isStrongBull and !isStrongBull[1], "HA Strong Bull", Alert.BAR, Sound.Ring);
Alert(isStrongBear and !isStrongBear[1], "HA Strong Bear", Alert.BAR, Sound.Ring);
Alert(isExtended and !isExtended[1], "HA Trend Extended", Alert.BAR, Sound.Ring);
Last edited by a moderator: