Top G indicator [BigBeluga] For ThinkOrSwim

Zlotko

Active member
VIP
The author states: designed to identify market extremes, helping traders spot potential tops and bottoms effectively.
๐Ÿ”ตKey Features:
High Probability Signals:
  • ๐”พ Label: Indicates high-probability market bottoms based on specific conditions such as low volatility and momentum shifts.
  • ^ (Caret): Marks potential bottom areas with less certainty than ๐”พ labels.
  • v (Inverted Caret): Signals potential top areas with less certainty than Top labels.

Midline Visualization:
  • A smoothed midline helps identify the center of the current range, providing additional context for trend and range trading.

Range Highlighting:
  • Dynamic bands around the highest and lowest points of the selected period
8lA20b4.png


Here is the original Tradingview code:
https://www.tradingview.com/script/JOE1tYTo-Top-G-indicator-BigBeluga/


For the new ThinkOrSwim code, you must scroll down to the next post


Buy Low, Sell High! This Indicator Shows Market Tops & Bottoms
 
Last edited by a moderator:

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

Could we convert this?
Top G Indicator Big Beluga
https://www.tradingview.com/script/JOE1tYTo-Top-G-indicator-BigBeluga/


Buy Low, Sell High! This Indicator Shows Market Tops & Bottoms

// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// ยฉ BigBeluga
//@version=6
indicator("Top G indicator [BigBeluga]", overlay = true, max_labels_count = 500)
// ๏ผฉ๏ผฎ๏ผฐ๏ผต๏ผด๏ผณ โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•{
int length = input.int(150)
color main_col = input.color(#CD7F32, "Main Color")
color col_na = color.new(color.black, 100)
// }

// ๏ผฃ๏ผก๏ผฌ๏ผฃ๏ผต๏ผฌ๏ผก๏ผด๏ผฉ๏ผฏ๏ผฎ๏ผณโ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•
lowest_highest(length)=>
series float lowest_src = ta.lowest(length)
series float highest_src = ta.highest(length)
series float mid = ta.hma(math.avg(lowest_src, highest_src), 15)
[lowest_src, highest_src, mid]

signals(lowest_src, highest_src)=>
float roc = ta.roc(close, 8)
roc := roc / ta.stdev(roc, 200)
bool top = high < highest_src and high[1] == highest_src[1] and roc[2] > 2 and lowest_src == lowest_src[5] and barstate.isconfirmed
bool G = low[1] == lowest_src[1] and low > lowest_src and low[2] == lowest_src[2] and roc[2] < -2 and barstate.isconfirmed
bool simple_g = low[1] == lowest_src[1] and low > lowest_src and not G and barstate.isconfirmed
bool simple_top = high < highest_src and high[1] == highest_src[1] and not top and barstate.isconfirmed
[top, G, simple_g, simple_top]

draw_labels(top, G, highest_src, lowest_src, simple_g, simple_top)=>
if top
label.new(time, highest_src, "Top", xloc = xloc.bar_time, color = col_na, textcolor = chart.fg_color)
if G
label.new(time, lowest_src, "๐”พ", xloc = xloc.bar_time, color = col_na, textcolor = main_col, style = label.style_label_up, size = size.large)

if simple_g
label.new(time, lowest_src, "^", xloc = xloc.bar_time, color = col_na, textcolor = color.new(main_col, 30), style = label.style_label_up, size = size.large)
if simple_top
label.new(time, highest_src, "ห…", xloc = xloc.bar_time, color = col_na, textcolor = color.new(main_col, 30))

[lowest_src, highest_src, mid] = lowest_highest(length)
[top, G, simple_g, simple_top] = signals(lowest_src, highest_src)
draw_labels(top, G, highest_src, lowest_src, simple_g, simple_top)
// }

// ๏ผฐ๏ผฌ๏ผฏ๏ผด โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•{
ph = plot(highest_src, color = bar_index % 2 == 0 ? main_col : na)
plot(mid, "", color.new(chart.fg_color, 50))
pl = plot(lowest_src, color = main_col, linewidth = 1)
plot(lowest_src, color = color.new(main_col, 80), linewidth = 5)
fill(pl, ph, highest_src, lowest_src, na, color.new(main_col, 90))
// }


or -------------------


Pine Scriptโ„ข indicator

Top G indicator [BigBeluga]​



// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// ยฉ BigBeluga

//@version=6
indicator("Top G indicator [BigBeluga]", overlay = true, max_labels_count = 500)

// ๏ผฉ๏ผฎ๏ผฐ๏ผต๏ผด๏ผณ โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•{
int length = input.int(150)
color main_col = input.color(#CD7F32, "Main Color")
color col_na = color.new(color.black, 100)
// }


// ๏ผฃ๏ผก๏ผฌ๏ผฃ๏ผต๏ผฌ๏ผก๏ผด๏ผฉ๏ผฏ๏ผฎ๏ผณโ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

lowest_highest(length)=>
series float lowest_src = ta.lowest(length)
series float highest_src = ta.highest(length)
series float mid = ta.hma(math.avg(lowest_src, highest_src), 15)
[lowest_src, highest_src, mid]


signals(lowest_src, highest_src)=>
float roc = ta.roc(close, 8)
roc := roc / ta.stdev(roc, 200)

bool top = high < highest_src and high[1] == highest_src[1] and roc[2] > 2 and lowest_src == lowest_src[5] and barstate.isconfirmed
bool G = low[1] == lowest_src[1] and low > lowest_src and low[2] == lowest_src[2] and roc[2] < -2 and barstate.isconfirmed

bool simple_g = low[1] == lowest_src[1] and low > lowest_src and not G and barstate.isconfirmed
check the below. I added MACD divergence check as well:

CSS:
#// Indicator for TOS
#// ยฉ BigBeluga
#indicator("Top G indicator [BigBeluga]", overlay = true, max_la
# Converted by Sam4Cok@Samer800     - 02/2025

input showGChannel = yes;
input gChannelLength = 150;
input useMacdFilter = yes;
input macdFastLength = 12;
input macdSlowLength = 26;
input macdSignalLength = 9;
input macdAverageType = AverageType.EXPONENTIAL;

def na = Double.NaN;
def last = IsNaN(close);

# // ๏ผฃ๏ผก๏ผฌ๏ผฃ๏ผต๏ผฌ๏ผก๏ผด๏ผฉ๏ผฏ๏ผฎ๏ผณ
def lowest_src = Lowest(low, gChannelLength);
def highest_src = Highest(high, gChannelLength);
def avg = (highest_src + lowest_src) / 2;
def mid = HullMovingAvg(avg, 15);
def roc1 = 100 * (close - close[8]) / close[8];
def roc = roc1 / StDev(roc1, 200);
def top = high < highest_src and high[1] == highest_src[1] and roc[2] > 2 and lowest_src == lowest_src[5] and !last;
def G   = low[1] == lowest_src[1] and low > lowest_src and low[2] == lowest_src[2] and roc[2] < -2 and !last;
def simple_g = low[1] == lowest_src[1] and low > lowest_src and !G and !last;
def simple_top = high < highest_src and high[1] == highest_src[1] and !top and !last;


#// ๏ผฐ๏ผฌ๏ผฏ๏ผด
plot ph = if showGchannel then highest_src else na; #, color = bar_index % 2 == 0 ? main_col : na)
plot md = if showGchannel then mid else na; #, "", color.new(chart.fg_color, 50))
plot pl = if showGchannel then lowest_src else na; #, color = main_col, linewidth = 1)

ph.SetStyle(Curve.SHORT_DASH);
ph.SetDefaultColor(Color.LIGHT_ORANGE);
md.SetDefaultColor(Color.GRAY);
pl.SetDefaultColor(Color.LIGHT_ORANGE);

# MACD

def MACD = MovingAverage(macdAverageType, close, macdFastLength) - MovingAverage(macdAverageType, close, macdSlowLength);
def Signal = MovingAverage(macdAverageType, MACD, macdSignalLength);
def hist = MACD - Signal;
def crossUp = (hist > 0) and (hist[1] <= 0);
def crossDn = (hist < 0) and (hist[1] >= 0);

def maxUp = if crossUp then 0 else if hist > 0 then Max(maxUp[1], hist) else maxUp[1];
def minDn = if crossDn then 0 else if hist < 0 then Min(minDn[1], hist) else minDn[1];
def PreUp = if !maxUp then maxUp[1] else PreUp[1];
def PreDn = if !minDn then minDn[1] else PreDn[1];

plot signalUp = useMacdFilter and G and hist < 0 and minDn > PreDn;
plot signalDn = useMacdFilter and top and hist > 0 and maxUp < PreUp;

signalUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalUp.SetDefaultColor(Color.CYAN);
signalDn.SetDefaultColor(Color.MAGENTA);

#-- Top & G

plot simpleTop = if simple_top then high else na;
plot simpleG = if simple_g then low else na;

simpleTop.SetDefaultColor(Color.ORANGE);
simpleG.SetDefaultColor(Color.ORANGE);
simpleTop.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
simpleG.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);

AddChartBubble(!signalDn and top, highest_src, "Top", Color.WHITE);
AddChartBubble(!signalUp and G, lowest_src, "G", Color.LIGHT_ORANGE, no);


#-- ENd of CODE
 
check the below. I added MACD divergence check as well:

CSS:
#// Indicator for TOS
#// ยฉ BigBeluga
#indicator("Top G indicator [BigBeluga]", overlay = true, max_la
# Converted by Sam4Cok@Samer800     - 02/2025

input showGChannel = yes;
input gChannelLength = 150;
input useMacdFilter = yes;
input macdFastLength = 12;
input macdSlowLength = 26;
input macdSignalLength = 9;
input macdAverageType = AverageType.EXPONENTIAL;

def na = Double.NaN;
def last = IsNaN(close);

# // ๏ผฃ๏ผก๏ผฌ๏ผฃ๏ผต๏ผฌ๏ผก๏ผด๏ผฉ๏ผฏ๏ผฎ๏ผณ
def lowest_src = Lowest(low, gChannelLength);
def highest_src = Highest(high, gChannelLength);
def avg = (highest_src + lowest_src) / 2;
def mid = HullMovingAvg(avg, 15);
def roc1 = 100 * (close - close[8]) / close[8];
def roc = roc1 / StDev(roc1, 200);
def top = high < highest_src and high[1] == highest_src[1] and roc[2] > 2 and lowest_src == lowest_src[5] and !last;
def G   = low[1] == lowest_src[1] and low > lowest_src and low[2] == lowest_src[2] and roc[2] < -2 and !last;
def simple_g = low[1] == lowest_src[1] and low > lowest_src and !G and !last;
def simple_top = high < highest_src and high[1] == highest_src[1] and !top and !last;


#// ๏ผฐ๏ผฌ๏ผฏ๏ผด
plot ph = if showGchannel then highest_src else na; #, color = bar_index % 2 == 0 ? main_col : na)
plot md = if showGchannel then mid else na; #, "", color.new(chart.fg_color, 50))
plot pl = if showGchannel then lowest_src else na; #, color = main_col, linewidth = 1)

ph.SetStyle(Curve.SHORT_DASH);
ph.SetDefaultColor(Color.LIGHT_ORANGE);
md.SetDefaultColor(Color.GRAY);
pl.SetDefaultColor(Color.LIGHT_ORANGE);

# MACD

def MACD = MovingAverage(macdAverageType, close, macdFastLength) - MovingAverage(macdAverageType, close, macdSlowLength);
def Signal = MovingAverage(macdAverageType, MACD, macdSignalLength);
def hist = MACD - Signal;
def crossUp = (hist > 0) and (hist[1] <= 0);
def crossDn = (hist < 0) and (hist[1] >= 0);

def maxUp = if crossUp then 0 else if hist > 0 then Max(maxUp[1], hist) else maxUp[1];
def minDn = if crossDn then 0 else if hist < 0 then Min(minDn[1], hist) else minDn[1];
def PreUp = if !maxUp then maxUp[1] else PreUp[1];
def PreDn = if !minDn then minDn[1] else PreDn[1];

plot signalUp = useMacdFilter and G and hist < 0 and minDn > PreDn;
plot signalDn = useMacdFilter and top and hist > 0 and maxUp < PreUp;

signalUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalUp.SetDefaultColor(Color.CYAN);
signalDn.SetDefaultColor(Color.MAGENTA);

#-- Top & G

plot simpleTop = if simple_top then high else na;
plot simpleG = if simple_g then low else na;

simpleTop.SetDefaultColor(Color.ORANGE);
simpleG.SetDefaultColor(Color.ORANGE);
simpleTop.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
simpleG.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);

AddChartBubble(!signalDn and top, highest_src, "Top", Color.WHITE);
AddChartBubble(!signalUp and G, lowest_src, "G", Color.LIGHT_ORANGE, no);


#-- ENd of CODE
Your conversion skills samer never cease to amaze me!
 
Upon reviewing historical signals for different stocks, this indicator provides the most precise buy and sell arrows. This has become my new favorite indicator. Thank you very much, Samer and Zlotko
 
What time frame have you been looking at?
Daily, 4-hour, 2-hour, and 1-hour time frames (ETF's and US Stocks). I am uncertain about the effectiveness of this indicator for timeframes under 1 hour, as I have not examined it, being a swing trader rather than a day trader.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
432 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