Download MetaTrader 5

question

To add comments, please log in or register
theDUDE
43
theDUDE  
In an expert adviser, in the OnTick() function, is there a way to set a global variable that will retain its value it had during the previous call? I'm looking for a variable that won't re-initialize with each new tick.
onewithzachy
2271
onewithzachy  
theDUDE:
In an expert adviser, in the OnTick() function, is there a way to set a global variable that will retain its value it had during the previous call? I'm looking for a variable that won't re-initialize with each new tick.

Hi theDUDE,

Come on, you can solve this yourself :), don't kidding around, we know you can solve this, it just a matter of coding.

In any EA, CI or Script:

double My_Var = 0.0;  // this is set as global variable or static local variable

OnTick()
 {
 if (My_Var == 0.0) My_Var = 1.618;

 //--- codes and codes goes here
 if (re_initialize == true) My_Vars = 0.0; // re-initialize again on next tick.


 }

click that delete link dude :)

 

To add comments, please log in or register