Up Down Volume indicator
Author: kbellare
Creation Date: 7/22/2014 9:37 AM
profile picture

kbellare

#1
I'm trying to build a Up Down Volume indicator which adds volume on Up bars and subtracts on Down bars - the code below doesn't compile - error message is "The best overload method for Math.Sign has invalid arguments; can't conver from WealthLab Data Series to sbyte"
- Please suggest how to fix the code

Note - OBV indicator doesn't have a period parameter to specify time period over which to sum up the up down volume.


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

Eugene

#2
Using Math.Sign would be nonsense because there's no such overridden operator in the DataSeries class. Math.Sign returns the value of sign for every double value whereas you're passing an entire DataSeries.

Consequently, you can simply loop through the DataSeries bar by bar and store the intermediate result as explained in the WealthScript Programming Guide > DataSeries > Filling a Custom DataSeries > Example 2.
profile picture

WEALTHPRO25

#3
can you please help with the code for up volume to down volume ratio, thanks
profile picture

Eugene

#4
profile picture

Eugene

#5
In a duplicate thread, Darrell__ suggested:


Maybe I am missing something, but looking at the source code for the UpDownVolume indicator in the Community Indicators, I don't see any reference to volume. It just appears to be taking a ratio of "up" days verse "down" days.

Wouldn't the indicator need something to Bars.Volume prior to using the Sum.Series function?
profile picture

Eugene

#6
Darrell, you're right of course. Thank you for spotting the bug. It will be fixed in upcoming release of Community Indicators.
profile picture

superticker

#7
In looking at the current (Oct 2017) Community Indicators solution for the UpDownVolume indicator, the line
CODE:
Please log in to see this code.
adds an unnecessary division to this solution, which slows the calculation down.

Honestly, Cone's solution cited in post #4 above would be the fastest solution using the FOR loop. That solution avoids the extra division and a call to the Math.Sign() function. This alternative solution also employs two less, intermediate DataSeries, so there's less garbage collection overhead afterwards. Just a thought.
profile picture

Eugene

#8
Thanks Mark, that's the change I've already checked in for v2017.11: replace that block of code with Cone's solution from post #4.
profile picture

superticker

#9
QUOTE:
the change I've already checked in for v2017.11
Thanks for all the great user support!

One of the reasons I explored using Wealth-Lab two-and-a-half years ago was because of the active user forum. This responsiveness adds a great deal of value to the product.

One improvement that can be done with the Wealth-Lab documentation is to add hyperlinks to the Wealth-Lab User Guide. By "hyperlinks", I don't necessarily mean external hyperlinks into the WL wiki as you're probably thinking (although this is a good idea too), but rather internal hyperlinks within a supplemental part of the Wealth-Lab User Guide. In other words, fold some of the forum discussions into a supplemental section of the WL User Guide.

I would not make the main reading thread of the User Guide any longer. Rather I would scatter hyperlinks throughout this document to unlock these hidden supplemental sections and examples (extracted from the forum). The goal here is the let WL User Guide readers discover ideas better that they would never otherwise consider.
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).