Errors, bugs, questions - page 734

 
Vitya:
Maybe, we need PositionTotal()?

And what does this have to do with the position if I ask OrdersTotal() how many orders are currently placed?

And I request this information in OnTrade(), the moment when the order exists cannot be missed.

But in fact, it turns out that this moment is missed anyway and the requests are processed either when the order is not yet present or when it is already present.

But the moment when it exists is not detected in OnTrade(), or else, the OrdersTotal() lies.

 

To avoid complaining about the code imperfection, here is the MetaQuotes code with my improvement of the script in the Expert Advisor.

Added OnTrade() function and put the script code to OnInit().

Not a single print displays a message that there is an order.

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 

I can only answer this with an article Trade events in MetaTrader 5:

Заключение

All operations in the MetaTrader 5 trading and analytical platform are asynchronous, and all changes in the trading account are reported independently of each other. Therefore you should not try to track a single event according to the "One request - One trade event" rule. If we want to determine exactly what has changed after the Trade event, we need to analyze all deals, positions and orders at each call of the handler OnTrade and compare them with the state we had before the event appeared.
This means that the order, which you are trying to catch, probably already needs to be searched using HistoryOrdersTotal
 
Rosh:

I can only answer this with the article Trading Events in MetaTrader 5:

This means that the order you are trying to catch should probably already be searched using HistoryOrdersTotal

I am guided by this article. I would like to find out the answer to the question: how is it possible that a trade event misses the moment when an order is placed but has not yet been executed?

Trade events are generated by the server in the following cases

  • Changes in active orders,
  • changes in positions,
  • changes in trades,
  • changes in the trading history.

I suspect that OrderTotal() fails. But I can't prove it with this functionality.

Although as an option I don't reject that OrderTotal() is taking data not where I think it is (i.e. not on the server).

 
Urain:

I am following this article. I would like to find out the answer to the question: how is it that a trade event misses the moment when an order has been placed but has not yet been executed?

Simply, when a Trade event comes, the order has already been placed and has already been executed. That's why it is not in the history and is already in effect.
 
Rosh:
By the time the Trade event arrives, the order has already been placed and executed. Therefore, this order hasn't yet been placed among the active ones and already appeared in the history.

Yes, yes, my thoughts are floating around this answer.

I would answer like this, at the time the order is placed, the server generates a "trades" event and sends it to the terminal, when the terminal receives it, a request is made in the code for the number of orders, but by the time this request comes to the server, the server has already executed the order.

I don't have any other explanation.

 
Urain:

Trade events are generated by the server in the following cases:

  • Change in active orders,
  • changes in positions,
  • changes in trades,
  • changes in trading history.

I suspect that OrderTotal() fails. But I can't prove it with this functionality.

Did I understand correctly that the list of active orders includes both active pending orders and orders to open a position?

Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
 
papaklass:

What does this mean?

Something like "No part of the used memory was released after the program was terminated". In particular, a similar message occurs when a program creates a dynamic object using the new operator, but does not subsequently delete itusing the delete operator.
 
papaklass:
... in "Experts" tab this message appears. It is not an error, it is a warning. A warning about what?

Well, I didn't say "mistake". Let it be a "warning". I've already said my version with an example. Have another look at the discussion from here (about line leakage - read to the end of the page): https://www.mql5.com/ru/forum/1111/page345#comment_54616

You may have to go to the BOD, with details of your situation.

 

Found a "confusion".

Why doesn't the compiler like the second b variable define?

And in general, how do I handle this situation?

#property script_show_inputs

// m[a].Column[b]
input int A=11;
input int B=3;

#define a A
//#define b B // тут раскоментировать
#define b 3   // тут закоментировать

// размер одного элемента 4 байта
struct ArrWe
{
  float Column [b];
};

void OnStart()
{
  ArrWe m[11]; // тут вместо "11" хочу использовать "a"
  Print("Размер структуры ArrWe ",sizeof(ArrWe));
  Print("Количество элементов 1-го измерения ",sizeof(m)/sizeof(ArrWe));
  Print("Количество элементов 2-го измерения ",sizeof(ArrWe)/4);   
  Print("Размер массива из 11 ArrWe ",sizeof(m));
}
Reason: