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
And how are you going to make trailing adapt to different parameters?
Preferably lead to a specific task. Such a description is not very clear. In my practice, the algorithm does not change from changing external parameters. It is made universal in advance for any values of these parameters. Therefore, it is not very clear what you mean. Describe it on a concrete example.
Thanks to the OOP, the main program is very brief and clear. This is just the first example that comes to mind. If you need to calculate the number of orders frequently, the advantages are obvious. It is hard to understand it at the first time. But functions, even with parameters, were also once a difficulty
Let's try on some particular task. If you have, please provide.
Specific task. The customer has ordered an Expert Advisor for two MAs, which would include all trailing variants available in the code base, but would not slow down in the tester.
The EA should also have the prospect to be updated with new trailing variants in the future (at low cost).
Thanks to OOP, the main program is very short and clear. This is just the first example that comes to mind. If we need to calculate the number of orders frequently, the advantages are obvious. It is hard to understand it at the first time. But functions, even with parameters, were also once a difficulty
I don't understand, why not make a function "int Number_orders()" that will always do the above loop and return the counter value "SELL"?
For example:
Why do we need a class here?
For example, 100 trailing stop variants need to be crammed into one Expert Advisor. When programming procedurally, you get a mess like this:
100 identical code fragments. When the program is running, it will usually include only one trailing stop. The remaining 99 ifs will just consume resources.
Now for the OOP variant. During Expert Advisor initialization, we scale the array with pointers according to the number of trails, we create objects only for the included trails. As a result, the following code will work all the time:
If one trailing bar is enabled, then cnt=1, i.e. there is nothing unnecessary.
Make an array of function names, choose the name from the index and access.
OOP has nothing to do with it. This is a language limitation they are trying to solve with OOP
I haven't tried it, but for example you can't make a non-typical language without an OOP.
I don't understand why not make a function "int Number_orders()" which will always do the above loop and return the counter value "SELL"?
Specific task. The customer has ordered an Expert Advisor for two MAs, which would include all trailing variants available in the code base, but would not slow down in the tester.
And with a prospect of adding new trailing variants in the future (not expensive).
By refining the class, I will get x.SELL x.BUY x.ALL and whatever else is needed. And it will be very easy to address them. OOP classes - for simplicity
Make an array of function names, pick a name from the index and call it.
It has nothing to do with OOP. This is a language limitation they are trying to solve with the help of OOP.
There is no function call by the name defined as a string. And in those languages where it exists, it's done through a hash of a table, that is, it's a terrible brake.
A normal way to solve this problem would be to use pointers to functions (about this I wrote here). But why use pointers alone, there is a more convenient way - OOP, which allows not only to take advantage of function pointers, but also conveniently structure data and code.