MQL4: datetime type variable used in expert advisor - ???

 

I would like to define datetime type varibale (called MacroEvent) for setting planned macro event in comming week.

For example on Friday 11th November 2011, on 11:11:11 will be publicated very important message for financial markets.

datetime MacroEvent = D'2011.11.11 11:11:11';


Then I would like to hold up my EA robot 8 minutes before and 4 minutes after publication the MacroEvent. It means that the EA can not open orders between: 2011.11.11 11:03:11 - 2011.11.11 11:15:11 and all the opened orders should be closed in the meantime. Besides, I would like to make this variable as the external variable (editable).

Can anybody give me any example of the expression for MQL4 syntax how to program something like that?

Thanks in advance.


Rgds,

 
bool AllowTrading=true;

if(TimeCurrent() > (MacroEvent - 8 *60) && TimeCurrent() < (MacroEvent + 4 *60) ) AllowTrading=false;
else AllowTrading=false;
If AllowTrading is false . . . don't trade . .
 
RaptorUK:
If AllowTrading is false . . . don't trade . .

Hi Raptor,


Thank you for the answer. Good idea but you have made a little error. The proper syntax should be:

bool AllowTrading=true;

if(TimeCurrent() > (MacroEvent - 8 *60) && TimeCurrent() < (MacroEvent + 4 *60) ) AllowTrading=false;
else AllowTrading=true;


The next problem is: HOW TO MAKE MacroEvent variable as extern value?

Probably the

datetime MacroEvent = D'2011.11.11 11:11:11';

is not proper initalization of this variable for change MacroEvent value via input parameters window (F7)?


Rgds,

 
puncher:

The next problem is: HOW TO MAKE MacroEvent variable as extern value?

Probably the

is not proper initalization of this variable for change MacroEvent value via input parameters window (F7)?

Did you try it?
 
no I did not yet
 
puncher:

Hi Raptor,

Thank you for the answer. Good idea but you have made a little error. The proper syntax should be:

Yep, copy and paste error . . . you got the idea though, that was the main thing ;-)