I have a question: how to get the index of the bar where I placed order in the past(ticket # is known.).

 

I have a question: how to get the index of the bar where I placed order in the past(ticket # is known.).

thanks

 
zeeyeetee: I have a question: how to get the index of the bar where I placed order in the past(ticket # is known.).

By using the "Open Time" of the order and then searching for that time within the bars. You can use the iBarShift() function for that:

 
Fernando Carreiro:

By using the "Open Time" of the order and then searching for that time within the bars. You can use the iBarShift() function for that:

o, yeah, order ticket # --> orderselect --> OrderOpenTime() --> iBarShift() --> bar index

thx Fernando,

iBarShift - Timeseries and Indicators Access - MQL4 Reference
iBarShift - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
Index of the bar which covers the specified time. If there is no bar for the specified time (history "gap"), the function will return -1 or the nearest bar index (depending on