Up/Down Volume Ratio

This indicator attempts to capture the ratio of rising price volume to falling price volume. The display is an average of up bar volume divided by down bar volume. The mid line is the 50/50 ratio. A divergence between price and the indicator can signal non-confirmation of the trend. (Note: Initial positing of the code had some lines missing)

Up/Down Volume Ratio

Up/Down Volume Ratio

# UPDOWNVOLUMERATIO
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 19 Jan 2009

declare lower;

input period = 10;
input smoothingPeriod = 3;
input priceChangeWeighted = NO;
def delta = absValue(close-close[1]);
def multiplier = if(priceChangeWeighted, delta,1);
 
plot maxLine = 80.0;
plot minLine = 20.0;
maxLine.setDefaultColor(color.BLUE);
maxLine.setLineWeight(2);
minLine.setDefaultColor(color.BLUE);
minLine.setLineWeight(2);
plot midLine = 50.0;
midLine.setDefaultColor(color.WHITE);
midLine.setLineWeight(2);
 
DEF up = if(close > close[1], volume*multiplier, 0);
DEF down = if(close < close[1], volume*multiplier, 0);
DEF upvol = sum(up, period);
DEF downvol = sum(down, period);
DEF ratio = (100.0*(upvol/(downvol+upvol)));
DEF UPDVR = HullMovingAvg(ratio,smoothingPeriod); 
 
DEF lineColor = if(UPDVR >= 80.0, 6, if(UPDVR < 20.0,5,1));
DEF plotData = UPDVR;
plot VolumeRatio = UPDVR;
VolumeRatio.AssignValueColor(getColor(linecolor));
VolumeRatio.setLineWeight(3);
VolumeRatio.setPaintingStrategy(paintingStrategy.HISTOGRAM);
plot VolumeRatioLine = UPDVR;
VolumeRatioLine.AssignValueColor(getColor(if(linecolor != 1, linecolor, 9)));
VolumeRatioLine.setLineWeight(2);
This entry was posted in Indicator and tagged , , , . Bookmark the permalink.

6 Responses to Up/Down Volume Ratio

  1. fiki says:

    I´m trying to understand this indicator. “is an average of up bar volume divided by down bar volume”. an average of what? how many bars?
    thanx

  2. thinkscripter says:

    If a bar is green its volume is added to a running sum of “Up Volume” and vice versa. The input parameter “period” is the number of bars the sum is carrying. The ratio is then just the Up/Down for that period.
    Eric

  3. avi elik says:

    hi, great job, i’m trying to copy the indicator to TOS ut i get some eror in the code, any advise.

    thanks.

    • ThinkScripter says:

      Make sure you are using the copy/paste icons that appear in the upper left of the code window. Do not try and manually select the code and copy it as this will not work.
      -Eric

  4. J-Train says:

    Thanks Eric, this is the best forgot about divergence study of the lot….dont know why it took me so long to re-look at it…my question is, is there a way you could plot a dot or somthing on the uper chart or on study to show divergence….will pay a fee for this…. I know nothing about code…..so nobody try and tell me how to do it

    thanks
    The J-Train

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>