Hello. I had an idea yesterday. But yesterday I wanted to sleep and scored. Today I thought, and, although, I understand how to do it, but.. I don’t like the implementation I came up with. Therefore, I decided to write here to discuss this thing, if anyone is interested.
The essence is as follows: I, usually, did not use money management(MM), but, there was a desire to check how some variations will affect the profitability of systems. So the point is that there is a desire that when I add a class in which various MM systems will appear, I can choose, for example, enum directly from the bot’om the desired MM system. I.e. I start the bot, and chose, for example, system #1, and, bot-trades with this MM system. I chose system #2, and the bot trades with this MM system. Did anyone implement such a thread at all?
I lead this to the fact that any system can be conveniently run in one fell swoop across all MM systems at once (optimization by the MM field). It is clear that you can specify in the code which system to use, but.. as they say, laziness is the engine of progress)) Only here it’s not about laziness, but about paying more attention to writing code, and not monkey work, changing the same thing in each owl.
If anyone is interested, I can throw what I think today. And then discuss..
I haven’t seen such thoughts and approaches from anyone yet, so I decided to write about it and then start writing code. I just haven’t decided how to do it beautifully yet. And I don’t want to write anyhow. After all, this is written once, and you will have to use it constantly.
hoz
I totally agree.
zloy_koldun
You’re the one who’s not paying attention. What does Your class do compared to a single function? Nothing!
a100
Only those who write in the OOP style will understand you. Get used to it
hoz
Vladimir, I don’t write like that. I don’t have procedural programming. If I write a method, it usually occurs 1 time in the entire hierarchy. You won’t find him anywhere else. There is no maximum overload. if there are different types (because there is no normal casting to the object in the MCL, this has to be done sometimes). Therefore, initially it is more difficult to think through the architecture sensitively than others. But this is not a barrier.
In addition, I do not use standard libraries, because they are not convenient and cumbersome. In addition, there is no normal, in my opinion, system of naming variables and not only variables. And using something, you don’t learn to think. I’m used to writing everything myself. I trust only native tools of frameworks of known programming languages. Although, and there I found some shoals in early versions.
artmedia70
Why create an object every time before opening a position? You create the object once in OnInit (), depending on the settings of external parameters. And you will be constantly selected one of the possible methods of calculating the lot. Changed the MM in the settings – changed the MM type in the MM class, and the program uses a different type of MM.
It’s simple.
barabashkakvn
Anything is possible. Sample code: Expert Ichimoku
Implemented the scheme:
Here, Risk is the percentage of risk per trade (the CMoneyFixedMargin class is used – trading with a fixed margin level).
You can fasten the CMoneyFixedRisk class-trading with a fixed level of risk.
You can compare the work of these two classes here: Money Fixed Margin and Money Fixed Risk. Here it is clearly shown how the Stop Loss affects the calculation of the position volume: what will happen if you specify a Stop Loss equal to zero and what will happen if you specify a Stop Loss not equal to zero.
ya_programmer
A good idea.
Waiting for implementation.
hoz
The Preface is great because I wanted to convey my idea. I see that I didn’t report it in its entirety. Everything You wrote I did. But it turned out that every time, before opening a position, you will need to create an object of the selected money management system and then get the received lot value from it. And I wanted to somehow implement it more flexibly, so that, as You wrote, you could choose the MM system from the external input parameter and in the parent class of all MM, an object of the class that is selected would be created and work with it throughout the program. I haven’t figured out how to do this. I stopped at this option, as You wrote. I did it myself after creating this branch
.
I thought I’d approach it differently. Nonpolymorphic here does not roll, because the parent class does not always include all the fields as the heir.
artmedia70
Och great Preface…
Something like this:
//--- enums
enum ENUM_MONEY_MANAGEMENT
{
MONEY_MANAGEMENT_FIX, // Fixed volume
MONEY_MANAGEMENT_MARTINGALE, // Martingale
MONEY_MANAGEMENT_DRUNK_TRADER, // Drunk trader
MONEY_MANAGEMENT_ENTIRE_CUTLET, // Entire cutlet
MONEY_MANAGEMENT_UNNECESSARY_MONEY, // Unnecessary money
MONEY_MANAGEMENT_ETC // etc ...
};
//--- input parameters
input ENUM_MONEY_MANAGEMENT InpMoneyManagement = MONEY_MANAGEMENT_FIX;
I. e.: create your own enumeration with descriptions, and then create an input parameter.
In the example I gave, MM with a fixed lot will be selected by default.
In the enumeration, you can add your desired enumeration values – I showed an example.
vdev
Everything could be described in two phrases.
I want to set a parameter through enum.Has anyone ever done this?
Answer: Yes