Return Tuple
Author: pestocat2
Creation Date: 12/16/2020 12:20 AM
profile picture

pestocat2

#1
I'm trying to use the Tuple concept of returning more than one parameter from a procedure. I get this error " No overload for method 'GetTradeLoop' takes 2 arguments"
The code is the area is as follows
CODE:
Please log in to see this code.

I have 2 arguments there what am I missing.
The return code is
CODE:
Please log in to see this code.






Take Care.
profile picture

pestocat2

#2
A little progress, I removed "dblGainLoss, Buy_Disp" from the call GetTradeLoop. Now it compiles and runs, however no data coming back. I may have build the DataSeries items bar by bar.
profile picture

Eugene

#3
GetTradeLoop isn't defined to accept parameters but you are passing arguments when calling it.
profile picture

pestocat2

#4
Now that it's running I'm using PrintDebug() to see what is happening...looking good now.
profile picture

pestocat2

#5
In my latest strategy update, I wanted to display a DataSeries of Gain/Loss for the stock back-test. I generated the desired chart, but I couldn't access curve data value such to change indicator color when showing a loss. Cone suggested that I split the strategy into 2 parts and converting the For trading loop to a procedure. That worked and now I could display a chart with green and red colors depending on whether a gain or loss. However I had 2 more DataSeries that I also wanted to show and they also were generated in the For trading procedure. A procedure can only return one parameter. Requesting assistance, Eugene suggested I use a Tuple to return the items I want. A tuple can combine several parameters into a single package and thus return just one item. The difficult part is how to format the code so I could compile the strategy. With time, books, and using Google, I was able get the strategy to compile. The strategy now returns 3 DataSeries. I have attached a sample display. I generate the Buy - Sell Indicators by looking at several WL indicators e.g., Hull moving averages bar by bar and then either adding a one or subtracting a one and the plotting the result. Notice on the Gain/Loss chart that the curve changes to red when going below zero percent. The Tuple code to combine the 3 DataSeries into one package is shown below.
CODE:
Please log in to see this code.


The next part is to open the returned Tuple and get the Requested DataSeries. One needs to create a tuple and get the data, see below.
CODE:
Please log in to see this code.


The strategy uses Heikin-Ashi candlesticks to generate a Buy signal and the uses a trailing stop for a Sell signal.
Thank you so much to both Eugene and Cone for all the assistance. I have learned much in this process.
profile picture

LenMoz

#6
Another construct might be...
CODE:
Please log in to see this code.
profile picture

Eugene

#7
Looks good.
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).