Restrict EA to place orders during certain time frames and how to use news calender in EA

 

Hi, 

 i have a working EA finally, thanks to online reference and forum suggestions. Now, i want to restirct EA from running during the New York end and Sydney start time. How can i do this? will be using NY time as input to EA.

secondly i want to restrict EA from placings orders 30 mins before and and after importance news declarations which have "//" or "///" importance level as per new importance. How can i use such a feature in EA? Can EA get control of news and its importance level. I am interested in implementing importance level news of major currncies only - USD, GBP, EUR, JPY and AUD. 

 do suggest me some reference if you have for such usage, if you have examples please share it. I plan to addthese features to EA soon.  

 

Thanks

 
gurmeetb:

Hi, 

 i have a working EA finally, thanks to online reference and forum suggestions. Now, i want to restirct EA from running during the New York end and Sydney start time. How can i do this? will be using NY time as input to EA.

secondly i want to restrict EA from placings orders 30 mins before and and after importance news declarations which have "//" or "///" importance level as per new importance. How can i use such a feature in EA? Can EA get control of news and its importance level. I am interested in implementing importance level news of major currncies only - USD, GBP, EUR, JPY and AUD. 

 do suggest me some reference if you have for such usage, if you have examples please share it. I plan to addthese features to EA soon.  

 

Thanks

What do you mean by "start time" ?

To manage new in code, see this topic https://www.mql5.com/en/forum/11155

All about Calendar tab and Macro Economic Events.
All about Calendar tab and Macro Economic Events.
  • www.mql5.com
AnalysisWhat is Fundamental Analysis and how use MT5 for that.
 
angevoyageur:

What do you mean by "start time" ?

To manage new in code, see this topic https://www.mql5.com/en/forum/11155

Thanks for link for calendar - "can not define the events by priority" - was actually looking for this feature on same. Hope wait is only option to add this. 

BTW, any pointers to coding for start time ? Hope i am clear on same. I actually need to block EA from trading NY 5:00 PM to 7:30 PM. So, how can i add this restriction on EA?  

 
gurmeetb:

Thanks for link for calendar - "can not define the events by priority" - was actually looking for this feature on same. Hope wait is only option to add this. 

BTW, any pointers to coding for start time ? Hope i am clear on same. I actually need to block EA from trading NY 5:00 PM to 7:30 PM. So, how can i add this restriction on EA?  

If the time matches the time you don't want to trade; return from start() . . . in other words,  do nothing.
 
RaptorUK:
If the time matches the time you don't want to trade; return from start() . . . in other words,  do nothing.
Thank you, have it updated. 
 

One more quick question:

Is there a function available for giving me no of open trades for a particular symbol. I am aware of OrdersTotal() but it gives me all open trade count. Do we already have an API for orderCount based on Symbol or i need to write for loop for same?  

 
gurmeetb:

One more quick question:

Is there a function available for giving me no of open trades for a particular symbol. I am aware of OrdersTotal() but it gives me all open trade count. Do we already have an API for orderCount based on Symbol or i need to write for loop for same?  

In MT5 there can be only 1 position for a symbol. You can use PostionSelect to check that.
 
angevoyageur:
In MT5 there can be only 1 position for a symbol. You can use PostionSelect to check that.
okies...so i will add for loop to do same. I am surprised to see this behaviour for MT5
 
gurmeetb:
okies...so i will add for loop to do same. I am surprised to see this behaviour for MT5
You need to read more about the fundamentals of the way MT5 works . . .  it's not a secret,  for example: Orders, Positions and Deals in MetaTrader 5
Reason: