A structure or class is basically the same thing, where a structure is simpler than a class.
Forum on trading, automated trading systems and testing trading strategies
How to choose between structure and class?
Vladislav Boyko, 2023.11.18 02:33
In this topic, I propose to either create some list of rules for choosing between a structure and a class, or state that both options are equivalent in terms of performance.
Class , you can do pointer stuff .
Hi everyone,
I'm trying to program cleanly,
what do you recommend for storing trade information and being able to manipulate it until the trade is closed?
I'm hesitating between creating a structure type variable, and creating a class with object manipulation to store all this information.
thank you in advance for your insights
Best Reguards,
ZeroCafeine 😊
I find embedding structures into classes is a good option - you can create methods within the struct or in the object depending on your need and you do not lose any OOP capabilities.
This also helps when I need to copy a set of fields - if they are grouped together in a structure it is just 1 line of codeI suggest you first learn to use structures, then classes without the use of pointers.
Once you know how to use them properly, then it will be easier to understand their pointer use.
Don't try to bite off more than you can chew.

- 2020.09.06
- www.youtube.com
No! That example code is about passing a parameter by reference. It is not about class object pointers.
I was not being unreasonable in my previous post. There was a reason why I stated that you should first understand structures and classes, before attempting to understanding object pointers.

- www.mql5.com
No - you can pass arrays, structures and objects to functions. They must be prefixed with the ampersand as it is "call by ref" only and you will get a complier error if you try otherwise.
With 'call by ref' you are indirectly passing a pointer to the variable/struct/object/array, as the function can overwrite the original memory space of the passed argument, with 'call by value' it takes a local copy.
The documentation has more info: Documentation on MQL5: Language Basics / Functions / Passing Parameters
I rarely use object pointers - if you master these basics you will find you can do mostly everything you need.

- www.mql5.com
Know that I'm here to learn, I always respect someone who teaches me something (It's part of my education), so you can talk to me however you want I'm not going to get angry 😊, but to answer you quickly you were not unreasonable but very unreasonable with your quote 😉,
As Albert Einstein said : "There's no such thing as a stupid question, only a stupid answer.",
I was not being unreasonable in my previous post. There was a reason why I stated that you should first understand structures and classes, before attempting to understanding object pointers.
I'll take the time to read your links later this week and come back to this post 😉.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
I'm trying to program cleanly,
what do you recommend for storing trade information and being able to manipulate it until the trade is closed?
I'm hesitating between creating a structure type variable, and creating a class with object manipulation to store all this information.
thank you in advance for your insights
Best Reguards,
ZeroCafeine 😊