try this, Up/Dn volume strength. very helpful indicator.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
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