Download MetaTrader 5

OrderOpenTime date condition

To add comments, please log in or register
Gargoyle
13
Gargoyle  
Hello guys,

I am stuck coding a time filter in MQL4...

What I want to code is: 

if order open time is > a date...

So I understood I must use OrderOpenTime function, but how to write correctly the condition?

if(OrderOpenTime(TIME_DATE)>DATE){....... this is the format I am looking for...


Help is appreciated!

Thank you very much!
Marco vd Heijden
Moderator
6152
Marco vd Heijden  
Returns open time of the currently selected order.

datetime  OrderOpenTime();
datetime time_1=some_date_here;

if(OrderOpenTime()>time_1)
  {
   // do something...
  }
Make sure the order is selected by OrderSelect() first.
honest_knave
Moderator
2342
honest_knave  

You must first select the order using OrderSelect()

Then you can compare OrderOpenTime() to whatever date/time you need. 

OrderSelect - Trade Functions - MQL4 Reference
OrderSelect - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderSelect - Trade Functions - MQL4 Reference
honest_knave
Moderator
2342
honest_knave  
Sorry Marco, we were typing at the same time.
Marco vd Heijden
Moderator
6152
Marco vd Heijden  
No problem but your pic seems to be gone.
Gargoyle
13
Gargoyle  
Marco vd Heijden:
Make sure the order is selected by OrderSelect() first.

Thank you very much!


and in some_date_here, how must be written the date correctly? like 20170101, or 2017.01.01 or how?


thank you very much!
Marco vd Heijden
Moderator
6152
Marco vd Heijden  
Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
  • www.mql5.com
Language Basics / Data Types / Integer Types / Datetime Type - Reference on algorithmic/automated trading language for MetaTrader 5
To add comments, please log in or register