Plotting Up/Down Volume Ratio
Author: Tobey
Creation Date: 12/3/2009 7:29 AM
profile picture

Tobey

#1
I’d like to make a custom indicator to plot the Up/Down Ratio using the daily volume fro the last 50 days.

Up Volume would the volume on days, today’s close is higher than yesterday’s close.
Down Volume would the volume on days, today’s close is lower than yesterday’s close.

The formula comes from a article in Investors Business Daily.

In words the formula would be:

50 day sum of (if close > yesterday close,
then
Close * Volume
Else
0) / 50

Divided by

50 day sum of (if close < yesterday close,
then
Close * Volume
Else
0) / 50


What I don’t understand is how to create the if condition to use in a DataSeries that would allow me to plot the series on a chart.

Thank you for your help
Tobey
profile picture

Cone

#2
CODE:
Please log in to see this code.
profile picture

Tobey

#3
Hi Cone,

Thanks! I works great. I'll study it to see if I can understand how you did it.

Thanks Again
Tobey
profile picture

Cone

#4
The thing to understand is that a "new DataSeries" is a zero-filled DataSeries (WealthScript Programming Guide: DataSeries > Filling a Custom DataSeries > How to: Create a DataSeries filled with zeroes). So, the loop adds values to the appropriate bars of DataSeries upPV or dnPV. Values not added are already zero. Then the only thing left to do was to use the Sum.Series indicator and divide.

profile picture

Tobey

#5
Hi Cone,

Thanks! That's the kind of explanation that will help me understand the code in the future.

I’ve been trying to translate the Code

for(int bar = 1; bar < Bars.Count; bar++)

into English.

And I’ve bin looking in the manuals for the meaning of double in

double pv = Close[bar] * Volume[bar];

but I’m finding it had to get them translated into English as clear as you put it.

Thanks Again
Tobey
profile picture

Eugene

#6
QUOTE:
And I’ve bin looking in the manuals for the meaning of double in

You'll find that answered in any C# 101 book, tutorial or course -- as opposed to the Wealth-Lab manuals. It's a C# keyword.
profile picture

WEALTHPRO25

#7
i am trying to use the index lab selecting up/down volume ratio for a symbol from the data set, but i do no get any graph, can you help so i can use this option
profile picture

Eugene

#8
As "Up/Down Volume Ratio" is not affected by a known bug preventing some MS123 IndexDefinitions to load in "Most Recent" and "Date Range" mode, this must be something else. Your problem description is suboptimal as it's missing all the key items: steps you take, data loading settings and symbol and bar scale used etc. As I already suggested twice, "it doesn't work" just does not work:

Once and
Twice

P.S. Note that the Up/Down Volume Ratio calculation in Index-Lab is different from the formula above. As its description says, "The Up/Down Volume Ratio is up volume divided by down volume."
profile picture

WEALTHPRO25

#9
problem description, i created data set of one symbol "gild" and selected up/down volume index building, using fidelity as data provider, date range is monthly chart, when i select the created index option and open a new chart there is no graph
profile picture

Eugene

#10
The whole purpose of Index-Lab is to create indices built on multiple constituents of an index. This index will not function with only a single instrument.
profile picture

WEALTHPRO25

#11
OK, SO IF I WANT UP/DOWN VOLUME OF ONE SYMBOL, HOW CAN I SEE THE GRAPH, IS THE ABOVE CODE BY CONE THE BEST SOLUTION
profile picture

Eugene

#12
If the custom formula in post #1 makes sense, then I think so.
profile picture

WEALTHPRO25

#13
got it , thanks
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).