Volume Strength based on Up/Dn Vol Ratio For ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
Apologies if this has been done before, i couldnt find it.

I am looking for a study that puts a label on my chart. What it does is add up the volume candles that are green on the day so far and display that in a label, then do the same for red and display that, then display a ratio green volume/red volume multiple.. ignores true doji candles (open price = close price)

So on the one minute chart it just gives you (a) the volume sum to the current minute of all the green 1 minute candles, (b) volume sum of all the red 1 minute candles and (c) a/b ...

Does that exist or can anyone create?

Many thanks
try this, Up/Dn volume strength. very helpful indicator.

CSS:
# Volume Strength based on Up/Dn Vol Ratio indicator
# Created for UseThinkScript.com member
# Created by Sam4Cok@Samer800 - 11/2022

declare lower;
input ShowLabel = yes;
input ShowMaLines = no;
input ShowCloud = yes;
input movAvgType = AverageType.SIMPLE;
input maLength = 30;
input LockbackPeriod = 50;
input thresholdHigh   =  1.0;
input thresholdMedium =  0.5;
input thresholdLow    =  0.25;
####-----------------------------------------------------------------
DefineGlobalColor("high",   Color.DARK_RED);
DefineGlobalColor("medium", CreateColor(255,120,0));
DefineGlobalColor("low",    Color.LIGHT_ORANGE);
DefineGlobalColor("good",   Color.GRAY);

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def c = close; def v = volume;
def upVol = if c > c[1] then v else 0;
def dnVol = if c < c[1] then v else 0;

def sumUp = Sum(upVol, LockbackPeriod);
def sumDn = Sum(dnVol, LockbackPeriod);
def upDnVolRatio = (sumUp / sumDn) - 1;
def Avg = MovingAverage(movAvgType, upDnVolRatio, maLength);
def Strength = ROUND((sumUp-sumDn)/(sumUp+sumDn)*100,2);

#-- Plots
plot movAvg = if !ShowMaLines then na else avg;
#movAvg.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
movAvg.AssignValueColor(if movAvg>thresholdLow then Color.CYAN else
                        if movAvg<-thresholdLow then Color.MAGENTA else Color.GRAY);
movAvg.SetLineWeight(2);

plot upRatio = if upDnVolRatio>0 then upDnVolRatio else 0;
upRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
upRatio.AssignValueColor(if upRatio>upRatio[1] then Color.GREEN else Color.DARK_GREEN);
plot dnRatio = if upDnVolRatio<0 then upDnVolRatio else 0;
dnRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
dnRatio.AssignValueColor(if dnRatio<dnRatio[1] then Color.RED else Color.DARK_RED);

def level1 = if isNaN(c) then na else thresholdLow;
def level2 = if isNaN(c) then na else thresholdMedium;
def level3 = if isNaN(c) then na else thresholdHigh;

#--Clouds
AddCloud(if !ShowCloud then na else if avg>level1 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg>level2 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg>level3 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg<-level1 then -level1 else na, avg ,Color.MAGENTA);
AddCloud(if !ShowCloud then na else if avg<-level2 then -level1 else na, avg ,Color.MAGENTA);
AddCloud(if !ShowCloud then na else if avg<-level3 then -level1 else na, avg ,Color.MAGENTA);

#---Label
AddLabel(ShowLabel and Strength>0, "Up Ratio(" + Strength + "%)", Color.GREEN);
AddLabel(ShowLabel and Strength<0, "Dn Ratio(" + Strength + "%)", Color.RED);

#--- END Code
 

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

try this, Up/Dn volume strength. very helpful indicator.

CSS:
# Volume Strength based on Up/Dn Vol Ratio indicator @CarusoInsights
# Created for UseThinkScript.com member
# Created by Sam4Cok@Samer800 - 11/2022

declare lower;
input ShowLabel = yes;
input ShowMaLines = no;
input ShowCloud = yes;
input movAvgType = AverageType.SIMPLE;
input maLength = 30;
input LockbackPeriod = 50;
input thresholdHigh   =  1.0;
input thresholdMedium =  0.5;
input thresholdLow    =  0.25;
####-----------------------------------------------------------------
DefineGlobalColor("high",   Color.DARK_RED);
DefineGlobalColor("medium", CreateColor(255,120,0));
DefineGlobalColor("low",    Color.LIGHT_ORANGE);
DefineGlobalColor("good",   Color.GRAY);

def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def c = close; def v = volume;
def upVol = if c > c[1] then v else 0;
def dnVol = if c < c[1] then v else 0;

def sumUp = Sum(upVol, LockbackPeriod);
def sumDn = Sum(dnVol, LockbackPeriod);
def upDnVolRatio = (sumUp / sumDn) - 1;
def Avg = MovingAverage(movAvgType, upDnVolRatio, maLength);
def Strength = ROUND((sumUp-sumDn)/(sumUp+sumDn)*100,2);

#-- Plots
plot movAvg = if !ShowMaLines then na else avg;
#movAvg.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
movAvg.AssignValueColor(if movAvg>thresholdLow then Color.CYAN else
                        if movAvg<-thresholdLow then Color.MAGENTA else Color.GRAY);
movAvg.SetLineWeight(2);

plot upRatio = if upDnVolRatio>0 then upDnVolRatio else 0;
upRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
upRatio.AssignValueColor(if upRatio>upRatio[1] then Color.GREEN else Color.DARK_GREEN);
plot dnRatio = if upDnVolRatio<0 then upDnVolRatio else 0;
dnRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
dnRatio.AssignValueColor(if dnRatio<dnRatio[1] then Color.RED else Color.DARK_RED);

def level1 = if isNaN(c) then na else thresholdLow;
def level2 = if isNaN(c) then na else thresholdMedium;
def level3 = if isNaN(c) then na else thresholdHigh;

#--Clouds
AddCloud(if !ShowCloud then na else if avg>level1 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg>level2 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg>level3 then avg else na, level1 ,Color.CYAN);
AddCloud(if !ShowCloud then na else if avg<-level1 then -level1 else na, avg ,Color.MAGENTA);
AddCloud(if !ShowCloud then na else if avg<-level2 then -level1 else na, avg ,Color.MAGENTA);
AddCloud(if !ShowCloud then na else if avg<-level3 then -level1 else na, avg ,Color.MAGENTA);

#---Label
AddLabel(ShowLabel and Strength>0, "Up Ratio(" + Strength + "%)", Color.GREEN);
AddLabel(ShowLabel and Strength<0, "Dn Ratio(" + Strength + "%)", Color.RED);

#--- END Code

Thanks, can you briefly describe what its doing?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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