MT4 leaving out ticks while performing my onTick calculations.

 

I wrote an indicator that performs a lot of calculations on each tick.

When comparing the performance to another computer running MT4 it occurred to me that the version running my indicator will leave out ticks when there very quick sequences of ticks (think market open on indices). 

Rather than leaving these out, I'd prefer that my indicator will wait until there's enough time to perform the calculation.

Is there a way to set this up by default?

I figured I could create some "timers" that will measure the ticks per second and see whether there's enough time but I though maybe there's a better way?

Thanks a lot for your help!

 

It's the wrong approach.

Just put it in timer and have it run the entire calculation no matter how fast how many ticks arrive.

You want the outcome but if tick come in quicker then you can calculate you will have to either make it faster or just wait for the result.

 
Marco vd Heijden:

It's the wrong approach.

Just put it in timer and have it run the entire calculation no matter how fast how many ticks arrive.

You want the outcome but if tick come in quicker then you can calculate you will have to either make it faster or just wait for the result.


Thank you very much for the reply!

I'm not sure whether I understand correctly.

"Just put it in timer and have it run the entire calculation no matter how fast how many ticks arrive."

Could you please elaborate on that? How should the timer work then?

 

ZetaTrader:


 How should the timer work then?

Open the Editor press F1 and enter in the line of the Index-tab OnTimer, press Enter and start reading.

Then use Google or the search here for examples, one would be here: (https://www.mql5.com/en/code/19455)

Beside that you will never get all the ticks, especially when the market 'goes very fast' (news).

Would you like to get outdated ticks if they are faster then your connection instead of always the last ones?

chkOnlineStatus
chkOnlineStatus
  • votes: 3
  • 2017.11.20
  • Carl Schreiber
  • www.mql5.com
chkOnlineStatus shows the three relevant items of the online status of the terminal: prev_calculated: Sometimes the terminal sets prev_calculated to zero and forces an indicator to re-calculate the complete history. ping: The ping changes, which might be caused by a switch to a different server. connected: Shows the connections status. Is send...
 
Carl Schreiber:

Open the Editor press F1 and enter in the line of the Index-tab OnTimer, press Enter and start reading.

Then use Google or the search here for examples, one would be here: (https://www.mql5.com/en/code/19455)

Beside that you will never get all the ticks, especially when the market 'goes very fast' (news).

Would you like to get outdated ticks if they are faster then your connection instead of always the last ones?


Thanks a lot for explaining!

I didn't realise he was referring to the onTimer function.

I'll have a careful look into these links and try to solve this.

 
ZetaTrader: When comparing the performance to another computer running MT4 it occurred to me that the version running my indicator will leave out ticks when there very quick sequences of ticks (think market open on indices).
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. While your indicator is running, nothing else can happen. The terminal is not running, it is not receiving/processing ticks. If your indicator takes longer than 2.5 seconds it will be terminated. Doing it in OnTimer changes nothing, it will not help.

  3. After the initial run, it should only be processing ticks for bar zero.
              How to do your lookbacks correctly.

  4. Reduce max bars on chart. Or code it to only process N bars. Or perform partial initial updates:
    int OnCalculate(...){
       COUNT    startTime   = GetTickCount();
       while(iBar > LAST){  --iBar;
          if(GetTickCount() - startTime > 1500)
             return rates_total-iBar-REDRAW_BAR);
          :


Reason: