Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correct to do it differently at all?
int ShiftBar=0;
for(int cnt=0; cnt<100; cnt++)
{
int hour=TimeHour(iTime(Symbol(),PERIOD_M30,cnt));
if(hour==1)
{
ShiftBar=cnt;
break;
}
}
Print("ShiftBar= ",ShiftBar);
Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correctly done in a different way altogether?
For a more painless transition to mql5 in the future, it would be better to use functions that are used in both languages. For searching for the number of bars it is better to use
intBars(
string symbol_name, // имя символаENUM_TIMEFRAMES timeframe, // периодdatetime start_time, // с какой датыdatetime stop_time // по какую дату
);
Actually, iBarShift() will do the job better than cycle.
For a more painless transition to mql5 in the future, it is better to use the functions used in both languages. For searching for the number of bars it's better to use
The iBarShift() can handle this task better than cycle.
Yes, but the problem is in finding the nearest 01.00 hours. How will you find it? int iBarShift( string symbol,// symbol inttimeframe, // period datetimetime, // time ????????? bool exact=false // mode );
Nauris Zukas: Yes, but the problem is finding the nearest 01.00 hours. How do you determine this? int iBarShift( string symbol,// symbol inttimeframe, // period datetimetime, // time ????????? bool exact=false // mode );
If you want to make future migration to mql5 as painless as possible, use functions available in both languages. To search for the number of bars it is better to use
intBars(
string symbol_name, // имя символаENUM_TIMEFRAMES timeframe, // периодdatetime start_time, // с какой датыdatetime stop_time // по какую дату
);
In principle, iBarShift() can handle this task better than a loop.
Will return the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.
The only problem is that I never fill up my memory cell with such unnecessary things as what the obtained value will be equal to, given a bar with the specified time, or less by 1. I just check every time.
Returns the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.
The only problem is, I never clog my memory cell with unnecessary stuff like what the value will be equal to, including the bar with the specified time or less by 1. I just check every time.
This I all understand, but try to get into the question. How do you find the specified time - in my case you need to find the nearest 01.00 hours. How do you write it down? datetime start_time, // from what date ???
This I all understand, but try to get into the question. How do you find the specified time - in my case you have to find the nearest 01.00 hours. How do you write it down? datetime start_time, // from what date ???
datetime t=StringToTime("01:00");
int b=Bars(_Symbol, PERIOD_M30, t, TimeCurrent());
At the current time 17:08 it shows 33. I.e. the bar number with time 01:00 will be 32.
Through a file, for example...
if you don't mind, a little more detail.
if you don't mind, a little more detail.
To pull quotes, use the Copy functions:
https://www.mql5.com/ru/docs/series
Then https://www.mql5.com/ru/docs/files is a link to file operations.
Good evening, I'm making a "rails" pattern, but I can't get it to work.... can you see what's wrong? Thanks in advance.
And these conditions will never be met
Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correct to do it differently at all?
Good afternoon! The task is this - I need to determine how many bars there will be before the next 01.00 hours. I've done it so far with a loop, but maybe it's more correct to do it somehow with iBarShift? Maybe it's more correctly done in a different way altogether?
For a more painless transition to mql5 in the future, it would be better to use functions that are used in both languages. For searching for the number of bars it is better to use
Actually, iBarShift() will do the job better than cycle.
For a more painless transition to mql5 in the future, it is better to use the functions used in both languages. For searching for the number of bars it's better to use
The iBarShift() can handle this task better than cycle.
int iBarShift(
string symbol,// symbol
inttimeframe, // period
datetimetime, // time ?????????
bool exact=false // mode
);
Yes, but the problem is finding the nearest 01.00 hours. How do you determine this?
int iBarShift(
string symbol,// symbol
inttimeframe, // period
datetimetime, // time ?????????
bool exact=false // mode
);
Forum on trading, automated trading systems & strategy testing
Any questions for beginners on MQL4, help and discussion on algorithms and codes
Alexey Viktorov, 2017.07.27 13:54
If you want to make future migration to mql5 as painless as possible, use functions available in both languages. To search for the number of bars it is better to use
In principle, iBarShift() can handle this task better than a loop.
Will return the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.
The only problem is that I never fill up my memory cell with such unnecessary things as what the obtained value will be equal to, given a bar with the specified time, or less by 1. I just check every time.
Returns the number of bars between the specified time and the current time, if the current bar time is specified as stop_time.
The only problem is, I never clog my memory cell with unnecessary stuff like what the value will be equal to, including the bar with the specified time or less by 1. I just check every time.
This I all understand, but try to get into the question. How do you find the specified time - in my case you need to find the nearest 01.00 hours. How do you write it down?
datetime start_time, // from what date ???
This I all understand, but try to get into the question. How do you find the specified time - in my case you have to find the nearest 01.00 hours. How do you write it down?
datetime start_time, // from what date ???