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
I have an assumption that there will be no lot, for example 0.15. At least I have not heard about it. If I do, I will change it.
I know it's unlikely, but you always want the perfect solution ))))
Ok, it's not the biggest problem, but I've created a problem for myself... I wanted a perfect OOP, but with no unnecessary calls and everything was optimal
I want to have 5 instances of the class, but I need to initialize the class fields once - they contain terminal environment, which will not change during the execution of the program.
string Language;
If I declare static string Language; - then there will be an error unresolved static variable 'A::Language'
here is an example
I will initialize string Language 5 times in this form - it is wrong and it will not compile with static modifiers
and there's no need to have 5 copies of the Language variable! - tried in class B to declare an instance of the class - same thing 5 Language variables have
2019.08.29 12:44:58.384 tst__ EURUSD,M15: initialized
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:57.989 tst__ EURUSD,M30: uninit reason 3
I know it's unlikely, but you always want the perfect solution ))))
Ok, it's not the biggest problem, but I've created a problem for myself... I wanted a perfect OOP, but with no unnecessary calls and everything was optimal
I want to have 5 instances of the class, but I need to initialize the class fields once - they contain terminal environment, which will not change during the execution of the program.
If I declare static string Language; - then there will be an error unresolved static variable 'A::Language'
here is an example
I will initialize string Language 5 times in this form - it's not correct, and it doesn't compile with static modifiers
2019.08.29 12:44:58.384 tst__ EURUSD,M15: initialized
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:57.989 tst__ EURUSD,M30: uninit reason 3
OK, that's an option
But I want to wrap it all in one class - in my example I have class B and I want 5 instances of B, but I don't want to initializeLanguage 5 timesand therefore I don't want to have aLanguagevariablein each instance
How do I get rid of extraLanguage ?
OK, that's an option
But I want to wrap it all in one class - in my example I have class B and I want 5 instances of B, but I don't want to initialize Language 5 times and therefore I don't want to have aLanguage variablein each instance
How do I get rid of extraLanguage?
Inherit. This way it will only be initialized once.
I know it's unlikely, but you always want the perfect solution ))))
Well, it's not the biggest problem, but I've created a problem for myself... I wanted a perfect OOP, but with no unnecessary calls and everything was optimal
I want to have 5 instances of the class, but I need to initialize the class fields once - they contain terminal environment, which will not change during the execution of the program.
If I declare static string Language; - then there will be an error unresolved static variable 'A::Language'
here is an example
I will initialize string Language 5 times in this form - it is wrong and it will not compile with static modifiers
and there's no need to have 5 copies of the Language variable! - tried in class B to declare an instance of the class - same thing 5 Language variables have
2019.08.29 12:44:58.384 tst__ EURUSD,M15: initialized
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:58.384 tst__ EURUSD,M15: B::BRussian
2019.08.29 12:44:58.384 tst__ EURUSD,M15: A::A
2019.08.29 12:44:57.989 tst__ EURUSD,M30: uninit reason 3
Inherit. In this form, it will only be initialised once.
Works for me
2019.08.29 13:24:19.690 tst__ EURUSD,M15: initialized
2019.08.29 13:24:19.690 tst__ EURUSD,M15: B::Bru
2019.08.29 13:24:19.690 tst__ EURUSD,M15: CLang::CLang
2019.08.29 13:24:19.690 tst__ EURUSD,M15: B::Bru
2019.08.29 13:24:19.690 tst__ EURUSD,M15: CLang::CLang
2019.08.29 13:24:19.690 tst__ EURUSD,M15: B::Bru
2019.08.29 13:24:19.690 tst__ EURUSD,M15: CLang::CLang
2019.08.29 13:24:19.690 tst__ EURUSD,M15: B::Bru
2019.08.29 13:24:19.690 tst__ EURUSD,M15: CLang::CLang
2019.08.29 13:24:19.690 tst__ EURUSD,M15: B::Bru
2019.08.29 13:24:19.690 tst__ EURUSD,M15: CLang::CLang
2019.08.29 13:24:19.690 tst__ EURUSD,M15: MyTerminalInfoString
at least myTerminalInfoString() is called once
So I kinda got a Singleton
Thank you!
I'm on my phone right now. Remind me in the evening and I'll show you how to solve it.
OK, if it's not too much trouble.
and the Singleton theme is fairly new to me, there is room for creativity - examples would
OK, if it's not too much trouble.
and the Singleton theme is fairly new to me, there is room for creativity - examples would
So, do you need a common field for the objects?
it's hard to say what i want ))))
Let me try to put it into words:
- I want a class that is initialized by the constructor and this class will not have any methods; the class purpose is to open an order and then close and/or reopen several more orders according to a script; the script type is an enumeration
- I will use an array of instances of the class - at least 5
- I don't want to open the order without calling the terminal environment every time. Therefore, I want to use SYMBOL_VOLUME_MAX, Symbol, SYMBOL_VOLUME_MIN and the number of digits in SYMBOL_VOLUME_STEP as constant values in the class
- I want optimal use of variables, i.e. I don't want to duplicate the constants in the previous paragraph.
That's about how I see it all, but in general, the problem is now reduced to the correct structure of the class itself, as it turned out already have to inherit, so that SYMBOL_VOLUME_MAX , Symbol,SYMBOL_VOLUME_MIN ... to have one copy, I think I will still stumble on the error output, I will use something like this from my PrintLastError.mqhhttps://www.mql5.com/ru/code/24829#