
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
Is time really that reliable ?
The granularity of Time[0] is in seconds, so if
within the first second you get two ticks, it would
count as two newbars. :/
The Time[] array holds the open time of each bar. By the time the second tick comes the time var is already updated to the new Time[0]
The Time[] array holds the open time of each bar. By the time the second tick comes the time var is already updated to the new Time[0]
yes, you're right. My bad.
again with new bar detection. i received the following message in Experts log (after MT4 upgraded)
"2015.09.23 12:45:58.276 sazon_4waves_03 XAUUSD,M5: array out of range in 'sazon_4waves_03.mq4' (89,12)"
here is the code of that area
https://gyazo.com/0ba6dd69466d430a1cd99339d56b9f8a(picture just to show line 89)
so the error when accessing Time[0]... is it my problem only, some more reliable methods of detecting new bars were found, or this is problem of a new terminal?
edited, thank you, GumRai.
Why don't you just paste the relevant code using the SRC button?
Then we don't have to go look at another webpage to see what you are talking about.
danik,
If you are only calling this function from OnTick, then it is a concern.
I would think that you could only get this error if there is absolutely no history loaded for the chart symbol.
How often do you get this error? Is it just at opening the terminal?
may be a work around, but it shouldn't really be necessary
Can be used to count new bars in OnTick() and or OnTimer() of multi symbol and or multi time-frame EA. For example:
(**as is, on the first call it will report a large number but will be accurate after that)
{
datetime cbartime=iTime(cursym,curtf,0);
if(cbartime!=nbartime[oslc,otlc])
{
datetime bardiftime=cbartime-nbartime[oslc,otlc];
ulong bardif=bardiftime/(curtf*60);
nbartime[oslc,otlc]=cbartime;
if(curtf==PERIOD_D1 && DayOfWeek()==0 && bardif>=1) bardif--; //Do not count Sunday bars on a daily chart
//Print(bardif," new bars found.");
return (short)bardif;
}
return 0;