Is there any way to limit the number of ticks in a second

 

Hello everyone,


As you know, OnTick() method will get triggered with any new tick gets pushed from the market. Sometimes, there will be only one tick a second, sometimes it can get as high as hundred. This becomes a problem when running multiple terminals on the same computer. Is there any way to limit the number of ticks received?

Say we put a limit of maximum 1 tick per 100 millisecond, any new ticks comes before the 100 millisecond elapses will be ignored.


Would appreciate any practical workarounds for this issue.

 
  1. No way to limit

  2. Fix your code.

    1. EAs : Don't do per tick what you can do per bar, or on open.
      If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts, and you recalculate.)
      If you are waiting for an order to close, only look when OrdersTotal (or MT5 equivalent) has changed.
                How to get backtesting faster ? - MT4 - MQL4 programming forum (2017)

    2. Indicators: Code it properly so it only recomputes bar zero (after the initial run).
                How to do your lookbacks correctly. (2016)
                3 Methods of Indicators Acceleration by the Example of the Linear Regression - MQL5 Articles. (2011)
      Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)

 
William Roeder #:
  1. No way to limit

  2. Fix your code.

    1. EAs : Don't do per tick what you can do per bar, or on open.
      If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts, and you recalculate.)
      If you are waiting for an order to close, only look when OrdersTotal (or MT5 equivalent) has changed.
                How to get backtesting faster ? - MT4 - MQL4 programming forum (2017)

    2. Indicators: Code it properly so it only recomputes bar zero (after the initial run).
                How to do your lookbacks correctly. (2016)
                3 Methods of Indicators Acceleration by the Example of the Linear Regression - MQL5 Articles. (2011)
      Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)

The problem with MT4/MT5 is that this issue arises even if you don't attach any EA to the chart, once you open +10 terminals with naked charts at the same setup, you start having problems.


If you are waiting for an order to close, only look when OrdersTotal (or MT5 equivalent) has changed.

Let's say I need to reevaluate with every tick waiting for a signal that gets written from the master terminal to a txt file, how can I do this without the OnTick() method?

 
Use OnTimer