GHLA SuperTrend CCI HighLow Activator For ThinkOrSwim

what would you like to see it crossover?
Sorry over the GHLA 0 Line, unless you have a better suggestion to identify a bullish trend. An example might be KRKNF today or JBL and ARKX around 12/19. I really appreciate your help and responsiveness. Cheers
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Sorry over the GHLA 0 Line, unless you have a better suggestion to identify a bullish trend. An example might be KRKNF today or JBL and ARKX around 12/19. I really appreciate your help and responsiveness. Cheers
Ok how about this one https://tos.mx/!P3aexqYG
this scans for stocks that the GannOSC crosses above the LL1 showing strength on a bullish move
1766546044417.png
1766546079040.png
1766546193837.png
 
Thanks I actually wanted the scan to identify cross overthe 0/middle bar line, which then turns the bar green as per attached. Example below where RKLB crossed around 12/2.
1766576966758.png
 
Last edited:
sorry I thought you were asking for a GHLA scan and you would need to set this indicator up first then use that study to set up the scan
Code:
# GHLA_SuperTrend_CCI_High_Low_Activator_Oscillator
#By CANDO13579
#STDEV zones by Chewie76
#Oscillator Range Analysis Labels by Antwerks

declare lower;
declare real_size;
input ghlaPeriod = 10;
input stPeriod = 14;
input stShiftTicks = 20.0;
input useFilter = yes;

def minTick = TickSize();
def shift = stShiftTicks * minTick;

# -----------------------------
# GHLA Logic
# -----------------------------
def ghlaAvgH = Average(high, ghlaPeriod);
def ghlaAvgL = Average(low, ghlaPeriod);

def sw = if close > ghlaAvgH then 1
else if close < ghlaAvgL then -1
else 0;

def ghlaDir = CompoundValue(1, if sw != 0 then sw else ghlaDir[1], 0);
def ghlaLevel = if ghlaDir < 0 then ghlaAvgH else ghlaAvgL;

# -----------------------------
# Custom CCI using Typical Price
# -----------------------------
def tp = (high + low + close) / 3;
def tpSMA = Average(tp, stPeriod);
def meanDev = Average(AbsValue(tp - tpSMA), stPeriod);
def cciValue = if meanDev == 0 then 0 else (tp - tpSMA) / (0.015 * meanDev);

# -----------------------------
# SuperTrend State Machine
# -----------------------------

# stFlag: 1=long, -1=short
rec stFlag = if IsNaN(stFlag[1]) then if cciValue >= 0 then 1 else -1
else if cciValue > 0 and stFlag[1] <= 0 then 1
else if cciValue < 0 and stFlag[1] >= 0 then -1
else stFlag[1];

rec st = if IsNaN(st[1]) then if cciValue >= 0 then low - shift else high + shift
else
if cciValue > 0 and stFlag[1] <= 0 then low - shift
else if cciValue < 0 and stFlag[1] >= 0 then high + shift
else
if stFlag > 0 and (low - shift) > st[1] then low - shift
else if stFlag < 0 and (high + shift) < st[1] then high + shift
else
if useFilter and stFlag > 0 and st[1] < st[1] and (close < open or high < high[1]) then st[1]
else if useFilter and stFlag < 0 and st[1] > st[1] and (close > open or low > low[1]) then st[1]
else st[1];

# -----------------------------
# signals
# -----------------------------
def notNaST = !IsNaN(st);
def upSignal = notNaST and close > st and close > ghlaLevel;
def downSignal = notNaST and close < st and close < ghlaLevel;
def neutralSignal = notNaST and !upSignal and !downSignal;

# -----------------------------
# Output (centered)
# -----------------------------
def signalCenter = 0;
plot Sig = signalCenter;
Sig.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Sig.SetLineWeight(4);

Sig.AssignValueColor(
if upSignal then Color.GREEN
else if downSignal then Color.RED
else Color.LIGHT_GRAY
);

# Boundary reference lines
# -----------------------------
plot UpperLine = 1;
UpperLine.SetDefaultColor(Color.DARK_GRAY);
UpperLine.SetStyle(Curve.SHORT_DASH);

