trouble with global variables..

 

Hi everyone,


Maybe you guys can help me.. So I assign a global bool variable at the beginning of my script and assign it to false.. But when I run my start function in the tester though, it treats it as if it were 'true'.. I'm probably missing something pretty basic. Would appreciate your help..


extern bool Martingale = false;


//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{

if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();

{if (Martingale)Recouperate();}

//----
}

 
heyarn:

Hi everyone,


Maybe you guys can help me.. So I assign a global bool variable at the beginning of my script and assign it to false.. But when I run my start function in the tester though, it treats it as if it were 'true'.. I'm probably missing something pretty basic. Would appreciate your help..


extern bool Martingale = false;


//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{

if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();

{if (Martingale)Recouperate();}

//----
}

Because you set it to external variable, therefore it is controlled via terminal. You must have once changed the variable to true via the terminal. To solve this, you either remove the extern from your program, so it will always take whatever you set in your program. Otherwise you need to change it via the terminal...

 
migmof:

Because you set it to external variable, therefore it is controlled via terminal. You must have once changed the variable to true via the terminal. To solve this, you either remove the extern from your program, so it will always take whatever you set in your program. Otherwise you need to change it via the terminal...



Thanks Migmof!!

Reason: