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
Show me an example so that there is no confusion, then I will answer.
An example is simple. Suppose 15 "computer cycles" are spent on automatic initialization of the a1.strA member. I've come to a preliminary conclusion that 15 cycles are spent on initializing the b1.strB member as well. Is it correct?
In the CExpert class of the standard library, there are these guarded declarations
At the same time, the constructor of this object contains the following strings
I tried to create something similar in my class, but without any further initialization (like Init and InitXXX).
The compiler compiled everything without any warnings or errors, but when I tried to install the EA on the chart, it got a critical error 281 (Invalid pointer access) and the EA was deleted from the chart.
In this regard, I have some questions:
1. What should I do in the constructor (specify NULL or specify the pointer to the specific object)?
2. Is InitTrade type pointer initialization obligatory?
In the CExpert class of the standard library, there are these guarded declarations
At the same time, the constructor of this object contains the following strings
I tried to create something similar in my class, but without any further initialization (like Init and InitXXX).
The compiler compiled everything without any warnings or errors, but when I tried to install the EA on the chart, it got a critical error 281 (Invalid pointer access) and the EA was deleted from the chart.
In this regard, I have some questions:
1. What should I do in the constructor (specify NULL or specify the pointer to the specific object)?
2. Is InitTrade type pointer initialization obligatory?
1. Both of them are correct. It all depends on particular implementation of the class (not specifically CExpert). However, it's better to create dynamic objects in InitXXX method, which returns bool (because constructor doesn't return execution result and you'll have to to reset the initialization flag and then analyze it (the flag).
2. Of course it is. Otherwise, the critical error 281 (Invalid pointer access) will occur.
PS. Thanks by the way. I'll have to insert pointer checks before use.
An example is simple. Suppose 15 "computer cycles" are spent on automatic initialization of the a1.strA member. I've come to a preliminary conclusion that 15 cycles are spent on initializing the b1.strB member as well. Is this correct?
No, it's not about the clock at all. Well, or not really about the clock.
OK, then a very simple question: which is faster to initialise in time, member a1.strA or member b1.strB from the above example?
Or what to read "point-by-point"? There is physically no way to learn programming on a "machine-processor" level.
OK, then a very simple question: which is faster to initialise in time, member a1.strA or member b1.strB from the above example?
Or what to read "point-by-point"? There is physically no way to learn "machine-processor" level programming.
a1.strA will initialize faster because its initialization process is simply zeroing in place. For b1.strB a memory allocation will be made.
However, this difference is quite difficult to measure, as it is much less than one percent, taking into account the code around initialisation
which initialises faster
For b1.strB a memory allocation will be made.
Here you go, thanks - the missing link in my logic.
TheXpert, thanks for the help. Tried to explain the point in my own words. I agree that a truly correct question is asked by those who are in the know. But they usually don't ask my level questions :)
1. It is correct in both ways. It all depends on the specific implementation of the class (not specifically CExpert). However, it's better to create dynamic objects in InitXXX method, which returns bool (because constructor doesn't return execution result and we will have to reset/unset initialization flag and then analyze it (the flag).
2. Of course it does. Otherwise critical error 281 (Invalid pointer access).
PS. Thanks by the way. I'll have to insert pointer checks before use.
Thank you, now everything is in its place. However, there is one more question. Let's assume that error 281 occurs, but it is better that the Expert Advisor is not unloaded. What should I do?
Let me to clarify my question - What to do if 281 error occurs after all steps of initialization, but it would not affect the main work of Expert Advisor critically enough not to run it at all?
Suppose error 281 occurs, but it is desirable that the EA is not unloaded. What should we do then?
Let me clarify my question: What to do if error 281 occurs after all the steps of initialization, but it will not affect the main work of the Expert Advisor critically enough not to run it at all?
"Invalid pointer access" =="Attempting to access an invalid pointer"? If yes, then
An attempt to access an invalid pointer causes a programcrash. That's why there is a need to use the CheckPointer() function before using a pointer. A pointer may be invalid in the following cases