MK, why don't you add normal functions for binary search to the standard library? ArrayBsearch is only applicable in simple cases where types are simple and you don't need a custom comparator. Templates are there, make an override over c++::std::lower/upper_bound. So far I've had to write it myself, which is not normal (almost completely copied from cppreference).
Everything is fine there, order placement should be controlled through OnTradeTransaction, by the way, if you connect to the exchange directly through Plaza2, the situation is the same - you need to control the arrival of messages about order placement. In MT4, this function is synchronous, but the same option is available in MT5, only in this case, the logic will stop until the function receives no response.
If you need, I can send you the control class, but it is written for market placing, but soon I will finalize it for limiters.
To control the request, you need to remember the fact of its placement. The class will be sent to you.
fxsaber: Very much I ask you to post something to the kodobase! For educational purposes.
Can't for the reason you yourself pointed out https://www.mql5.com/ru/forum/1111/page1743#comment_2877482. Recently I could not localize the error, spent a lot of time to form the source code into servicedesk - in the end nothing came out because of many cross-references (one pulls the other in geometric progression) - I sent .ex5
For educational purposes I can suggest the task: without introducing additional variables simplify h() so that f() is called in any case once
bool f() { return Random(); /*вычисляется ооочень долго, но результат не зависит от числа вызовов*/ }
void g1() { /*делает что-то полезное*/ }
void g2() { /*делает что-то полезное*/ }
void h() {
#ifndef MACRO
if ( f() )
#endif
{
if ( f() )
g1();
g2();
}
}
For educational purposes, I can suggest the following task: without introducing additional variables, simplify h() so that f() is called once in any case
bool f() { return Random(); /*вычисляется ооочень долго, но результат не зависит от числа вызовов*/ }
void g1() { /*делает что-то полезное*/ }
void g2() { /*делает что-то полезное*/ }
void h() {
#ifndef MACRO
if ( f() )
{
g1();
g2();
}
#else
if ( f() )
g1();
g2();
#endif
}
Why is that? A template with const cannot accept non-const - it violates the contract.
Template is not by itself (unlike function) - its task is to perform substitution (by analogy with #define). If there are no contradictions at the end of replacement (and there are none), the template has fulfilled its task. At least I tried to compile it in C++ and the compiler gave no errors or warnings
MT5-OrderSend is NOT fully synchronised - there is no synchronisation with the trading environment. This means that the history readings do not correspond to the real situation.
No timeout is out of the question. There is no reliable solution to the problem, because you have to deal with synchronization issues at the terminal level, not at the server level.
In fact, MT5 users are facing what MT4 bridge developers are facing.
If an OrderSend is sent, you have to REMEMBER (this is where the potential vulnerability is) that it is done. Then ignore the current history (trading environment) until the corresponding message comes in OnTrade. Once it arrives, REMEMBER to FORGET.
When there is no REMEMBER, you can trust the history as in MT4.
MT4-OrderSend is FULLY synchronised.
I wonder - for what reason is this done ... I understand if you mess with OrderSendAsync asynchronously, you can handle both OnTrade and OnTradeTransaction. With OrderSend I want to have simple behavior, like in MT4. Once it is called, we obtain in the output already modified open positions and history. There is a subtle point. If the current state is stored in a global variable and the expectation of state changes takes a relatively long time, and the trader manages to change the EA parameters, the global variables will be reset and the state will be discarded.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
In the process a couple of questions arose:
1. Why is it impossible to write operator() in Comp (it is prohibited for some reason)?
2. Why can't we pass prvalue to function which accepts constant reference?
ZS: and also very annoying this warning: "struct has no members, size assigned to 1 byte "
Everything is fine there, order placement should be controlled through OnTradeTransaction, by the way, if you connect to the exchange directly through Plaza2, the situation is the same - you need to control the arrival of messages about order placement. In MT4, this function is synchronous, but the same option is available in MT5, only in this case, the logic will stop until the function receives no response.
If you need, I can send you the control class, but it is written for market placing, but soon I will finalize it for limiters.
Very much I ask you to post something to the kodobase! For educational purposes.
Can't for the reason you yourself pointed out https://www.mql5.com/ru/forum/1111/page1743#comment_2877482. Recently I could not localize the error, spent a lot of time to form the source code into servicedesk - in the end nothing came out because of many cross-references (one pulls the other in geometric progression) - I sent .ex5
For educational purposes I can suggest the task: without introducing additional variables simplify h() so that f() is called in any case once
Compilation error
(*) In general, in pattern (1) both A->(2) and const A->(3) can be substituted instead of T.
Why is that? A pattern with const cannot accept non-const - it violates the contract.
For educational purposes, I can suggest the following task: without introducing additional variables, simplify h() so that f() is called once in any case
Why is that? A template with const cannot accept non-const - it violates the contract.
Has anyone experienced a similar problem? Is it a "bug" in the terminal or mine?
MT5-OrderSend is NOT fully synchronised - there is no synchronisation with the trading environment. This means that the history readings do not correspond to the real situation.
No timeout is out of the question. There is no reliable solution to the problem, because you have to deal with synchronization issues at the terminal level, not at the server level.
In fact, MT5 users are facing what MT4 bridge developers are facing.
If an OrderSend is sent, you have to REMEMBER (this is where the potential vulnerability is) that it is done. Then ignore the current history (trading environment) until the corresponding message comes in OnTrade. Once it arrives, REMEMBER to FORGET.
When there is no REMEMBER, you can trust the history as in MT4.
MT4-OrderSend is FULLY synchronised.I understand if you mess with OrderSendAsync asynchronously, you can handle both OnTrade and OnTradeTransaction. With OrderSend I want to have simple behavior, like in MT4. Once it is called, we obtain in the output already modified open positions and history.
There is a subtle point. If the current state is stored in a global variable and the expectation of state changes takes a relatively long time, and the trader manages to change the EA parameters, the global variables will be reset and the state will be discarded.