MQL4 - automated forex trading   /  

Forum

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

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

avatar
1106
puncher 2011.11.05 21:48 

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,



Protect Yourselves, Developers!

Protect Yourselves, Developers!

Protection of intellectual property is still a big problem. This article describes the basic principles of MQL4-programs protection. Using these principles you can ensure that results of your developments are not stolen by a thief, or at least to complicate his "work" so much that he will just refuse to do it.


avatar
4224
RaptorUK 2011.11.05 22:03 
bool AllowTrading=true;

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

avatar
1106
puncher 2011.11.05 22:23 
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,


avatar
4328
WHRoeder 2011.11.05 22:28 
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?

avatar
1106
puncher 2011.11.05 22:48 
no I did not yet

avatar
4224
RaptorUK 2011.11.06 00:36 
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 ;-)
Back to topics list  

To add comments, please log in or register