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
In that case, unambiguously CopyRates from the first bar 10s. And not to be called every tick, but enough at appearance of a new bar.
How do I know if a new bar has appeared without CopyRates? I mean, you have to catch the new bar event first. Without CopyRates is it possible? I'm a little confused).
That's what it means, I have never dealt with this topic on MT5. Please understand)).
Oh, Vladimir. Although I blurted it out, but unfortunately, I didn't make a reservation. If we need only opening price or time, for example, there's no need to use CopyRates(), in this case CopyOpen or iOpen is quite enough... respectively CopyTime or iTime. It is chosen according to your religious preferences.
And I'll add my caveat: In terms of performance costs, there is no appreciable difference. Accordingly, only religious biases remain.The fxsaber was checking CopyRates() cost - it's more expensive than getting the required property separately. It doesn't apply to the situation when we need to get all prices at once.
And how do I know that a new bar appeared without CopyRates? I mean, you need to catch the new bar event first. Is it possible to do it without CopyRates? I'm a little confused).
Without paying attention to anything, monitor the appearance of a new bar and call CopyRates
There are a lot of different functions and ways of detecting a new bar on the site.
How do I know if a new bar has appeared without CopyRates? I mean, you have to catch the new bar event first. Without CopyRates is it possible? I am a little confused).
That's what it means, never dealt with this topic on MT5. Please understand.))
The easiest way is to compare the opening time of the current bar. If it is not equal to the previously memorised one - have a new bar - do what needs to be done on the new bar and memorise this time for the next check.
Without paying attention to anything, we track the appearance of a new bar and call CopyRates
There are a lot of different functions and ways of defining a new bar on the site.
fxsaber did a CopyRates() cost check - it is more expensive than getting the required property separately. This does not apply to the situation where you need to get all prices at once.
The easiest way is to compare the opening time of the current bar. If it is not equal to the previously memorised one - have a new bar - do what needs to be done on the new bar and memorise this time for the next check.
So, you call the CopyRates on every tick? Otherwise, how would you know, that the opening time of current bar has changed?
you can either class CNewbar, or search the forum for NewBar
SZZ: whole article!https://www.mql5.com/ru/articles/159
Igor, you need to go to the first grade. They teach the letters there and after you learn it you will understand the difference between CopyRates and CopyBuffer.
Here's a better suggestion to solve this problem WITHOUT CopyRates
OK, the usual...oops, oops...and not a single line of code ))))
I cited my example to show that it's not always convenient (and seldom necessary) to obtain an array of consecutive OHLC. In practical tasks we usually need to obtain a selection of OHLC values from different bars (indicators are not included)
Alright, take care!
So, so on each tick call CopyRates? Otherwise, how do we know that the opening time of the current bar has changed?
Yes, on every tick we check the time:
And in a nutshell, it's like this:
I just wrote it on my hand - to show the idea, not the accuracy of writing
So, on every tick we should call CopyRates? Otherwise, how to know that the opening time of the current bar has changed?
if(prevTime!=iTime(...))
{
// current bar open time changed
}
prevTime=iTime(...);