is there a way to load a file into the memory during optimization and each

 

subsequent pass not having to load the file again ?

(load a constant structure once from a file and work on that , sort of)

tx 

 
 Lorentzos Roussos: subsequent pass not having to load the file again ? (load a constant structure once from a file and work on that , sort of) tx 

Consider incorporating the data into the compile cycle. Generate an include file of all that data in that file, in what ever structures it needs as global variables, and include it in the compilation for your testing,

Then remove it for the final executable that will work with an actual file.

 
Fernando Carreiro #:

Consider incorporating the data into the compile cycle. Generate an include file of all that data in that file, in what ever structures it needs as global variables, and include it in the compilation for your testing,

Then remove it for the final executable that will work with an actual file.

Won't it need "static generation" in that include file ? otherwise i'll be loading again , not from the drive but still .

 
Lorentzos Roussos #: Won't it need "static generation" in that include file ? otherwise i'll be loading again , not from the drive but still .

Globally scoped variables that are initialised during the declaration are equivalent to static variables and are "baked"/"hard-coded" into the executable file.

Just don't change their content at runtime, as sometimes during odd circumstances the Strategy Tester carries those changes over to the next pass. Consider them as constant data.

EDIT: I think you can even declare them as "const" global variables so as not to allow changes but I've never tested that in MQL.

EDIT2: Yes, "const" works correctly and prevents changes to the global variables.

const double dbTest = 1.34;

void OnStart() {
   dbTest = 2.34;
};

 
Lorentzos Roussos #: Won't it need "static generation" in that include file ? otherwise i'll be loading again , not from the drive but still .

Maybe I misunderstood your question. Yes, you have to declare global variables of the structures and initialise their data with literal constants of the data.

struct SData {
   string sName;
   double dbValue;
};

const SData g_oData[] = { { "EUR", 1.12 }, { "USD", 1.0 } };
 
Fernando Carreiro #:

Maybe I misunderstood your question. Yes, you have to declare global variables of the structures and initialise their data with literal constants of the data.

i thought so .

i though you were talking about global variables for a minute .

Thank you .

 
Lorentzos Roussos #: i thought so . i though you were talking about global variables for a minute . Thank you .

Yes, that is what I am talking about. Is there a problem with using globally scoped variables?

 
Fernando Carreiro #:

Yes, that is what I am talking about. Is there a problem with using globally scoped variables?

i must put structures into these : ?

https://www.mql5.com/en/docs/globals

Documentation on MQL5: Global Variables of the Terminal
Documentation on MQL5: Global Variables of the Terminal
  • www.mql5.com
Global Variables of the Terminal - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Lorentzos Roussos #: i must put structures into these : ?

Terminal variables are for interprocess communications (e.g. EA to EA) and persistent storage (recovery). Your use is neither.

 
Lorentzos Roussos #: i must put structures into these : ? https://www.mql5.com/en/docs/globals

Don't use Global Terminal Variables during testing. Besides being slow and file based, they are shared amongst everything—live running EAs, EAs being tested, multiple passes in optimisations, etc.

Instead, use globally scoped variables as I have described, in your code at compile time.

 
Fernando Carreiro #:

Don't use Global Terminal Variables during testing. Besides being slow and file based, they are shared amongst everything—live running EAs, EAs being tested, multiple passes in optimisations, etc.

Instead, use globally scoped variables as I have described, in your code at compile time.

I'll need to iterate through the members of structures , i'll go ahead and assume the only way is custom arrays with members , or , dedicated function to export code .

Thanks

William Roeder #:

Terminal variables are for interprocess communications (e.g. EA to EA) and persistent storage (recovery). Your use is neither.

Thanks