can i write like this ?

 

struct slow_strategy
{string symbol = {"USDCHF"} };

 

can i write like this ?

that is the first time i use data struct 

 

thanks 

 
struct slow_strategy {
  string symbol = "USDCHF";
  //int stuff1;
  //double stuff2;
  //double stuff3[100];
}
This works with me
 

You can do it like that, but don't but the {} around the string:


struct slow_strategy
{string symbol = "USDCHF"};


 
nerobot:

You can do it like that, but don't but the {} around the string:


 

thanks all of you

i find out that {} is use for set all the structure_name member to "USDCHF" , does it?

like  

FILETIME  access_ft = {0};
SYSTEMTIME access_st = {0};
 

 

You would use {} if you were trying to fill up an array on construction:


char name[] = {'U', 'S', 'D', 'C', 'H', 'F'};




 
nerobot:

You can do it like that, but don't but the {} around the string:

 

the code you mention still have compile error:  '=' - variable is expected 

at line 2

 

struct slow_strategy
{string symbol = "USDCHF"};

 how to solve?

thanks 

 
kelly:

the code you mention still have compile error:  '=' - variable is expected 

at line 2

 

 how to solve?

thanks 

well then just declare it first, and then give symbol the value USDCHF
struct slow_strategy
{
string symbol;
};
//...
slow_strategy ss;
ss.symbol = "USDCHF";
//...
 
ifmihai:
well then just declare it first, and then give symbol the value USDCHF

thanks ifmihai, it works now

i turn out that i have declare ss as a object to structure (slow_strategy )

 

ss= object 

 
kelly:

thanks ifmihai, it works now

i turn out that i have declare ss as a object to structure (slow_strategy )

 

ss= object 

I am not familiar with objects in mql5...yet.

but it's good you worked it out:) 

 
kelly:

thanks ifmihai, it works now

i turn out that i have declare ss as a object to structure (slow_strategy )

 

ss= object 

Please, publish your code. As far as i see it is not a top secret, so you can share your code here.
 

I turn out that the problem come from  have not declare ss as a object to structure (slow_strategy )

that is

slow_strategy ss;

is missing in my  .mq5  file

Thankyou to all of you

Reason: