On one application of the OOP

 

I am writing an EA to a client and the situation is as follows. There is no clear TOR for all the items, but there are ideas he wants to test. That is, the work is closer to research.

He says, I do not even know what to do, there are variants of inputs, I want to try them, can I do that? I will have to write several variants of the Expert Advisor? And entries by volume obviously cannot fit into one function and they should be born dynamically by market. In other words, there may be 1... N. I am making a simplified description of the situation.

Let's create a base class where everything remains unchanged and from this class we will have descendants with changed behavior.

- And what is a class?

The client understands MQL a little, but is not a programmer. I started to explain, but he did not understand.

I found a picture on the Internet of the classification of animal species. I said to him: "Let's simplify it and assume that all of them evolved from each other".

I say - our base class would be Ancient flagellates. Has basic functionality, just the essentials. And from it, we'll have Protozoa, Multicellular, etc. And each descendant will contain all functionality of its parent.

- Oh, I see! And even the Mammals will have the functionality of the Ancient flagellates, am I right?

- Yeah, that's right.

Now I'm thinking how this case would be optimally used in a tester, the strategy is not scalper or ticking, for a tester is suitable. Also in the frightening riddles of who the Suckers are ))

classes

**

 
Alexey Volchanskiy:

...

I say - our base class would be Ancient flagellates. It has basic functionality, just the essentials. And from it we will give birth to Protozoa, Multicellular, etc. Each descendant will contain all functionality of its parent.

...

Unfortunately, the idea of inheritance turned out to be a stick with two ends. You may hurt yourself unintentionally. That's why it's better to use inheritance in a very limited way.
 
Vasiliy Sokolov:
Unfortunately, the idea of inheritance turned out to be a double-edged sword. You might accidentally knock yourself out. That's why you'd better use inheritance in a very limited way.

This EA is likely to have no more than two inheritance links. The picture is just to demonstrate inheritance. I'm not a follower of complication myself ) But the Lord God... who likes to have fun))).

Concerning the "lump" look at the standard library, it's rather deep there, especially in Controls.

 
Alexey Volchanskiy:

This EA is likely to have no more than two inheritance links. The picture is just to demonstrate inheritance. I'm not a follower of complication myself ) But the Lord God... who likes to have fun))).

As for "licking", look at the standard library, it's a pretty deep level there, especially in Controls.

Unfortunately the standard library is not a benchmark. Some classes are just masterpieces, others are written with no understanding of the subject (probably written by different people).
 
Vasiliy Sokolov:
Unfortunately, the idea of inheritance has become a double-edged sword. You may hurt yourself unintentionally. That's why you'd better use inheritance in a very limited way.

Can I give you an example of "zashib"?

I, on the contrary, always try to use inheritance and polymorphism as much as possible. It's very convenient to have virtual functions that are called as needed on the objects you create...

There are cases where all the descendants carry the functionality of the ancestor class which the descendants no longer need - but I don't see any special problems here. Don't use it, that's all. I'm not even speaking about protected inheritance, when users of the class - can no longer refer to the ancestor's functions, and, here, it is very easy to "remove unnecessary functionality".

 
George Merts:

Can I give you an example of "zashib"?

I, on the contrary, always try to use inheritance and polymorphism as much as possible. It's very convenient to have virtual functions that are called as needed on the very objects that are created...

There are cases where all descendants carry functionality of the ancestor class, which the descendants no longer need, but I do not see any particular problem here. Don't use it, that's all. I'm not even talking about protected inheritance, when users of the class - can no longer refer to the ancestor's functions, and, here, it is very easy to "remove unnecessary functionality".

Well written. I use virtual functions extensively in this project, very handy. The descendant classes have different "behaviors", but the same interface. There's no notion of an interface in MQL, but it's not hard to imitate it.

I have already thought of putting instances of all descendants in an array and running them in a loop with calls of virtual functions. And to select the most successful signals in some way, which I haven't yet thought of. So far, it is not clear how to determine the "goodness". So, there is an opportunity to optimize on the fly by adjusting to the changing market.

I think it's better to do not in the working EA, but in its small modification that works in parallel with writing information at least in a file, the exchange speed is not important here.

What about"ancestor class functionality, which descendants don't need any more" - no matter, the functions exist in memory as a single copy anyway. Of course, data memory will be allocated for each instance, but nowadays with gigabytes of RAM it's not very important.

 
You'd better describe the ToR, because it's not clear what you mean and what classes have to do with it.
 
Alexey Volchanskiy:

I am writing an EA to a client and the situation is as follows. There is no clear TOR for all the items, but there are ideas he wants to test. That is, the work is closer to research.

He says, I do not even know what to do, there are variants of inputs, I want to try them, can I do that? I will have to write several variants of the Expert Advisor? And entries by volume obviously cannot fit into one function and they should be born dynamically by market. In other words, there may be 1... N. I am making a simplified description of the situation.

Let's create a base class where everything remains unchanged and from this class we will have descendants with changed behavior.

- And what is a class?

The client understands MQL a little, but is not a programmer. I started to explain, but he did not understand.

I found a picture on the Internet of the classification of animal species. I said: Let's simplify it and assume that all of them evolved from each other.

I say - our base class would be Ancient flagellates. Has basic functionality, just the essentials. And from it, we'll have Protozoa, Multicellular, etc. And each descendant will contain all functionality of its parent.

- Oh, I see! And even the Mammals will have the functionality of the Ancient flagellates, am I right?

- Yeah, that's right.

Now I'm thinking how this case would be optimally used in a tester, the strategy is not scalper or ticking, for a tester is suitable. Also in the frightening riddles of who the Suckers are ))

**

If you don't know what they want then you may ask them to do it manually. Or let them hand-test what they don't know...
 
Alexey Volchanskiy:

I am writing an EA to a client and the situation is as follows. There is no clear TOR for all the items, but there are ideas he wants to test. That is, the work is closer to research.

He says, I do not even know what to do, there are variants of inputs, I want to try them, can I do that? I will have to write several variants of the Expert Advisor? And inputs by volume obviously cannot be contained in one function and they should be born dynamically by market. In other words, there may be 1... N. I am making a simplified description of the situation.

Let's create a base class where everything remains unchanged and from this class we will have descendants with changed behavior.

- And what is a class?

The client understands MQL a little, but is not a programmer. I started to explain, but he did not understand.

I found a picture on the Internet of the classification of animal species. I said to him: "Let's simplify it and assume that all of them evolved from each other".

I say - our base class would be Ancient flagellates. Has basic functionality, just the essentials. And from it, we'll have Protozoa, Multicellular, etc. And each descendant will contain all functionality of its parent.

- Oh, I see! And even the Mammals will have the functionality of the Ancient flagellates, am I right?

- Yeah, that's right.

Now I'm thinking how this case would be optimally used in a tester, the strategy is not scalper or ticking, for a tester is suitable. Also in the frightening riddles of who the Suckers are ))

**

The main thing is how it is convenient to use. To try different inputs, you can do this in bulk by input set number. I.e. there is a collection of input sets. If convenient, as an array of functions. The simplest ones - unconditional buy or sell by market. Or conditional)). And then we run the optimizer and look through the different entry sets.
 
Alexey Busygin:
You'd better describe your ToR, because it's not clear what you mean and what classes have to do with it.

What are the terms of reference - the one given to me by the customer? )) Do you think that's politically correct?

Or is it something exotic to you? Or is it some kind of exoticism for you? For me, it's an ordinary working tool.

 
Vladimir Pastushak:
They should be sent to decide what they want first and then ask for it... Or let them hand-test what they don't know...
Why not? I love research, especially if it's paid for)