plot LowerLine = -1;
LowerLine.SetDefaultColor(Color.DARK_GRAY);
LowerLine.SetStyle(Curve.SHORT_DASH);

# Gann High/Low Activator Oscillator

input activatorPeriod = 14;

# Calculate simple moving averages
def avgHigh = Average(high, activatorPeriod);
def avgLow = Average(low, activatorPeriod);

# Determine state
def bullState = close > avgHigh;
def bearState = close < avgLow;

# Track the last valid state
def lastState = CompoundValue(1,
if bullState then 1
else if bearState then -1
else lastState[1],
0);

def avgRange = avgHigh - avgLow;
def oscillator =
if avgRange != 0 then
if lastState == 1 then (close - avgLow) / avgRange
else if lastState == -1 then (close - avgHigh) / avgRange
else 0.5
else 0.5;

# Plot oscillator
plot GannOsc = oscillator;
GannOsc.SetLineWeight(2);
GannOsc.AssignValueColor(
if lastState == 1 then CreateColor(0, 255, 0) # Green
else if lastState == -1 then CreateColor(255, 165, 0) # Orange
else Color.GRAY
);

# Plot midline
plot MidLine = 0.5;
MidLine.SetDefaultColor(Color.LIGHT_GRAY);
MidLine.SetStyle(Curve.SHORT_DASH);
# 2 Standard Deviation Full

input deviations = 2.0;
input deviations2 = 2.5;
input fullRange = yes;
input length = 300;

def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(GannOsc);
stdDeviation = StDevAll(GannOsc);
} else {
regression = InertiaAll(GannOsc, length);
stdDeviation = StDevAll(GannOsc, length);
}

plot UpperLine1 = regression + deviations * stdDeviation;
#plot MiddleLine = regression;
plot LowerLine1 = regression - deviations * stdDeviation;

UpperLine1.SetDefaultColor(Color.RED);
LowerLine1.SetDefaultColor(Color.GREEN);
UpperLine1.SetLineWeight(1);
LowerLine1.SetLineWeight(1);
UpperLine1.HideBubble();
UpperLine1.HideTitle();
LowerLine1.HideBubble();
LowerLine1.HideTitle();


plot UpperLine2 = regression + deviations2 * stdDeviation;
plot LowerLine2 = regression - deviations2 * stdDeviation;

UpperLine2.SetDefaultColor(Color.RED);
LowerLine2.SetDefaultColor(Color.GREEN);
UpperLine2.SetLineWeight(1);
LowerLine2.SetLineWeight(1);
UpperLine2.HideBubble();
UpperLine2.HideTitle();
LowerLine2.HideBubble();
LowerLine2.HideTitle();

AddCloud(UpperLine2, UpperLine1, Color.RED, Color.CURRENT);
AddCloud(LowerLine1, LowerLine2, Color.GREEN, Color.CURRENT);
# === Oscillator Range Analysis ===

def isOverbought2 = GannOsc >= UpperLine2;
def isOverbought1 = GannOsc >= UpperLine1;
def isOversold2 = GannOsc <= LowerLine2;
def isOversold1 = GannOsc <= LowerLine1;

def oscZone =
if isOverbought2 then 2
else if isOverbought1 then 1
else if isOversold2 then -2
else if isOversold1 then -1
else 0;

def forecastSignal =
if upSignal and oscZone <= -1 then 1 # Strong Buy
else if downSignal and oscZone >= 1 then -1 # Strong Sell
else if upSignal then 2 # Buy Opportunity
else if downSignal then -2 # Sell Opportunity
else 0;

# === AddLabel Displays ===

AddLabel(yes,
if upSignal then "TREND: Bullish (UP)"
else if downSignal then "TREND: Bearish (DOWN)"
else "TREND: Neutral/Sideways",
if upSignal then Color.GREEN
else if downSignal then Color.RED
else Color.GRAY
);

