instance variables

 

Hi All,
Are there instance variables in EA besides external variables,
or can I reset an external variable from EA code?
After declaring and initializing an external variable, how can i reset the value without clicking on smiley face and resetting it manually, how can i do it inside the code?

Thanks

 

external int test= 1;

int start(){

Print("Test = ", test); // prints out "Test = 1"

test = 2;

Print("Test = ", test); // prints out "Test = 2"

return(0);

}

 
phy wrote >>

external int test= 1;

int start(){

Print("Test = ", test); // prints out "Test = 1"

test = 2;

Print("Test = ", test); // prints out "Test = 2"

return(0);

}

Thanks phy, but if i switch to a different time frame or close and reopen metatrader or click on smiley face, in all those cases that variable shows the old value 1, the one it got during initialization.

How do i change it to a new value? Somewhere it stores those variables, when i click on smiley face and change it, EA will keep it even if i close and reopen EA. There should be some kind of methods, to set the value, similar like for the global variables GlobalVariableSet().

 

Probably being stored in the chr file in the Profile.

 
phy wrote >>

Probably being stored in the chr file in the Profile.

Thank you phy, I tired to search for a file which possibly has data from external variables, didn't find.

If I have two pairs in my account running the same EA, one pair is done for the day, and second is still allowed to place more trades. Where can I store that variable 'done for the day' and not lose the value if I switch for a minute to a different time frame?

Thanks

 

GlobalVariableSet() can store doubles outside the EA itself.

 
phy wrote >>

GlobalVariableSet() can store doubles outside the EA itself.

Thanks phy, but GlobalVariableSet() will store the value for a global variable not instance variable, one value in that variable for the whole system, let say I have $DoneForTheDay global variable, and set it to true. Then it will be true for all instances for the EA (for all pairs). If only one pair is done for the day and the other pairs are not, then I need to keep different values for each pair, same way as I have external variables set differently for each pare.

 

You can do it...

---

if(some condition is true) GlobalVariableSet(Symbol()+"_DoneForDay", 1);

---

if(GlobalVariableGet(Symbol()+"_DoneForDay") == 1) return(0);

 
phy wrote >>

You can do it...

---

if(some condition is true) GlobalVariableSet(Symbol()+"_DoneForDay", 1);

---

if(GlobalVariableGet(Symbol()+"_DoneForDay") == 1) return(0);

Thank you phy!

Reason: