
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
Suppose we have
We know thatstart_time should be2018.04.28 23:00
So it turns out that the time is wrong here ?
Alexey, take a look at my example. I showed there line by line how the hourly time you pass is converted to the nearest time from the current bar.
Couldn't find a declaration of the variable type limit. My eyesight is weak.
Post 50, procedure OnCalculate
Post 50, OnCalculate procedure
Thanks, but which one is 50? Can you help me out with a link?
Thanks, but which one is the 50? Can you help me out with a link?
https://www.mql5.com/ru/forum/262864/page5
The link is just to the page. It says #50 in the title of the post. Your #74 ))
You havelimit=start_index-stop_index+1 written first, that islimit==1, and then where the division by 2 islimit=(int)(stop_time-start_time)/PeriodSeconds(_Period). One is not added. Zero is divided by the period.
Right,limit=start_index-stop_index+1is for i>0, i.e. for history calculation, and limit=(int)(stop_time-start_time)/PeriodSeconds(_Period) is for calculation on the current bar.
And the thing is, in fact, why our time is so crooked - if we have an hour timeframe, the dates must be round, both at the beginning and at the end - this is the real problem, that the bar time on the start date is somehow wrong!!!
Perhaps there is a problem here.
As start_time comes correct at this point
datetime start_time=rates[i].time;
Alexey, there is no "at the end". It's just a quantization. Exactly at 18:00 the bar opened, showed minimum and maximum and safely closed, in the same second.
For example, the bar opened at 18:00, so the initial time(start_time) will be 18:00 and the final time(stop_time) is supposed to be 19:00 for the hourly timeframe. Thus, the index between them will be different on the M1 timeframe. And in the code, the start and the end index are the same, which is not true.
Right,limit=start_index-stop_index+1is for i>0, i.e. for history calculation, and limit=(int)(stop_time-start_time)/PeriodSeconds(_Period) is for calculation on the current bar.
And the thing is, in fact, why our time is so crooked - if we have an hour timeframe, the dates must be round, both at the beginning and at the end - this is the real problem, that the bar time on the start date is somehow wrong!!!
Perhaps there is a problem here.
Since start_time comes correct at this point
And why are they round, if you first make CopyRates from hourly timeframe (it turns out round numbers), then pass to the procedureCreateFigure time from the current timeframe (time, which turns into Time) and Rates from hourly timeframe, and then look for an index in the array of current time?start_index=ArrayBsearch(Time,start_time);