DataSeries using Math.Max
Author: Panache
Creation Date: 2/8/2016 4:07 PM
profile picture

Panache

#1
I would like to create a data series containing the higher of the Open or Close.

CODE:
Please log in to see this code.

throws an error. Is there a way it can be done with a DataSeries Object?
profile picture

Eugene

#2
That's because Math.Max accepts two numbers, not two DataSeries. Try this:

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

Panache

#3
Thanks Eugene. I thought this might be one of those times when you have much simpler way to code something than the way I would do it.
profile picture

Eugene

#4
Well, with extension methods you can make it a one-liner. Still, you'd have to put that DataSeriesEx class somewhere (btw, one already exists in Community Components, providing access to methods like "DataSeries.ToList"). But then you use ".HighestOfTwo" as a native WealthScript method and don't even need a "using" directive:

CODE:
Please log in to see this code.


I think it makes sense to add HighestOfTwo and its opposite LowestOfTwo to C.Components.
profile picture

Eugene

#5
HighestOfTwo and LowestOfTwo have been added to Community Components 2016.03.
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).