Errors, bugs, questions - page 1978

 
fxsaber:

Chrome.

FireFox still has updated themes at the top

and blue on the left. try the browser that was on your smartphone

 
STARIJ:
in FireFox still updated themes at the top

And the blue ones on the left

It's the same in Chrome. I can't get myself to automatically see these blue/grey icons. And the bold font of unread topics is so impressive that I even wrote about it.

 
Has anyone already written to service-desk or maybe aware of MQ's plans to add friend-overs to MQL? It's sorely lacking.
 

An interesting case on AcePrime-Demo accounts.

We start the Expert Advisor

// Советник возвращает полностью сформированные торговые запросы (включая ручные)
#define  TOSTRING(A)  #A + " = " + (string)(A) + "\n"
#define  TOSTRING2(A) #A + " = " + EnumToString(A) + " (" + (string)(A) + ")\n"

string ToString( const MqlTradeRequest &Request )
{
  return(TOSTRING2(Request.action) + TOSTRING(Request.magic) + TOSTRING(Request.order) +
         TOSTRING(Request.symbol) + TOSTRING(Request.volume) + TOSTRING(Request.price) + 
         TOSTRING(Request.stoplimit) + TOSTRING(Request.sl) +  TOSTRING(Request.tp) + 
         TOSTRING(Request.deviation) + TOSTRING2(Request.type) + TOSTRING2(Request.type_filling) +
         TOSTRING2(Request.type_time) + TOSTRING(Request.expiration) + TOSTRING(Request.comment) +
         TOSTRING(Request.position) + TOSTRING(Request.position_by));
}

string ToString( const MqlTradeResult &Result )
{
  return(TOSTRING(Result.retcode) + TOSTRING(Result.deal) + TOSTRING(Result.order) +
         TOSTRING(Result.volume) + TOSTRING(Result.price) + TOSTRING(Result.bid) +
         TOSTRING(Result.ask) + TOSTRING(Result.comment) + TOSTRING(Result.request_id) +
         TOSTRING(Result.retcode_external));
}

void OnTradeTransaction(   const MqlTradeTransaction&, const MqlTradeRequest& Request, const MqlTradeResult& Result )
{
  if (Request.action)
  {
    Print(ToString(Request));
    Print(ToString(Result));    
  }
}

And we try to open a position on any bo-symbol (binary options). In the log of the terminal we get

'3182780': market sell 1.00 XAUUSDbo
'3182780': failed market sell 1.00 XAUUSDbo [Invalid data]

In the Expert Advisor's log we get

Request.action = TRADE_ACTION_DEAL (1)
Request.magic = 0
Request.order = 0
Request.symbol = XAUUSDbo
Request.volume = 1.0
Request.price = 0.0
Request.stoplimit = 0.0
Request.sl = 0.0
Request.tp = 0.0
Request.deviation = 0
Request.type = ORDER_TYPE_SELL (1)
Request.type_filling = ORDER_FILLING_FOK (0)
Request.type_time = ORDER_TIME_GTC (0)
Request.expiration = 1970.01.01 00:00:00
Request.comment = 
Request.position = 0
Request.position_by = 0

Result.retcode = 4
Result.deal = 0
Result.order = 0
Result.volume = 0.0
Result.price = 0.0
Result.bid = 0.0
Result.ask = 0.0
Result.comment = 
Result.request_id = 9
Result.retcode_external = 0

I checked it and OrderCheck returns true. Trade session is open etc. But MT5 warns about both manual and automatic requests in the same way, giving me retcode = 4. Why is there such a situation, when terminal says everything is ok, but you try and nothing happens? How do I know without any requests that it won't open? And what is this fourth return code?

GetLastError() returns

ERR_TRADE_SEND_FAILED

4756

Failed to send trade request


Reproduces everything without any problems.
 

Good afternoon.

Am I the only one who thinks that code like this shouldn't compile (there should be a private member access error)?

class cA;
class cB;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class cA
  {
   //====================
private:
   //====================
   //===============
   //===============
   cB               *B;
   //===============
   //===============
   void              testfunc(void){::Print(__FUNCSIG__);}
   //====================
public:
   //====================
   //===============
   //===============
   void              test(void)
     {
      ::Print(__FUNCSIG__);

      if(::CheckPointer(::GetPointer(this.B))==POINTER_INVALID)return;

      this.B.testfunc();   // Здесь идет вызов private метода объекта B, что вроде как не должно быть возможным
     }
   //===============
   //===============
   void              SetB(cB *const b){this.B=b;}
   //===============
   //===============
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class cB  : public cA
  {

  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   cA A;
   cB B;

   A.SetB(&B);
   A.test();

//---
   return(INIT_SUCCEEDED);
  }

SD says it's OK, it can do that...

 
Andrey Barinov:

Good afternoon.

Am I the only one who thinks that code like this shouldn't compile (there should be a private member access error)?

SD says it's ok, it can do that...

According to MQL rules, an instance of a class can freely access private fields and methods of another instance if it belongs to the same class as the first one. Since cB is inherited from cA, cB is cA and therefore cA can access any private methods and fields of the cB instance, regardless of where it is declared.

 
Vasiliy Sokolov:

According to MQL rules, an instance of a class can freely access the private fields and methods of another instance if it belongs to the same class as the first one. Since cB is inherited from cA, cB is cA and hence cA can access any private methods and fields of the cB instance, no matter where it is declared.

Thanks. I haven't seen this in the documentation. Can you point it out?
 
Andrey Barinov:
Thank you. I didn't see this in the documentation. Can you point it out?
It's not in the documentation, because it's a peculiar undocumented "feature" of the language. It's very strange and controversial, but it happened that way nonetheless.
 
Andrey Barinov:
Thank you. I haven't encountered this feature in the documentation. Can you point it out?

This is also the case in C++(and MQL is built in the image and likeness of C++). As they say, C++ privacy is at class level, not at object level. Otherwise you wouldn't be able to make, for instance, a copy-constructor without special getter methods for all the private fields.

 
Stanislav Korotky:

It's the same in C++

Have you tried to compile this example in C++, or is it just general theoretical reasoning?
Reason: