Wanting to call shift value for bar order was opened on?

 
Hello,

I want to call the shift value for the bar when the order was opened. So if I opened a new order 10 minutes ago, I want to be able to call shift value (10) for 1 minute bars. This is the code I was using, but it does not work........

OrderSelect(1,SELECT_BY_POS);
opentime=TimeToStr(OrderOpenTime(),TIME_DATE|TIME_MINUTES);
open_time=D'opentime';
shift=iBarShift("EUROUSD",PERIOD_M1,open_time);
Print("shift from open time bar",shift);

Do you know any easy method to call this shift variable?

Currently I am calculating a bar counter i.e. Floor(Time[0] and OpenTime / 60 seconds) - but the problem occurs in respect of missing bars over the weekend - which causes the bar counter to not be precise enough.

Do you know if an easier way - perhaps using the iBarShift function?

Thank you.

Kind regards,

RJF
 
Try this:

 OrderSelect(1,SELECT_BY_POS);
 openordertime = OrderOpenTime();
 ibar = iBarShift(NULL, 0, openordertime, true/false);
 // ibar is the bar where the open order occurred, unless there is no bar available, then -1 or nearest bar is returned; check the documentation.
Reason: