Close at certain date and time

 

Hi Guys,



Due to the asynchronous opening and close time of different market, what's the function to extract the Close at certain date and time

eg close at 5.00 am for #NKD and USDJPY



Thanks in advance

ShinjiOno

 
Hi
I don't think there is a built in function to set an OrderClose() time
OrderSend() and OrderModify() has expiration features but only for pending orders not

So you would have to make your variable for datetime then create your condition

IE - if (datetime variable) OrderClose();

Of course more to it then that if your not familiar with making functions for this then you need to OrderSelect() the order first, then use your datetime condition, then OrderClose()

This should get you on the right track anyhow, and searching the forums and google for those features would give you plenty to work with.


Hope this helps
Happy hacking

 
Hi Agent86, thanks for the reply. However, I'm looking at the close price for eg. 5am for both #NKY and USDJPY. I'm not looking to close the order. Thanks for the reply anyway ShinjiOno
 
ShinjiOno: Due to the asynchronous opening and close time of different market, what's the function to extract the Close at certain date and time  eg close at 5.00 am for #NKD and USDJPY
  1. Create/get a datetime you want.
  2. Get the shift for that datetime
  3. Get the close for that shift.
#define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600
int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when % HR2400 );            }
datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when - TimeOfDay(when) );   }
//datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent();
//                                          return(DateOfDay(when) + HR2400);   }
datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent();
   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1);
                                       return( iTime(NULL, PERIOD_D1, iD1) ); }
:
datetime now = TimeCurrent();
#define HR0500 (5 * PERIOD_H1 * 60)  // 18000
datetime am05 = DateOfDay() + HR0500;
if(now < am05) am05 = Yesterday() + HR0500;

int iJpy = iBarShift("USDJPY", 0, am05);
double jpyClose5AM = iClose("USDJPY",0 iJpy);
 

Thanks alot!!!

Appreciate that

Reason: