Download MetaTrader 5

can i write like this ?

To add comments, please log in or register
LEE Chun Wing
831
LEE Chun Wing  

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

 

can i write like this ?

that is the first time i use data struct 

 

thanks 

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

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


struct slow_strategy
{string symbol = "USDCHF"};


LEE Chun Wing
831
LEE Chun Wing  
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};
 

nerobot
85
nerobot  

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


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




LEE Chun Wing
831
LEE Chun Wing  
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 

Mihai Ionescu
1355
Mihai Ionescu  
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";
//...
LEE Chun Wing
831
LEE Chun Wing  
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 

Mihai Ionescu
1355
Mihai Ionescu  
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:) 

Alexey Da
Moderator
6683
Alexey Da  
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.
LEE Chun Wing
831
LEE Chun Wing  

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

To add comments, please log in or register