AddLabel(yes,
"GANN STATE: " +
(if lastState == 1 then "Bull Zone"
else if lastState == -1 then "Bear Zone"
else "Neutral"),
if lastState == 1 then CreateColor(0, 255, 0)
else if lastState == -1 then CreateColor(255, 165, 0)
else Color.GRAY
);

AddLabel(yes,
"OSC Range: " +
(if oscZone == 2 then "Overbought (2σ)"
else if oscZone == 1 then "Overbought (1.5σ)"
else if oscZone == -1 then "Oversold (1.5σ)"
else if oscZone == -2 then "Oversold (2σ)"
else "In Range"),
if oscZone >= 1 then Color.RED
else if oscZone <= -1 then Color.GREEN
else Color.LIGHT_GRAY
);

AddLabel(yes,
"FORECAST: " +
(if forecastSignal == 1 then "Strong BUY Zone"
else if forecastSignal == -1 then "Strong SELL Zone"
else if forecastSignal == 2 then "Buying Opportunity"
else if forecastSignal == -2 then "Selling Opportunity"
else "Wait / Watch"),
if forecastSignal == 1 or forecastSignal == 2 then Color.GREEN
else if forecastSignal == -1 or forecastSignal == -2 then Color.RED
else Color.YELLOW
);
Many thanks for your help Antwerks. If I want to now add a scan for a selling opportunity, what do I change?
 
Hi again Antwerks. I downloaded the same script #34 for the bullish "OSC". But the "scan box" does not show the choice of "close" on the left side. Just the cross below UL1 on the right side. What am I doing wrong? Many thanks.
You want to scan for the OSC to cross over the UL1
 
Antwerks, just following up to see you can help me with above. Thanks!
The other scanner we wrote was when the OSC crosses above the LL1 which gave an earlier signal and if the OSC does not go below the LL1 then it is telling us to stay in the trade (confirming other indicators) - this new scanner will give signals just when crossing the "signal" line just giving notice maybe of momentum changes or just oscillation of price action - just a thought for you to decide how to handle your strategies.
1766776005509.png
 
Here is a bullish version if you want bearish change to cross below SIG - https://tos.mx/!5AGQuZv6
REMEMBER IT TAKES MORE THAN ONE INDICATOR TO VALIDATE A BUY OR SELL SIGNAL!

Yea, I guess that's where I'm struggling a bit; I can see where multiple signals suggest a buy signal, but I don't know how to program and just using scan conditions doesn't work because the signals are not all simultaneous. Since this thread is about supertrends, another signal I use/like is DMI. Rather than just a simple cross of DI+ over DI-, I can't figure out how to program for a crossover and then delta between the lines grows quickly, like after around 8/21 below. BTW, do you use a combination of signals you've programmed into one scan? really appreciate all your help and guidance!

1766785978374.png
 
Yea, I guess that's where I'm struggling a bit; I can see where multiple signals suggest a buy signal, but I don't know how to program and just using scan conditions doesn't work because the signals are not all simultaneous. Since this thread is about supertrends, another signal I use/like is DMI. Rather than just a simple cross of DI+ over DI-, I can't figure out how to program for a crossover and then delta between the lines grows quickly, like after around 8/21 below. BTW, do you use a combination of signals you've programmed into one scan? really appreciate all your help and guidance!

View attachment 26645
These are both momentum indicators (although DTE is a trend momentum and the GHLA is a multi-faceted composite momentum indicator) That's why you see them both behave very similar in their signals and directional "trend". @useThinkScript or @merryDay had written a good article on non-colinear indicators to use that give you a better "overall picture" of the price action chart.
Complex indicators are very difficult due to each logic indicator segment needs to be tuned differently most of the time, so you get a lot of "nothing" most of the time. There are a few really good complex indicators in the VIP section that have been proven to be very insightful, but you will need to join the VIP (well worth the money)
 
