How to get the amount of bars since the order is open!?

 

Could somebody please be so kind and teach me how to make a function to get the amount of bars since the order is open!?

For example, if I bought a EUR/USD on 9/2, then today such function should return 10 in a daily chart, 240 (more or less) in a hourly chart, and so on.

Much appreciated!!!

 
PiggyChu620:

Could somebody please be so kind and teach me how to make a function to get the amount of bars since the order is open!?

For example, if I bought a EUR/USD on 9/2, then today such function should return 10 in a daily chart, 240 (more or less) in a hourly chart, and so on.

Much appreciated!!!

Check the iBarShift function. You need to input inside the time the trade was opened .

 
  1. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  2. iBarShift