SuperTrend Volume [BigBeluga] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
Dw0dNVl.png


Author Message:

SuperTrend Volume [BigBeluga] is an advanced trend-following indicator that combines the traditional SuperTrend method with a normalized volume visualization inside trend bands, offering enhanced insight into market dynamics and volume activity.

CODE:

CSS:
#// Indicator For TOS
#// © BigBeluga
#indicator("SuperTrend Volume [BigBeluga]", overlay = true, max_lines_count = 50
# Converted by Sam4Cok@Samer800    - 12/2024

input atrLength = 25;
input multiplier  = 4.0; #, "Bands", step = 0.01)
input VolumePlotType = {default "Bars", "Area"}; # "Volume Type",  == "Bars"
input lookbackPeriod = 200;

def na = Double.NaN;
def bar = VolumePlotType == VolumePlotType."Bars";
Script supertrend {
input factor = 3;
input atrPeriod = 10;
    def src = hl2;
    def tr = if isNaN(high[1]) then (high - low) else
             if !high[1] then (high - low) else TrueRange(high, close, low);
    def atr = WildersAverage(tr, atrPeriod);
    def upBand = src + factor * atr;
    def loBand = src - factor * atr;
    def lowerBand; def upperBand;
    def prevLowerBand = if isNaN(lowerBand[1]) then loBand else
                        if !lowerBand[1] then loBand else lowerBand[1];
    def prevUpperBand = if isNaN(upperBand[1]) then upBand else
                        if !upperBand[1] then upBand else upperBand[1];
    lowerBand = if loBand > prevLowerBand or close[1] < prevLowerBand then loBand else prevLowerBand;
    upperBand = if upBand < prevUpperBand or close[1] > prevUpperBand then upBand else prevUpperBand;
    def _direction;
    def superTrend;
    def prevSuperTrend = superTrend[1];
    if isNaN(atr[1]) {
        _direction = 1;
   } else if !atr[1] {
        _direction = 1;
    } else if prevSuperTrend == prevUpperBand {
        _direction = if close > upperBand then -1 else 1;
    } else {
        _direction = if close < lowerBand then 1 else -1;
    }
    superTrend = if _direction == -1 then lowerBand else upperBand;
    plot st = if isNaN(superTrend) then Double.NaN else superTrend;
    plot dir = if isNaN(_direction) then Double.NaN else _direction;
    }
#// CALCULATIONS
def supertrend = supertrend(multiplier, atrLength).st;
def direction  = supertrend(multiplier, atrLength).dir;
def distance     = Average(high - low, lookbackPeriod);
def supertrend1  = supertrend + distance * direction ;
def n_vol        = Min(4, (volume / StDev(volume, lookbackPeriod)));
def step         = (supertrend - supertrend1) / 4;
def trend_change = direction != direction[1];
def volLine = if !trend_change then supertrend1 + step * n_vol else na;
def hiVol = n_vol == 4;
#-- PLot Lines
plot ST_line1 = if !trend_change and supertrend1 then supertrend1 else na;
plot ST_line  = if !trend_change and supertrend then supertrend else na;
ST_line1.SetLineWeight(2);
ST_line1.AssignValueColor(if direction < 0 then if hiVol then Color.CYAN else CreateColor(0, 128, 128) else
                          if hiVol then Color.MAGENTA else Color.PLUM);
ST_line.AssignValueColor(if direction < 0 then CreateColor(0, 128, 128) else Color.PLUM);

#-- Area

AddCloud(if bar then na else if hiVol then volLine else na, ST_line1, Color.CYAN , Color.MAGENTA);
AddCloud(if bar then na else volLine, ST_line1, Color.CYAN , Color.MAGENTA);

#-- Bars
def conUp1 = bar and !trend_change and direction < 0 and hiVol;
def conUp  = bar and !trend_change and direction < 0 and !hiVol;
def conDn1 = bar and !trend_change and direction > 0 and hiVol;
def conDn  = bar and !trend_change and direction > 0 and !hiVol;

AddChart(open = if conUp1 then volLine else na, high = ST_line1 ,
         low = volLine ,  close = if conUp1 then ST_line1 else na,
         type = ChartType.CANDLE, growcolor =  Color.CYAN);
AddChart(open = if conUp then volLine else na, high = ST_line1 ,
         low = volLine ,  close = if conUp then ST_line1 else na,
         type = ChartType.CANDLE, growcolor =  CreateColor(0, 128, 128));

AddChart(open = if conDn1 then ST_line1 else na, high = ST_line1 ,
         low  = if conDn1 then volLine else na,  close = if conDn1 then volLine else na,
         type = ChartType.CANDLE, growcolor =  Color.MAGENTA);
AddChart(open = if conDn then ST_line1 else na, high = ST_line1,
         low  = if conDn then volLine else na,  close = if conDn then volLine else na,
         type = ChartType.CANDLE, growcolor =  Color.PLUM);


#// Max Vol points

plot volDn = if hiVol and direction > 0 then high else na;
plot volUp = if hiVol and direction < 0 then low else na;

volUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
volDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);

volUp.SetDefaultColor(Color.CYAN);
volDn.SetDefaultColor(Color.MAGENTA);

#-- END of CODE
 
Dw0dNVl.png


Author Message:

SuperTrend Volume [BigBeluga] is an advanced trend-following indicator that combines the traditional SuperTrend method with a normalized volume visualization inside trend bands, offering enhanced insight into market dynamics and volume activity.

CODE:

CSS:
#// Indicator For TOS
#// © BigBeluga
#indicator("SuperTrend Volume [BigBeluga]", overlay = true, max_lines_count = 50
# Converted by Sam4Cok@Samer800    - 12/2024

input atrLength = 25;
input multiplier  = 4.0; #, "Bands", step = 0.01)
input VolumePlotType = {default "Bars", "Area"}; # "Volume Type",  == "Bars"
input lookbackPeriod = 200;

def na = Double.NaN;
def bar = VolumePlotType == VolumePlotType."Bars";
Script supertrend {
input factor = 3;
input atrPeriod = 10;
    def src = hl2;
    def tr = if isNaN(high[1]) then (high - low) else
             if !high[1] then (high - low) else TrueRange(high, close, low);
    def atr = WildersAverage(tr, atrPeriod);
    def upBand = src + factor * atr;
    def loBand = src - factor * atr;
    def lowerBand; def upperBand;
    def prevLowerBand = if isNaN(lowerBand[1]) then loBand else
                        if !lowerBand[1] then loBand else lowerBand[1];
    def prevUpperBand = if isNaN(upperBand[1]) then upBand else
                        if !upperBand[1] then upBand else upperBand[1];
    lowerBand = if loBand > prevLowerBand or close[1] < prevLowerBand then loBand else prevLowerBand;
    upperBand = if upBand < prevUpperBand or close[1] > prevUpperBand then upBand else prevUpperBand;
    def _direction;
    def superTrend;
    def prevSuperTrend = superTrend[1];
    if isNaN(atr[1]) {
        _direction = 1;
   } else if !atr[1] {
        _direction = 1;
    } else if prevSuperTrend == prevUpperBand {
        _direction = if close > upperBand then -1 else 1;
    } else {
        _direction = if close < lowerBand then 1 else -1;
    }
    superTrend = if _direction == -1 then lowerBand else upperBand;
    plot st = if isNaN(superTrend) then Double.NaN else superTrend;
    plot dir = if isNaN(_direction) then Double.NaN else _direction;
    }
