Errors, bugs, questions - page 2744

 
Aliaksandr Hryshyn:

Error:


Thank you for your message.
Corrected.

 
Ilyas:

Optimisation question. In the Tester, on every tick I need to get a tick for further work. I do it this way.

void OnTick()
{
  static MqlTick Tick;
  
  if (SymbolInfoTick(_Symbol, Tick))
    // ...
}


It is clear that this variant will be slower:

void OnTick()
{
  MqlTick Tick;
  
  if (SymbolInfoTick(Symbol(), Tick))
    // ...
}


But SymbolInfoTick is also slower because its string-parameter isn't passed by reference.


Is it possible to have regular SymbolInfo* overloads where string is passed by reference?


It's better to have

const MqlTick _Tick; // Текущий _Symbol-тик.


In Optimizer, these functions are called tens of billions of times.

 
Ilyas:
Are you suggesting to add GetNextEvent function ?

Not really, I would rather call this function as HandleNextEvent, a possible signature:

bool HandleNextEvent (ENUM_EVENT_TYPE);


When called, similar to GetNextEvent, checks if the specified ENUM_EVENT_TYPE is present in the queue,
and if this event is present, automatically passes control to the user code of the corresponding handler (OnChartEvent, OnTrade, OnTradeTransaction, ... (thanksto fxsaber for the addition)).
Returns true if there was an event in the queue, otherwise returns false.


Possible use case:

//....
for(int i = 0; i < 10^6; ++i){
   // .... Data Calculations

   if((i % 10^3) == 0){
       while(HandleNextEvent(EVENT_TYPE_ALL));
   }
}
//....
 
fxsaber:

Optimisation question. In the tester, on every tick I need to get a tick for further work. I do it this way.
It is clear that this variant will be slower.

Have you checked this statement in practice? It may appear to be just the opposite.

MqlTick consists of primitive data types that are not initialized.
Correspondingly, no time is wasted on selection at all because it's the same "sub esp" operation, just of a different size.
As the result, the bottleneck may be on the side of processor's cache for reading a value from memory operation.

Anyway, we should test it )).

 
Sergey Dzyublik:

when this event occurs, automatically transfers control to the user code of the appropriate handler

Possible use case:

A very nice and useful solution!

 
Sergey Dzyublik:

Have you tested this statement in practice? It just might turn out to be the opposite.

Theorising here. I haven't checked it. But the transfer on the string link seems appropriate.

 
Sergey Dzyublik:

A possible use case:

you're not making any sense.

According to the signature and your description, the terminal should call a function to process the next event and then return control to the program at the point where the handlenextevent is called?

What if the handlenextevent is called again during processing?

What happens to events that don't pass the filter in the parameters? are they skipped? do they change the queue?

scripts don't have an event queue at all, why add it on crutches when there are Expert Advisors and indicators?

 
TheXpert:

1) you are suggesting some kind of nonsense.
2) according to the signature and your description, the terminal should call the next event processing by function and then return control to the program to the point of handlenextevent call?
3) what if the handlenextevent is called again during processing?
4) and what happens to events that don't fall under the filter in the parameters? are they skipped? do they change the order?


1) My job is to offer, but whether it's something crazy or not - it's up to developers, not you, they know a bit better...
2) All right. If I'm interested in processing a specific event, and not all events in the system, it would be nice to be able to process only this type of event, leaving the processing of other events as normal.
3) If HandleNextEvent is called again during processing - call and process. The only thing that can happen is stack overflow, but this is user's and code's problem, not developer's.
4) Events that don't fall under the filter remain in the same sequence and will be called when the user returns control to the system as usual.


 
TheXpert:

scripts don't have an event queue at all, why add it on crutches when there are EAs and indicators?

Here is an example of a script that opens and closes its positions/orders asynchronously.

// Максимально быстро все закрывает. Возврат, когда действие подтверждено.
bool CloseAll()
{
  uint RequestID[];
  
  for (int i = ArrayResize(RequestID, OrdersTotal()) - 1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS))
      // Отправили асинхронный приказ
      RequestID[i] = (OrderType() <= OP_SELL) ? OrderCloseAsync(OrderTicket(), OrderLots(), OrderClosePrice(), 100) : OrderDeleteAsync(OrderTicket());
  
  return(Transactions.Waiting(RequestID)); // Дождались ответа от сервера на все асинхронные приказы
}
TradeTransactions
TradeTransactions
  • www.mql5.com
Асинхронные торговые приказы обладают огромным преимуществом - высокая скорость при массовой отправке. Однако, распространению таких приказов мешает некоторое неудобство - данные о результате приказа возможно увидеть только в OnTradeTransaction. Такое обстоятельство заставляет обывателя строить событийную модель своей ТС, если хочется...
 
Sergey Dzyublik:

1) My job is to suggest, and whether or not it is a nonsense is not for you to decide, but for the developers, they know a bit better...

If you suggest something that's easier to implement, there's a better chance of implementation. removed your option because it gives almost nothing.

Reason: