Errors, bugs, questions - page 2652

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
Why are you fighting? Why don't we do something useful together?
Stanislav posted a fantastically useful script in KB. It easily creates archives with MQL-files and resources.
I have an EA with hundreds of mqh-files. Using the script I can now easily transfer my EA to the source code, control the versions and share with others.
Thank you. I'll try to break it down and check the options with chart events.
Have a look at the thread, recently dealt with the issue in detail -https://www.mql5.com/ru/forum/327888
Anton Shpilyuk: 2) Циклом-перебором до тех пор пока дата не будет совпадать(минус - скорость работы) это так?
On the subject of "get bar index by time copyrates"
Horror, it really is! The task was to get the bars of M1 timeframe in the indicator, although the indicator itself works on M5 timeframe.
1. we had to initialize the desired timeframe in OnCalculate() to load it before the start of the indicator (after the initialization the FirstStartFlag = false;). Remember, in indicators, if it is not loaded, it will give -1 or not fully loaded, so we check how much is loaded, if not enough, we go to the beginning ofreturn(0);
declare array MqlRates rates[]; at the beginning, wherecnt_bars*5; - recalculate the number of bars M5 in M1
After that, we update the historical data on M1 in the body of the required function every time we perform calculations:
Further, in the loop of M5 bars, we do an embedded loop of searching for the index of the corresponding M1 bar,time[s] being the current M5 bar of the timeframe under calculation:
And then we use this index to find the necessary M1 bar data, in my case it is rates[IndexRates-5].time and rates[IndexRates-k-4].close
Thank goodness this nested loop goes through the bars quickly, even on a 90-day history. But I would like to be able to search for bar indexes in the rates[].time array like a binary search using the ArrayBsearch function
Brief gist of the bug:
When there is class inheritance A <= B <= C <= D
and two overloading functions are implemented, for example, one with parameter A* and one with parameter B*,
. When passing a C* or D* object into such a function, the MQL causes a "ambiguous call to overloaded function" compilation error.
Question: Is there a more sensible workaround to this idiotic bug than the one presented above?
Here we go with more "Why MQL != C++"...
Why comment on something if you haven't got to the bottom of it?
Why comment on something if you haven't got to the bottom of it?
Because I have long ago opened a topic for such clarifications (because no one like you could do it yourself).
And then that the difference in languages has nothing to do with errors or bugs!
The MQL is demoralising little by little:
Brief gist of the bug:
When there is class inheritance A <= B <= C <= D
and two functions are implemented, for example, one for A* and one for B*,
. When passing a C* or D* object to such a function, the MQL causes a "ambiguous call to overloaded function" compilation error.
Question: Is there a more sensible workaround to this idiotic bug than the one presented above?
Well, STL is not transposed one-to-one. You have to look closely at the specifics here. The easiest way is to write all the possible functionality in the abstract methods in a base class or interface, and in the descendants - either implementation or =delte. In this case, you need to pass pointers or references of the same type to the methods of the base class. Although there is an unavoidable evil in the form of a virtual table, but it's better to arrange the architecture in such a way that there won't be expensive dynamic_cast branching anywhere.