I exported a bunch of balance curves for different assets in a loop during training. When I read them back in, they don't have the correct asset identifier. Instead they all get the same asset identifier as the first asset in the loop. Here's a small script to demonstrate (uncomment the first #define statement and Train to export balance curves, then comment the first #define statement and Test to read them back in):
#define WRITECURVES
#define FILENAME "Log\TestCurves.bin"
typedef struct curve
{
string Name;
int Length;
var *Values;
} curve;
curve Curve[6];
function run()
{
#ifdef WRITECURVES
set(PARAMETERS|LOGFILE);
StartDate = 2016;
EndDate = 2016;
BarPeriod = 1440;
Curves = FILENAME;
while(asset(loop("EUR/USD", "AUD/USD")))
{
int trades = optimize(1, 1, 3, 1);
reverseLong(trades);
}
#endif
#ifndef WRITECURVES
byte *Content = file_content(FILENAME); // read in balance curves
if(!Content) return; //nothing to read
int i,j,N = 0;
while(N<6 && *Content)
{
// extract next curve
string Name = Content;
Content += strlen(Name)+1;
int Size = *((int*)Content);
int Length = Size/sizeof(var); // number of values
Content += 4;
var *Values = Content;
Content += Size;
// store curve and print its name and length
Curve[N].Name = Name;
Curve[N].Length = Length;
Curve[N].Values = Values;
printf("n%s: %d",Curve[N].Name,Length);
N++;
}
quit();
#endif
}
Printed to the Zorro GUI, I have the name associated with each curve. Here's the output after running this code:
TestCurves compiling...........
TestCurves_EURUSD_1_1: 180
TestCurves_EURUSD_1_2: 180
TestCurves_EURUSD_1_3: 180
TestCurves_EURUSD_1_1: 180
TestCurves_EURUSD_1_2: 180
TestCurves_EURUSD_1_3: 180
Quit
Expected:
TestCurves compiling...........
TestCurves_EURUSD_1_1: 180
TestCurves_EURUSD_1_2: 180
TestCurves_EURUSD_1_3: 180
TestCurves_AUDUSD_1_1: 180
TestCurves_AUDUSD_1_2: 180
TestCurves_AUDUSD_1_3: 180
Quit
Is there anything obvious that is incorrect in my script?
Thanks for any help.