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
The proposed solution hasn't hit anything else yet. That's why I couldn't suggest it better.
If you put the solution in front of the SB now, it becomes synchronized.
#include <Trade\Trade.mqh>
Can I give you a little example? When I connect classes - yours and SB:
#include <Trade\Trade.mqh>
Getting into the theme)
Taken from here
Getting into the theme)
Taken from here
I just swapped the lines...
Can I give you a little example? When I connect classes - yours and SB:
#include <Trade\Trade.mqh>
I'll get into the subject.)
Yes, I forgot about that nuance. True, this restriction does not exist there anymore...
If you rearrange the inludes, then, of course, will not swear. But the effect will be null - SB will not be synchronized.
Unfortunately, I do not see a nice solution. So far
// Это сделает СБ синхронизированным и не потребует каких-либо изменений в экспертах.
#ifdef OrderSend
#undef OrderSend
#define CTrade CTradeBase
#include <Trade\Trade.mqh>
#undef CTrade
class CTrade : public CTradeBase
{
virtual bool OrderSend(const MqlTradeRequest &request,MqlTradeResult &result)
{
bool res;
string action="";
string fmt ="";
//--- action
if(m_async_mode)
res=::OrderSendAsync(request,result);
else
res=ORDERSEND::OrderSendSync(request,result); // единственное отличие от стандарта
//--- check
if(res)
{
if(m_log_level>LOG_LEVEL_ERRORS)
PrintFormat(__FUNCTION__+": %s [%s]",FormatRequest(action,request),FormatRequestResult(fmt,request,result));
}
else
{
if(m_log_level>LOG_LEVEL_NO)
PrintFormat(__FUNCTION__+": %s [%s]",FormatRequest(action,request),FormatRequestResult(fmt,request,result));
}
//--- return the result
return(res);
}
};
// Эта строчка позволяет сделать все OrderSend корректными.
#define OrderSend ORDERSEND::OrderSendSync
#else
#include <Trade\Trade.mqh>
#endif
My bad, overconfidently stated, didn't check.
Yes, I forgot about that nuance. True, this restriction does not exist there anymore...
If you rearrange the inludes, then, of course, will not swear. But the effect will be null - SB will not be synchronized.
Unfortunately, I do not see a nice solution. For now you can see the following way
// Это сделает СБ синхронизированным и не потребует каких-либо изменений в экспертах.
...
Well, that is, to connect your class, and Trade\Trade.mqh will pull up.
What if it is required to inherit from Trade\Trade.mqh ? How?
Well, that is, to connect your class, and Trade\Trade.mqh will be pulled up.
Inheritance will work as before. But you'd better clarify your question.
That is, make CTrade a base class in the first line of your code:
How should it be in this case? Instead of #include <Trade\Trade.mqh> insert the suggested code?
Inherit this code from CTrade.
I.e., make CTrade a base class in the first line of your code:
Accordingly, you should not connect Trade\Trade.mqh to your program any more, but rather an inluder, for example #include <aTradeSync.mqh> which contains your class and #include <Trade\Trade.mqh> written there in the very beginning.
I wouldn't do it that way, because it would require changing previously written experts. And pure OrderSend will not be synchronized, only SB-OrderSend. Not everyone uses SB-only. Some people even use pure MQL5.
Therefore, the below solution seems to be optimal for the time being. All EAs will work without changes.
#include <TradeSync.mqh> // Если подключен OrderSendSync.mqh - СБ станет синхронизированной, иначе - стандартной.
I wouldn't do it this way, because it would require changing previously written experts. And pure OrderSend will not be synchronized, but only SB-OrderSend. Not everyone uses SB-only. Some people even use pure MQL5.
Therefore, the below solution seems to be optimal for the time being. All EAs will work without changes.
#include <TradeSync.mqh> // Если подключен OrderSendSync.mqh - СБ станет синхронизированной, иначе - стандартной.