Last edited by a moderator:
These are both momentum indicators (although DTE is a trend momentum and the GHLA is a multi-faceted composite momentum indicator) That's why you see them both behave very similar in their signals and directional "trend". @useThinkScript or @merryDay had written a good article on non-colinear indicators to use that give you a better "overall picture" of the price action chart.
Complex indicators are very difficult due to each logic indicator segment needs to be tuned differently most of the time, so you get a lot of "nothing" most of the time. There are a few really good complex indicators in the VIP section that have been proven to be very insightful, but you will need to join the VIP (well worth the money)
This is super helpful and validates my challenges. Happy to join VIP. Do you happen to have a link for that article about non-colinear indicators?
 
I've added an "Avg" line to the Oscillator (think MACD with a Value line and an Avg)...

Code:
input averageType = AverageType.WILDERS;
plot Avg = MovingAverage(averageType, GannOsc, ActivatorPeriod);
Avg.AssignValueColor(
if GannOsc >= Avg then Color.Cyan
else if GannOsc <=Avg then Color.Magenta
else Color.LIGHT_GRAY
);

1765751437960.png
1765751437960.png
 
Last edited by a moderator:
I've added an "Avg" line to the Oscillator (think MACD with a Value line and an Avg)...

Code:
input averageType = AverageType.WILDERS;
plot Avg = MovingAverage(averageType, GannOsc, ActivatorPeriod);
Avg.AssignValueColor(
if GannOsc >= Avg then Color.Cyan
else if GannOsc <=Avg then Color.Magenta
else Color.LIGHT_GRAY
);

View attachment 26557View attachment 26557
So I guess we need to know or define the signal you are wanting from the average - what action or information you expect on the cross over? Is the average tuned to reduce lag it generates? Is the MA used for smoothing and confirmation of or validates trend? If so please define.
Adding a moving average to an oscillator is a subjective enhancement, not a universally beneficial practice. It can help with confirmation or smoothing, but It does not improve the predictive power of the oscillator by itself. It may reduce responsiveness and obscure cleaner signals and unless you have tested it in your specific strategy, assume it adds more noise than edge.
"If you can’t define what the moving average crossover adds to your entry/exit logic — skip it."
 
I'm new to this forum and technical analysis. Can someone please provide a more detailed explanation how to interpret the colors of the horizontal line and oscillator? What is the significance of the oscillator crossing over the horizontal line? How do I interpret the numbers along the right hand axis? Why is the significance of the 0.5 midline? Any guidance will be greatly appreciated.
 
I'm new to this forum and technical analysis. Can someone please provide a more detailed explanation how to interpret the colors of the horizontal line and oscillator? What is the significance of the oscillator crossing over the horizontal line? How do I interpret the numbers along the right hand axis? Why is the significance of the 0.5 midline? Any guidance will be greatly appreciated.
Here is a run down on the indicator. The indicator is in the VIP section. Join VIP for this and a myriad of other great scripts.

Horizontal Line (Signal Line)
This is a thick horizontal line at 0 on the oscillator pane:
  • Color meanings:
    • Green: Indicates a bullish condition (price is strong).
    • Red: Indicates a bearish condition (price is weak).
    • Gray: Neutral – no clear bullish or bearish trend.
This line shows trend bias at a glance — it's not moving; the color is what changes to indicate market trend shifts.

Oscillator Line (Gann Oscillator)

This is the actual dynamic line that moves between 0 and 1:

What it represents:
  • It's a normalized measure of price strength, calculated based on where the close sits between a moving average of highs and lows.
  • It tells you how strong bulls or bears are, depending on where the line is relative to 0.5 (the center).
How to read it:
  • Above 0.5 → bullish momentum.
  • Below 0.5 → bearish momentum.
  • The higher above 0.5, the stronger the bull trend.
  • The lower below 0.5, the stronger the bear trend.
What happens when the oscillator crosses 0.5?
This is a momentum shift signal:
  • Crossing above 0.5 → shift from bear to bull bias.
  • Crossing below 0.5 → shift from bull to bear bias.
It’s often used as a confirmation that a trend is beginning or strengthening.

Right-hand Axis Values
The numbers along the right side of the oscillator pane typically range between 0 and 1, showing the current oscillator value.

