Learning and writing together in MQL5 - page 34

 
Yedelkin:

A simple script like this gives me strange results

Maybe someone can explain what's the reason? When number 254 is explicitly converted to uchar, it works as intended.

Thanks for the message, let's look into it.
 
Rosh:
Thanks for the message, we'll sort it out.

Same story with ushort:

void OnStart()
  {
   for(ushort i=32760;i<32775;i++)
     {
      switch(i>USHORT_MAX-2)
        {
         case   true:  Print(__FILE__," ",__FUNCTION__,": ",i,">(USHORT_MAX-2) - true");   break;
         case  false:  Print(__FILE__," ",__FUNCTION__,": ",i,">(USHORT_MAX-2) - false");  break;
        }
     }
  }
 

How would you make it so that when a condition occurs, the music starts? Heh-heh, it's a bit strange application of mql)) But to watch the picture waiting for the right moment is boring, and completely leave all the work to the robot somehow not so sensible. So I decided to let the music play when I want it, and then I'll do it myself))

I looked through the reference book, or maybe I was looking too hard or something, but I couldn't find it.)

 
Check out the function PlaySound()
 
Rosh:
Check out the function PlaySound()

Thank you very much.)
 

Question about tracking requotes.

The description of the OrderSend() function says that "When placing a market order, successful completion of the OrderSend() method does not always mean successful execution of the trade. You need to check the ... the retcode value". I.e., it can be inferred that if OrderSend()==true, we can still get a requote. Ok.

But in the example ("Sending a trade request with result handling") to section"Structure of trade request result" the message about a requote is only checked if OrderSend() ==false.

So in which cases do we check for requotes: at any value returned by OrderSend(), or only if OrderSend() ==false?

Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса - Документация по MQL5
 
Yedelkin:

Question about tracking requotes.

The description of the OrderSend() function says that "when placing a market order, the successful completion of the OrderSend() method does not always mean a successful transaction.

The successful execution of the OrderSend() method only means that the request is checked for correctness and placed in the queue for execution. But its further fate is not guaranteed - the order may be canceled during its processing, for example, due to a filling policy.

But in general, if there was a requote, OrderSend() has clearly failed.

 
Rosh:

Successful execution of OrderSend() only means that the request has been checked for correctness and queued for execution. But its further fate is not guaranteed - the order may be canceled during its processing, for example, due to the fill policy.

But in general, if there was a requote, OrderSend() has clearly failed.

In other words, a requote means that the request initially failed to pass the correctness check?
 
Yedelkin:
In other words, a requote means that the request initially failed to pass the correctness check?

Well, yes, the price stated in the request did not match and you are prompted to take into account the new prices which can be obtained from the response structure of the MqlTradeResult server:

struct MqlTradeResult
  {
   uint     retcode;          // Код результата операции
   ulong    deal;             // Тикет сделки, если она совершена
   ulong    order;            // Тикет ордера, если он выставлен
   double   volume;           // Объем сделки, подтверждённый брокером
   double   price;            // Цена в сделке, подтверждённая брокером
   double   bid;              // Текущая рыночная цена предложения (цены реквота)
   double   ask;              // Текущая рыночная цена спроса (цены реквота)
   string   comment;          // Комментарий брокера к операции (по умолчанию заполняется расшифровкой)
  };

 
Rosh:

Well yes, the price stated in the request did not match and you are prompted to take into account the new prices, which can be obtained from the response structure of the MqlTradeResult server:

OK!

Probably, I'm overdoing it, but here's another question. Before sending a request to place a market order (to open a position), I reset the trade ticket to zero, i.e. I make result.deal=0. Can we expect that the server will return a null trade ticket in MqlTradeResult response structure, but a bit later, the trade will be executed and the position will be opened? Or does the return of a null trade ticket by the server guarantee that the position could not be opened and it will not be further opened based on this request?