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
Thank you, I have to fix my code also when exact is true, as I misunderstood this parameter. English documentation for iBarShift is wrong.
I think this is my error too, iBarShift should return bar which contain specified time (not with exact open time).
Could I use your function in my library (with your copyrights, of course)? If it is faster and correct, why should I reinvent the wheel?)
I think this is my error too, iBarShift should return bar which contain specified time (not with exact open time).
Could I use your function in my library (with your copyrights, of course)? If it is faster and correct, why should I reinvent the wheel?)
Thank you, I have to fix my code also when exact is true, as I misunderstood this parameter. English documentation for iBarShift is wrong.
The mql5 bug is on Bars() function, I reported it to Service Desk.
Build 880 fix the bug on Bars(), and all is working well now.
on m2 with m1 the values at trudy, for some reason have values not -1, and at zero bar there is a return to the 1st bar.
The function is crooked in at least two places:
1) if(time>LastBar)
return(0);
If exact=true, the logic should return -1 in case time does not explicitly belong to the last bar, i.e. if time>LastBar+PeriodSeconds(timeframe).
2) if(CopyTime(symbol,timeframe,time,1,checkcandle)==1)
...
return(-1);
Again, if exact=false, the nearest bar should be returned, in this case Bars(symbol,timeframe)-1.
I think there is a minor bug in your code:
If the the last tick 'opens' a new bar then if(time>LastBar) becomes false - because now time == LastBar
And later we land here:
And now shift == 0 which returns -1 instead of 0!
So I think this:
should be changed to
Calli
I think there is a minor bug in your code:
If the the last tick 'opens' a new bar then if(time>LastBar) becomes false - because now time == LastBar
And later we land here:
And now shift == 0 which returns -1 instead of 0!
So I think this:
should be changed to
Calli
Your correction would work too, but the case 'time==LastBar' is processed as a "normal" case.
The statement
if(time>LastBar)was added as a bug fix if time is greater than current bar 0 time.