This is likely more of a C# question than a WL question but I think they're related
If I have a DataSeries of length n say, and I want to extract some middle portion of it (say, from the 4th element to the n-5th element) and treat it as a new DataSeries is there a way to do it.
My readings of C# inform me there is an Array.Copy method. Is there anything similar for a DataSeries?
Thanks for the help.
Size:
Color:
Why would one want to do it?
Size:
Color:
Why am I not surprised that you ask! ;->)
I am working with the EquityCurve. I have some methods which operate on it to give me some statistics I like.
These methods work on the entire series. I'd like to do some subsampling and rather than rewrite the methods to accommodate specific start and end dates, I thought I could "trick" the methods by passing along a reduced series.
Is that fair?
Size:
Color:
Well, there probably is no native WealthScript analogue of Array.Copy but you can devise an own method that loops through the EquityCurve and extracts the dates in between specific start/end dates into a new blank DataSeries. Or you could "convert" the EquityCurve into a double array first and then apply Array.Copy to this array.
Size:
Color:
Ok, Food for thought.
Thanks Eugene
Size:
Color:
QUOTE:
Or you could "convert" the EquityCurve into a double array first and then apply Array.Copy to this array.
Hello Eugene
May I ask what you meant by
"convert"? in the post above and how it could be accomplished?
I gather it is not simply a cast
So for example if I needed the Close DataSeries into a C# array of type double, can it be done without a for loop
Array.Copy can do the copy of only part of the array for me.
Thank you
Size:
Color:
Here's the function. Now you can do it without your own for loop.
CODE:
Please log in to see this code.
Size:
Color:
Thanks Cone
Of course this will work. I had thought from Eugene's post there was some way to do it without a for loop.
I guess there isn't. The "convert" in quotes led me to believe there was some "other" way.
Thanks again
p.s. woud you need Bars.Count to be replaced by ds.Bars.Count because conceivably you might be passing a DataSeries other than the current symbol? perhaps some external symbol (or a different time scale) that might not have the same number of bars as the current
Size:
Color:
You're right. I've replaced it with ds.Count.
Size:
Color: