I missed the functionality similar to iBarShift for MT4. Can you tell me how to do it?
And as far as I understand you should use CopyTime instead of Time[10]?
The analogue of ibarshift:
int iBarOnTime( string symbol, ENUM_TIMEFRAMES timeframe, datetime time, bool exact=false )
analogue of Time[]:
Time( int i )
There's a lot more out there that will come in handy:
double iHigh(string symbol,int tf,int ind) double High( int i ) double iLow(string symbol,int tf,int ind) double Low( int i ) double iClose(string symbol,int tf,int ind) double Close( int i ) double iOpen(string symbol,int tf,int ind) double Open( int i ) double HighOnTime( string symbol, ENUM_TIMEFRAMES timeframe, datetime time, bool exact=false ) double LowOnTime( string symbol, ENUM_TIMEFRAMES timeframe, datetime time, bool exact=false ) double CloseOnTime( string symbol, ENUM_TIMEFRAMES timeframe, datetime time, bool exact=false ) double OpenOnTime( string symbol, ENUM_TIMEFRAMES timeframe, datetime time, bool exact=false ) string SPeriod(ENUM_TIMEFRAMES tf) //символьное представление периода datetime iTime( const string symbol, int tf, int ind ) //+------------------------------------------------------------------+ //| Аналог Bars(), не требует предварительной синхронизации истории | //| Вход : symbol - символ в терминале | //| timeframe - таймфрейм | //| Выход : нет | //| Прим. : нет | //+------------------------------------------------------------------+ int BarsSinh( string symbol,ENUM_TIMEFRAMES timeframe ) //+------------------------------------------------------------------+ //| Произвести синхронизацию таймсерии с историей | //| Вход : symbol - символ в терминале | //| tf - таймфрейм | //| Выход : нет | //| Прим. : нет | //+------------------------------------------------------------------+ void SynhronizeSeries( string symbol, ENUM_TIMEFRAMES tf ) //+------------------------------------------------------------------+ //| Проверить наличие истории на дату start_date, если остуствует, | //| то произвести попытку загрузки | //| Вход : symbol - символ в терминале | //| period - таймфрейм | //| start_date - дата проверки истории | //| Выход : код результата выполнения операции подробнее | //| см. https://www.mql5.com/ru/docs/series/timeseries_access | //| Прим. : нет | //+------------------------------------------------------------------+ int CheckLoadHistory(string symbol,ENUM_TIMEFRAMES period,datetime start_date) //+------------------------------------------------------------------+ //| возвращает строкое значение периода | //+------------------------------------------------------------------+ string GetPeriodName(ENUM_TIMEFRAMES period)
If anyone is interested, I found an alternative.
int iBarShiftFast(string symbol, ENUM_TIMEFRAMES timeframe, datetime time) { datetime lastBar; SeriesInfoInteger(symbol, timeframe, SERIES_LASTBAR_DATE, lastBar); return(Bars(symbol, timeframe, time, lastBar) - 1); }
According to my measurements, acceleration compared to CopyTime variant is from 2 to 7 times (depending on input data). If you have any comments or bugs, please post them.
If anyone is interested, I found an alternative.
According to my measurements, acceleration compared to CopyTime variant is from 2 to 7 times (depending on input data). If you have any comments or bugs, please write.
Thank you. I will try it.
Or maybe this is the right way to do it now:
Or maybe this is more correct now:
And even faster and more correct (the first parameter must be NULL, it does not work with zero)
int bar = Bars(NULL, 0, t, 32000000000);
Because there is no need to execute theTimeCurrent() function unnecessarily
32000000000 is not from the current moment, but almost from the moment of 3000
And even faster and more correct (the first parameter must be NULL, it does not work with zero)
Because there is no need to execute theTimeCurrent() function unnecessarily
32000000000 is not from the current moment, but almost from the moment of 3000
And what about -1? This is an important moment...
What about -1? It's an important point...
I'm not sure what this is about?
The Bars function returns the number of bars. When we want to get the index of a bar with index 9 (sorry for the tautology), it will return 10, because the index of the first bar is 0.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I missed the functionality similar to iBarShift for MT4. Can you tell me how to do it?
And as far as I understand you should use CopyTime instead of Time[10]?