Why OnChartEvent is more faster than OnTimer?

 

When I set something to do with OnTimer, setting 1 millisecond takes longer than if I call this function when reacting to an event. Why?

 
Jomar Ferreira:

When I set something to do with OnTimer, setting 1 millisecond takes longer than if I call this function when reacting to an event. Why?

https://www.mql5.com/en/docs/eventfunctions/eventsetmillisecondtimer


" When working in real-time mode, timer events are generated no more than 1 time in 10-16 milliseconds due to hardware limitations. "

Documentation on MQL5: Working with Events / EventSetMillisecondTimer
Documentation on MQL5: Working with Events / EventSetMillisecondTimer
  • www.mql5.com
EventSetMillisecondTimer - Working with Events - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Alexandre Borela #:
https://www.mql5.com/en/docs/eventfunctions/eventsetmillisecondtimer


" When working in real-time mode, timer events are generated no more than 1 time in 10-16 milliseconds due to hardware limitations. "

Since OnChartEvent is faster then, is there any way to create "dummy" events without necessarily having to interact with metatrader 4?

 
Jomar Ferreira #:

Since OnChartEvent is faster then, is there any way to create "dummy" events without necessarily having to interact with metatrader 4?

This timer limitation goes back all the way to the OS, you would need special real time OS to go bellow the 10-16 millisecond barrier.
Even if you generated the events, there would be no garantee they would be executed in less the 10-16ms.

This is why people that code real HFTs have highly speciallized code connected directly to the exchange(in the case of brazil, B3 has the PUMA system).

 
What are you repeatedly doing when nothing has changed (no onChart, no onTick)?
 
William Roeder #:
What are you repeatedly doing when nothing has changed (no onChart, no onTick)?

A possible use case would be HFTs, tracking something like "if no order has been executed in X ms, do something", but I don't believe metatrader
would be a good tool in this case, too many abstraction layers.

Reason: