Hi,
I want to count number of bars from a specified date to current time. For ex. on 2 Mar 2018 12:00PM I want to count how many bars would be there in a timeframe from 1 Mar 2018 00:00 AM. I want to know which function I should use and how? I think its 'Bars', but I don't know what values to put in or how to use it. Can someone kindly help me and tell me the solution?
Thanks,
D_S_
Look at the iBarShift documentation.
Use the sample code from provided on that page.
- docs.mql4.com
Hi Drazen,
Thanks for reply. As I can understand iBarShift is used to find a bar at particular time. But, I didn't knew how to use it as I am not an expert programmer in MQL4.
I want to count number of bars from a specified date/time to current time. For ex. if specified time is 1 Mar 2018 07:00PM, then while calculating the indicator value on 2 Mar 02:12 AM the bar count should be taken 8 (in hourly chart), 9 at 03:01 AM, and so on.
So, according to you iBarShift will count number of bars from current time to a specified time and return a number, right?
Thanks very much for your help. I am really grateful.
Hi Drazen,
Thanks for reply. As I can understand iBarShift is used to find a bar at particular time. But, I didn't knew how to use it as I am not an expert programmer in MQL4.
I want to count number of bars from a specified date/time to current time. For ex. if specified time is 1 Mar 2018 07:00PM, then while calculating the indicator value on 2 Mar 02:12 AM the bar count should be taken 8 (in hourly chart), 9 at 03:01 AM, and so on.
So, according to you iBarShift will count number of bars from current time to a specified time and return a number, right?
Thanks very much for your help. I am really grateful.
It's not according to me, it's according to the documentation:
Returned value
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 exact parameter).
Which part of the above sentence you don't understand?
Also, did you run the sample from the article? It's only 3 lines of code.
If you can't figure out that code sample you should probably go to the freelance section and ask there for help.
Hi,
I want to count number of bars from a specified date to current time. For ex. on 2 Mar 2018 12:00PM I want to count how many bars would be there in a timeframe from 1 Mar 2018 00:00 AM. I want to know which function I should use and how? I think its 'Bars', but I don't know what values to put in or how to use it. Can someone kindly help me and tell me the solution?
Thanks,
D_S_
I think the right function for you is Bars(). There are two overloadings for that function and the second for your task
int Bars( string symbol_name, // symbol name ENUM_TIMEFRAMES timeframe, // period datetime start_time, // start date and time datetime stop_time // end date and time );https://docs.mql4.com/series/barsfunction
I think the right function for you is Bars(). There are two overloadings for that function and the second for your task
Don't post MT5 documentation links in the MT4 forum. https://docs.mql4.com/series/barsfunction
Don't post MT5 documentation links in the MT4 forum.
It's not according to me, it's according to the documentation:
Which part of the above sentence you don't understand?
Also, did you run the sample from the article? It's only 3 lines of code.
If you can't figure out that code sample you should probably go to the freelance section and ask there for help.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I want to count number of bars from a specified date to current time. For ex. on 2 Mar 2018 12:00PM I want to count how many bars would be there in a timeframe from 1 Mar 2018 00:00 AM. I want to know which function I should use and how? I think its 'Bars', but I don't know what values to put in or how to use it. Can someone kindly help me and tell me the solution?
Thanks,
D_S_