It's better to use OOP to prevent a mess in code. A lot of trading frameworks (with different complexity and capabilities) are already published on this site.
ohh, I guess I misunderstood the point of Your comment, I guess i just got the idea now...
Did you mean that the function void Check_Positions() could also defined only once not inside each strategy ?
I haven't thought about it myself as I've been testing and learning mql5 trading logic, but it's probably a good idea as the task of the function serves the same purpose in every strategy... I'll deal with it as soon as I have time.
I've now had a few hours to think about this topic. For easier management, it is of course a good idea to put such a function in its own responsible class so that we don't have to search for its location later, since we can do it with only a very small additional cost. At the same time let the variables of the each strategy be left processing to the strategy itself. Because each strategy is inherently very different. There is no point in bringing them higher, it would only create unjustified additional costs and additional confusion.
There is no point in making functions like this virtual or implementing it in any other way with deeper OOP principles. In this particular case, it would do more harm than good. I believe that the best thing to do to make a specific situation more comfortable would look something like this:
but my original question was much easier, whether it is still a good solution to use the PositionSelectByTicket() function to track active positions and whether this function can fail in certain situations? mql5 gurus know this for sure...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
It's better to use OOP to prevent a mess in code. A lot of trading frameworks (with different complexity and capabilities) are already published on this site.
ohh, I guess I misunderstood the point of Your comment, I guess i just got the idea now...
Did you mean that the function void Check_Positions() could also defined only once not inside each strategy ?
I haven't thought about it myself as I've been testing and learning mql5 trading logic, but it's probably a good idea as the task of the function serves the same purpose in every strategy... I'll deal with it as soon as I have time.
I've now had a few hours to think about this topic. For easier management, it is of course a good idea to put such a function in its own responsible class so that we don't have to search for its location later, since we can do it with only a very small additional cost. At the same time let the variables of the each strategy be left processing to the strategy itself. Because each strategy is inherently very different. There is no point in bringing them higher, it would only create unjustified additional costs and additional confusion.
There is no point in making functions like this virtual or implementing it in any other way with deeper OOP principles. In this particular case, it would do more harm than good. I believe that the best thing to do to make a specific situation more comfortable would look something like this:
but my original question was much easier, whether it is still a good solution to use the PositionSelectByTicket() function to track active positions and whether this function can fail in certain situations? mql5 gurus know this for sure...