Hi im new to MQL5 but need some help in getting the bar inde of the last order

 

Hi please help ive read a few articles relating to orders ect. but what i need is to know how many bars (timeframes) away was the last order


i need to do this so that i can identify what the bar index is of the last order placed and is still open. Thgis is so i can loop through the bars since the last order still open.


Thanks in advance

 
cghrmauritius:

Hi please help ive read a few articles relating to orders ect. but what i need is to know how many bars (timeframes) away was the last order


i need to do this so that i can identify what the bar index is of the last order placed and is still open. Thgis is so i can loop through the bars since the last order still open.


Thanks in advance

See iBarShift in this article (pt.18). Use the open time of your last order as time parameter.
 
angevoyageur:
See iBarShift in this article (pt.18). Use the open time of your last order as time parameter.
Sorry to be Dumb here but how do i get the order time from my last order please?
 
cghrmauritius:
Sorry to be Dumb here but how do i get the order time from my last order please?
How do you place your orders ? Simply set a datetime variable with the time you placed your order.
 
angevoyageur:
How do you place your orders ? Simply set a datetime variable with the time you placed your order.

Hi thanks for this but i keep getting

'iBarShift' - function not defined

code

long create_time_msc=PositionGetInteger(POSITION_TIME_MSC);
        
int shift=iBarShift(_Symbol,PERIOD_M15,create_time_msc,false);

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
 
cghrmauritius:

Hi thanks for this but i keep getting

'iBarShift' - function not defined

code

long create_time_msc=PositionGetInteger(POSITION_TIME_MSC);
        
int shift=iBarShift(_Symbol,PERIOD_M15,create_time_msc,false);

iBarShift is a MQL4 function, did you include the code that implement this function for MQL5 to your code ?
 
angevoyageur:
iBarShift is a MQL4 function, did you include the code that implement this function for MQL5 to your code ?
Hi yes i did but i get a return of 0 constantly
 
Thanks i have it cured now thanks a lot for your help
 
cghrmauritius:
Thanks i have it cured now thanks a lot for your help
You are welcome.