marcovth:
iBarShift() in mql4 but I don't believe there is an equivalent in mql5, use the search and have a look.
Hello ...
Is there a function that finds the (closest) bar-index for a certain given datetime?
Thanks.
Thanks ...
https://www.mql5.com/en/articles/81
int iBarShiftMQL4(string symbol, int tf, datetime time, bool exact=false) { if(time<0) return(-1); ENUM_TIMEFRAMES timeframe=TFMigrate(tf); datetime Arr[],time1; CopyTime(symbol,timeframe,0,1,Arr); time1=Arr[0]; if(CopyTime(symbol,timeframe,time,time1,Arr)>0) { if(ArraySize(Arr)>2) return(ArraySize(Arr)-1); if(time<time1) return(1); else return(0); } else return(-1); }
![Migrating from MQL4 to MQL5 Migrating from MQL4 to MQL5](https://c.mql5.com/36/1/migrating-from-mql4-to-mql5__1.png)
Migrating from MQL4 to MQL5
- 2010.05.17
- Sergey Pavlov
- www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello ...
Is there a function that finds the (closest) bar-index for a certain given datetime?
Thanks.