Key levels:
  • 0.5 = Neutral (centerline).
  • 1 = Max bull strength.
  • 0 = Max bear strength.
You’ll also see lines at standard deviation levels, like:
  • UpperLine1 / UpperLine2 (usually red): Overbought levels (e.g., 0.85, 0.9+)
  • LowerLine1 / LowerLine2 (usually green): Oversold levels (e.g., 0.15, 0.1-)
Zone Interpretation (based on colors and zones)

The oscillator has zones like:

Zone NameMeaningColor
Overbought 2σVery strong — might be overextendedRed
Overbought 1.5σStrong bullish, potential toppingRed
Oversold 1.5σBearish pressure, possible bottomingGreen
Oversold 2σExtremely oversold — reversal possibleGreen
In RangeNormal price actionGray
Summary
  • Color of horizontal line = current trend bias (green/red/gray).
  • Oscillator line = price strength, moves dynamically between 0–1.
  • Crossing 0.5 = momentum shift.
  • Right axis values = actual oscillator values.
  • Overbought/Oversold clouds = zones to watch for reversals or overextensions.
Tip for New Users

Look for alignment between:
  • Green oscillator AND green horizontal line = strong bull trend
  • Red oscillator AND red line = strong bear trend
  • Oscillator bouncing off overbought/oversold zones = possible reversals
You're on the right path, understanding these tools takes time, but you're already ahead by asking the right questions.
 
Last edited by a moderator:
After you add the STDEV zones then add this to the bottom of the script for labels
Code:
# === Oscillator Range Analysis ===

def isOverbought2 = GannOsc >= UpperLine2;
def isOverbought1 = GannOsc >= UpperLine1;
def isOversold2   = GannOsc <= LowerLine2;
def isOversold1   = GannOsc <= LowerLine1;

def oscZone =
    if isOverbought2 then 2
    else if isOverbought1 then 1
    else if isOversold2 then -2
    else if isOversold1 then -1
    else 0;

def forecastSignal =
    if upSignal and oscZone <= -1 then 1  # Strong Buy
    else if downSignal and oscZone >= 1 then -1  # Strong Sell
    else if upSignal then 2  # Buy Opportunity
    else if downSignal then -2  # Sell Opportunity
    else 0;

# === AddLabel Displays ===

AddLabel(yes,
    if upSignal then "TREND: Bullish (UP)"
    else if downSignal then "TREND: Bearish (DOWN)"
    else "TREND: Neutral/Sideways",
    if upSignal then Color.GREEN
    else if downSignal then Color.RED
    else Color.GRAY
);

AddLabel(yes,
    "GANN STATE: " +
    (if lastState == 1 then "Bull Zone"
     else if lastState == -1 then "Bear Zone"
     else "Neutral"),
    if lastState == 1 then CreateColor(0, 255, 0)
    else if lastState == -1 then CreateColor(255, 165, 0)
    else Color.GRAY
);

AddLabel(yes,
    "OSC Range: " +
    (if oscZone == 2 then "Overbought (2σ)"
     else if oscZone == 1 then "Overbought (1.5σ)"
     else if oscZone == -1 then "Oversold (1.5σ)"
     else if oscZone == -2 then "Oversold (2σ)"
     else "In Range"),
    if oscZone >= 1 then Color.RED
    else if oscZone <= -1 then Color.GREEN
    else Color.LIGHT_GRAY
);

AddLabel(yes,
    "FORECAST: " +
    (if forecastSignal == 1 then "Strong BUY Zone"
     else if forecastSignal == -1 then "Strong SELL Zone"
     else if forecastSignal == 2 then "Buying Opportunity"
     else if forecastSignal == -2 then "Selling Opportunity"
     else "Wait / Watch"),
    if forecastSignal == 1 or forecastSignal == 2 then Color.GREEN
    else if forecastSignal == -1 or forecastSignal == -2 then Color.RED
    else Color.YELLOW
);
THANK YOU FOR THIS! Anyway you can share the code for the Labels in the lower oscillator?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1086 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top