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
However, when it comes to large calculations, iBarShift is inappropriate there because we work with arrays. In fact, iBarShift and other similar functions are intended for rare calls.It is irrational to loop them. We just get the array in CopyTime and quickly find everything. That's why the test example is of little use in real practice, unless of course the coder is a dummies ) And I don't think it's worth bothering for the sake of dummies ).
I think it is more logical to wrap your function into a class. Then you won't have to check the symbol/period at each call. You will have a different object for each time series.
I'm not arguing. It's just that these functions were created when there was no built-in iBarShift and Bars was glitchy.
Personally, I need these functions to control the programme and charts with the mouse. I also create synthetic TFs with logarithmic scale and these functions are very useful there. They are necessary in solving the problem of pattern recognition and significantly speed up calculations. Such a synthetic TF contains the entire history of a symbol and contains only 3000 bars.
I am disappointed with the Bars and iBarShift functions. MQ can't get them up to scratch. They cure one thing and cripple another.
I realised that these are rudimentary functions and it is better to forget about them like a terrible dream.
Let them remain for students and conservatives.
I think it is reasonable to use the search of bar number by time through the usual search in the time[] array.
For example, it can be done with the help of such a function:
Yes, you need an array. But personally, I always have it at hand and it is updated with every tick. That's why I don't even need to form it.
And this function is ten times faster than the original iBarShift.
An example of searching for the bar number by time in an array of 100 000 items by the half division method:
Fix. If you go beyond the existing history, it returns the wrong position:
Result:
The fBarShift() function in this case returns the total number of bars, which is not a correct position.Fix. If you go beyond the existing history, it returns the wrong position:
Result:
The fBarShift() function in this case returns the total number of bars, which is not a correct position.I don't get it, it returns -1, as it should be.
Judging by the code, there is no search for the required bar, it is calculated. And if the history is broken?
What do you mean by the words "Judging by the code"?
Is it just your imagination or have you studied it thoroughly?
It was a long time ago, but as I remember, there was a calculation only when it was appropriate, i.e. when the history is 100% not broken and there are no holes. This is easily verified by checking the time difference between bars. At the expense of this is a gain in speed. Check it if you don't believe me.
Now this code is faster than the standard iBarShift, but not significantly (20-50%, earlier it was 10 times faster). Already MQ fixed the code. So we can say that this code is not so relevant anymore.
I don't get it, it returns -1 as it should.
This is the return code of the CopyOpen() function
And the fourth parameter is missing here:
What do you mean, "Judging by the code"?
Is it just your imagination or have you studied it thoroughly?
It was a long time ago, but as I remember, there was a calculation only when it was appropriate, i.e. when the history is 100% unbroken and there are no holes. This is easily verified by checking the time difference between bars. At the expense of this is a gain in speed. Check it if you don't believe me.
Now this code is faster than the standard iBarShift, but not significantly (20-50%, earlier it was 10 times faster). Already MQ fixed the code. So we can say that this code is not so relevant anymore.
I used the code from the first page. There are no cycles, so only calculation (excluding stupid variants). I'm not saying it's wrong, everything is correct except for one exception.
I used the code from the first page. There are no loops, so only calculation (excluding stupid variants). I'm not saying it's wrong, everything is correct except for one exception.
You don't need loops there, because the standard Bars() function is used, and the essence of the algorithm is to minimise its use through calculations with stored data of previous calls to the function in static variables.
I fixed one error (changed - to + in the fBarShift function). It turned out to be fixed in my code, but I must have forgotten to post it. Updated. Version 1.04.
The purpose of this code was to fight the bug that was in the Bars() function. The speed increase was a "side" effect. Now this bug is gone and they have significantly improved the speed. So there is no sense in this library now.