Download MetaTrader 5
To add comments, please log in or register
Share your programs. That will improve your rating.
Frenchytrader
281
Frenchytrader 2014.09.24 08:53 

Hi all,


I'm not used to OnTimer() however, the EA refreshes every 2 minutes given by  EventSetTimer(60*2);


I would like to modify this EA, but it seems not working as usual:

Example

   if(TimeCurrent()>0) { bool test = true;} else{ test = false; }

If I do this, I got an error: "Test - Undeclared identifier"


So i have to do this:

   if(TimeCurrent()>0) { bool test = true;} else{ bool test = false; }

=> This is really weird.


I tried to add the Start()... but I got the same error?


While if i do this into any other EA... it works fine:

   if(TimeCurrent()>0) { bool test = true;} else{ test = false; }



Please help


Cheers

Keith Watford
Moderator
8014
Keith Watford 2014.09.24 08:57  

Declare the bool outside of {} if you are going to reference it in more than one{}

 

bool test;

if(TimeCurrent()>0) { test = true;} else{ test = false; }
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.09.24 08:57  
bool test;

if(TimeCurrent()>0) { test = true;} else{ test = false; }
Just declare it on global.
Frenchytrader
281
Frenchytrader 2014.09.24 09:51  
deysmacro:
Just declare it on global.
Thx : )
/
To add comments, please log in or register