Sharing data between optimizations; how?

Questions about MultiCharts and user contributed studies.
User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Sharing data between optimizations; how?

Postby JoshM » 08 Dec 2011

I'm trying to come up with a way to have an "unique identifier" for each optimization run, needed in exporting the data.

My thought was to put the time of the optimization in a GlobalVariable, and let each optimization run look to see if there such a GlobalVariable, and if yes, use the numeric value of that GlobalVariable, and if not, generate it.

However, this does not seem to work, since each optimization run can't read/find/use the GlobalVariable.

With this code:

Code: Select all

Variables:
backtestTimeGV(0), gvName("");

backtestTimeGV = el_datetodatetime(CurrentDate) + el_timetodatetime_s(CurrentTime_s);
gvName = Text(GetStrategyName, "test");

Print(TimeNow, "backTestTimeGV: ", FormatTime("HH:mm:ss", GVGetNamedDouble(gvName, 0)));

// If the global variable does not exist, set it to the current time
if (GVGetNamedDouble(gvName, 0) = 0) then
value75 = GVSetNamedDouble(gvName, backtestTimeGV)

// If it does exist, use the value of the global variable
else
backtestTimeGV = GVGetNamedDouble(gvName, 0);

Print(Spaces(3), "backTestTimeGV after: ", FormatTime("HH:mm:ss", backtestTimeGV),
Spaces(3), "GlobalVariable value: ", FormatTime("HH:mm:ss", GVGetNamedDouble(gvName, 0)));
I get the following output (First error occurs in bold, when the GlobalVariable returns zero, while before that it's set to 7:20:10):
06-12_07:20:10 backTestTimeGV: 00:00:00
backTestTimeGV after: 07:20:10 GlobalVariable value: 07:20:10
06-12_07:20:10 backTestTimeGV: 07:20:10
backTestTimeGV after: 07:20:10 GlobalVariable value: 07:20:10
06-12_07:20:10 backTestTimeGV: 07:20:10
backTestTimeGV after: 07:20:10 GlobalVariable value: 07:20:10
06-12_07:20:10 backTestTimeGV: 07:20:10
backTestTimeGV after: 07:20:10 GlobalVariable value: 07:20:10
06-12_07:20:11 backTestTimeGV: 00:00:00
06-12_07:20:11 backTestTimeGV: 00:00:00

backTestTimeGV after: 07:20:11 GlobalVariable value: 07:20:11
06-12_07:20:11 backTestTimeGV: 07:20:11
backTestTimeGV after: 07:20:11 GlobalVariable value: 07:20:11
06-12_07:20:11 backTestTimeGV: 07:20:11
backTestTimeGV after: 07:20:11 GlobalVariable value: 07:20:11
backTestTimeGV after: 07:20:11 GlobalVariable value: 07:20:11
06-12_07:20:13 backTestTimeGV: 00:00:00
backTestTimeGV after: 07:20:13 GlobalVariable value: 07:20:13
06-12_07:20:13 backTestTimeGV: 07:20:13
06-12_07:20:13 backTestTimeGV: 07:20:13
06-12_07:20:13 backTestTimeGV: 07:20:13
backTestTimeGV after: 07:20:13 GlobalVariable value: 07:20:13
backTestTimeGV after: 07:20:13 GlobalVariable value: 07:20:13
backTestTimeGV after: 07:20:13 GlobalVariable value: 07:20:13
06-12_07:20:14 backTestTimeGV: 00:00:00
06-12_07:20:14 backTestTimeGV: 00:00:00
06-12_07:20:14 backTestTimeGV: 00:00:00
06-12_07:20:14 backTestTimeGV: 07:20:14
Thanks in advance for any suggestions :)

Regards,
Josh

Return to “MultiCharts”