Return more than one DataSeries
Author: pestocat2
Creation Date: 12/12/2020 6:58 PM
profile picture

pestocat2

#1
I have an object or procedure and I'm using the keyword "return" to push back a DataSeries to my display code. Is it possible return more than just one DataSeries from this object using return.
Thank you and Take Care.
profile picture

Eugene

#2
Sure a procedure can return a collection of DataSeries (Tuple, List or whatever) if your procedure generates multiple series. Have you seen some C# 101 books? It's a very basic feature described there for sure.

Wiki FAQ > How do I start with C# ?

Question is, why do you think you need to do it??
profile picture

pestocat2

#3
Eugene,
This goes back to my discussion on https://www.wealth-lab.com/Forum/Posts/Modifying-Heikin-Ashi-adding-stops-40508
I have more than one DataSeries that I would like to return to Display code of my strategy. BTW, what is the proper name of the code element where I use "return" to get back the DataSeries. Is it a procedure or object or what should it be called.
Take Care
profile picture

Eugene

#4
I know that it goes back there but it's too overloaded to try to comprehend. The code element is called a procedure and it can return anything from a DataSeries to a List<DataSeries> and more. Question is, what's the point in doing so when you can call that several times. Again, this is ABC of C# and if you want to master it, pick a tutorial or a book from the Wiki FAQ. Can you explain here in plain English why do you think it's needed?
profile picture

Cone

#5
If you need just two or a few series, you can use a void method (doesn't return a value) and pass [DataSeries] variable(s) by reference. Here's a quick example for 2 series. Add as many as you like.

CODE:
Please log in to see this code.


profile picture

pestocat2

#6
Cone,
How would this work in returning DataSeries from a procedure?
Take Care
profile picture

Eugene

#7
It already does return multiple DataSeries from a procedure. When you read the C# book that is coming it's going to be obvious. ;)
profile picture

Cone

#8
QUOTE:
How would this work in returning DataSeries from a procedure?
My example has a procedure named MakeMySeries(). Just follow the design pattern of the example. Inside of MakeMySeries (or whatever you want to name it) you just need to assign values to the "out" reference arguments ser1, ser2, etc. in any way you like. For the sake of brevity, I simply assigned to the Bars.Close series +/- 1.
profile picture

pestocat2

#9
Cone,
I was able to get your suggestion to compile and run. However the data returned was not correct. It looks as if the price data got into the data that was suppose to get out. Now I'm working on the Tuple return concept. My C# book has not been all that much help, it's still very confusing. But I have another book coming too.
Take Care
profile picture

superticker

#10
QUOTE:
It looks as if the price data got into the data that was suppose to get out.
This statement needs clarification; I don't follow. But there's nothing wrong with the solution in Post# 5; it should work. Notice that MakeMySeries(...) creates the output, but the calling Execute() block must first declare the storage for the output that MakeMySeries(...) will used. That's because the calling Execute() block "owns" these DataSeries even though the routine being called, MakeMySeries, creates them.

QUOTE:
working on the Tuple return concept. My C# book has not been all that much help
Hold everything. For the C# 6.X compiler, the Tuple is a .NET framework topic/function, not a C# compiler topic/function. Now for the C# 7.X compiler, the Tuple may be handled at the compiler level itself as an advanced compiler feature. But an introductory C# book won't cover advanced, new C# 7.0 compiler features.

My "wild guess" is that you're using the C# 6.X compiler, so you need to be referring to your .NET 4.6-4.8 framework book, not your C# 6.X compiler book concerning Tuples. We are talking about two different books here. .NET framework Tuple

I still think you would have more flexibility making separate calls for each DataSeries you need returned much like WL indicators work. These multiple DataSeries solutions lock you into a design pattern (paradigm), which is not flexible. You want to avoid inflexible paradigms. Also, returning a single DataSeries is much easier and less complicated. Keep your code simple.
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).