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
Yes, here's another question that keeps coming up and has no clear answer. When you need to inherit your own class - what's better to do, inherit it or write a new extended version of your class.
It all depends on the general idea of what you want in the end, imho
if you plan to use the class somewhere else, you need to make it complete without inheritance
in my example, the CError class can get GetLastError(), unset with a description and return the value (int) of the error. I plan to use it everywhere, anyway, it only has a constructor that defines the language in a static variable and the case that returns the error text
But there is another useful method - bool ServerDisable(); - it defines server availability (multiplatform MT4/МТ5 code), very good function, it seems to be needed somewhere else in the code, but I thought, that I will use it for trade operations all the same - I put it in COrder class
.....
and if I want to use it for trailing? .... - plenty of space for imagination, but in the end it will be used as an object in COrder - where else could it be used?
imho, everything looks cumbersome, it's easier to include the service function library with the linker, and the compiler won't include the unused parts into the executable by itself
the whole class would be quite compact in procedural style, i showed an example for a function to open an order that can store in static constants the order volumehttps://www.mql5.com/ru/forum/85652/page17#comment_12805083
Is it really important to stay within limits? If it's important to stay within limits, you can write functions too.
I was answering in the context of your message that if you don't use classes, you'll have to bother with inconvenient call signatures. I showed that you don't have to bother.
What prevents me from sending the name of the symbol to the constructor, making the class flexible and versatile? You don't consider the possibility of portfolio trading as a matter of principle?
considering everything,
But so far I have stuck with research - now I'm almost ready to research 1000 and 1 ways of MM and all sorts of tricks with order systems )))
But I still think it would not be too flexible in the end, I have already written 2 times above that a procedural style + small classes with well-tuned functions of order handling would be better.
i will switch to testing my ideas for now and then i will see what i edit often in the code and what i leave untouched
.....
What if I want to use it for trailing? .... There is more room for imagination, but in the end it will still be used as an object in the COrder - where else could it be used?
Trailing bars are separate because they have nothing to do with the main logic. They may or may not exist at all.
***
Trailing bars and other similar maintenance functions should be made as descendants of one class, and their instances should be created in an array. If a function is enabled, an instance is added to the array and executed. If all of the functions are disabled, the array is empty and unnecessary ifs are not executed. You can insert at least 100 trailing bars into the EA, and it will not affect the speed of its execution.
That's not the way to do it. You have to at least call both Bid() and Ask(). Your code looks like just a variable, making it appear that its value remains unchanged, when in reality it is not.
alas, it has always been done this way, in MT4 it is still Bid and Ask and no whims of the Creator to ruin this simple use and getting current prices ;)
I have the following scheme where I haven't experienced any problems.
are we talking about this code?https://www.mql5.com/ru/code/22770
really like the implementation. really good for tester and optimizer, i will probably use it as a base, the code is short and readable, to be honest i am surprised to read your code, you have much more sophisticated style of writing, i usually plug and play, i know i can not understand the logic
alas, it has always been like that, in MT4 it remains Bid and Ask and no creator's whims destroy this simple use and getting current prices ;)
But their values are invariable within the current event processing (unless you call RefreshRates forcibly of course). So they are variables, not functions. And your functions look like variables
Give FPs a real task of managing and processing arrays of hundreds of megabytes or gigabytes of data and all their fairytale message model(data is immutable) will go to hell.
These are theorists, just in time to break out of real-world tasks and broadcast in their fictional universe :) telecom stories are dumbass data passes.
In fact, the only chance to fight complexity is to pack it into objects.But their values remain unchanged within the current event processing (unless you call RefreshRates forcibly). So, they are variables, not functions. And your functions look like variables
I don't even know how to explain the problem discussed in your example, I'll try to explain it humanly - for me, as a person who had the first Pentium-90 PC, it pains to see that in order to get a convenient use, an extra function call, which implies putting values of registers on stack, will be added... and ...here we go.
I know that now everything is cached repeatedly at the processor level, and I suspect that compiler developers will make the "function call from function call" more efficient
then your example should look like this:
Or like this:
Vasiliy, this article would be very useful for you - not to torture yourself by squeezing out OOP for the sake of OOP.
I have an idea of functional framework for MT. There will be almost no OOP there. Only functions, "monads" and other pseudo FP functionality. I'm writing everything in quotes, since it's impossible to make full-fledged FP in MQL.
Comments are unnecessary.
you do not like each other so much, or maybe it's the opposite of 2 gays looking for a way out for yourselves)
i liked your articles by the way, the expert's are lame, weak, but i like him just as much,
and I'm not gay.