MQL4 - automated forex trading   /  

Forum

instance variables

Back to topics list To post a new topic, please log in or register

avatar
5
viola 2008.08.18 09:05 

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

article

Interview with Harry Brinkhuis

To my findings a Take Profit of 42 and a Stop Loss of 84 is the right combination for Phoenix. They are part of what I call the balance between settings, timeframe, Stop Loss and Take Profit. Other people that were testing Phoenix tried to change Take Profit and Stop Loss and got very different results. They somehow changed "The Balance"!


avatar
2462
phy 2008.08.18 14:33 

external int test= 1;

int start(){

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

test = 2;

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

return(0);

}


avatar
5
viola 2008.08.18 17:45 
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().


avatar
2462
phy 2008.08.18 17:56 

Probably being stored in the chr file in the Profile.


avatar
5
viola 2008.08.18 18:39 
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


avatar
2462
phy 2008.08.18 18:49 

GlobalVariableSet() can store doubles outside the EA itself.


avatar
5
viola 2008.08.18 19:00 
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.


avatar
2462
phy 2008.08.18 19:27 

You can do it...

---

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

---

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


avatar
5
viola 2008.08.18 20:40 
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!

Back to topics list  

To add comments, please log in or register