#// CALCULATIONS
def supertrend = supertrend(multiplier, atrLength).st;
def direction  = supertrend(multiplier, atrLength).dir;
def distance     = Average(high - low, lookbackPeriod);
def supertrend1  = supertrend + distance * direction ;
def n_vol        = Min(4, (volume / StDev(volume, lookbackPeriod)));
def step         = (supertrend - supertrend1) / 4;
def trend_change = direction != direction[1];
def volLine = if !trend_change then supertrend1 + step * n_vol else na;
def hiVol = n_vol == 4;
#-- PLot Lines
plot ST_line1 = if !trend_change and supertrend1 then supertrend1 else na;
plot ST_line  = if !trend_change and supertrend then supertrend else na;
ST_line1.SetLineWeight(2);
ST_line1.AssignValueColor(if direction < 0 then if hiVol then Color.CYAN else CreateColor(0, 128, 128) else
                          if hiVol then Color.MAGENTA else Color.PLUM);
ST_line.AssignValueColor(if direction < 0 then CreateColor(0, 128, 128) else Color.PLUM);

#-- Area

AddCloud(if bar then na else if hiVol then volLine else na, ST_line1, Color.CYAN , Color.MAGENTA);
AddCloud(if bar then na else volLine, ST_line1, Color.CYAN , Color.MAGENTA);

#-- Bars
def conUp1 = bar and !trend_change and direction < 0 and hiVol;
def conUp  = bar and !trend_change and direction < 0 and !hiVol;
def conDn1 = bar and !trend_change and direction > 0 and hiVol;
def conDn  = bar and !trend_change and direction > 0 and !hiVol;

AddChart(open = if conUp1 then volLine else na, high = ST_line1 ,
         low = volLine ,  close = if conUp1 then ST_line1 else na,
         type = ChartType.CANDLE, growcolor =  Color.CYAN);
AddChart(open = if conUp then volLine else na, high = ST_line1 ,
         low = volLine ,  close = if conUp then ST_line1 else na,
         type = ChartType.CANDLE, growcolor =  CreateColor(0, 128, 128));

AddChart(open = if conDn1 then ST_line1 else na, high = ST_line1 ,
         low  = if conDn1 then volLine else na,  close = if conDn1 then volLine else na,
         type = ChartType.CANDLE, growcolor =  Color.MAGENTA);
AddChart(open = if conDn then ST_line1 else na, high = ST_line1,
         low  = if conDn then volLine else na,  close = if conDn then volLine else na,
         type = ChartType.CANDLE, growcolor =  Color.PLUM);


#// Max Vol points

plot volDn = if hiVol and direction > 0 then high else na;
plot volUp = if hiVol and direction < 0 then low else na;

volUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
volDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);

volUp.SetDefaultColor(Color.CYAN);
volDn.SetDefaultColor(Color.MAGENTA);

#-- END of CODE
I know nothing on how to write code in TOS (I know... face palm). I cut and paste this code and there is an notice saying "exactly one plot expected" in the box below the code. What am I doing incorrectly. I'm doing high volume studies in TC2000 and would like to be able to do it in TOS (as I trade in TOS but it's easier to write scans in TC2000)
 
Last edited by a moderator:
I know nothing on how to write code in TOS (I know... face palm). I cut and paste this code and there is an notice saying "exactly one plot expected" in the box below the code. What am I doing incorrectly. I'm doing high volume studies in TC2000 and would like to be able to do it in TOS (as I trade in TOS but it's easier to write scans in TC2000)

That error occurs when you attempt to stuff a script written and formatted for charts into the scanner.
Follow this tutorial for setting up your scan conditions by referencing your custom chart indicators saved in your study tab.
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
 
@samer800
TY for the indicator
What is the significance of volume bar color?Is it high volume if color is lighter and and arrow appears below the candlestick?
 
@samer800
TY for the indicator
What is the significance of volume bar color?Is it high volume if color is lighter and and arrow appears below the candlestick?
The volume is normalized to a value range of 0-4. When the volume reaches a value of 4, the bar color will change, and an arrow will be displayed. The location of the arrow will depend on the trend: in an uptrend, the arrow will appear below the candlestick, while for down trend and significant volumes, the arrow will be positioned above the candlestick

more details can be found here:

https://www.tradingview.com/v/U1QqjWSn/
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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