Download MetaTrader 5
To add comments, please log in or register
Find out the latest MQL5.community news!
Lovro Mirnik
54
Lovro Mirnik 2015.02.09 19:13 

I am currently working around some really basic stuff and I can't wrap my head around this one.


How would a simple program look that would do nothing else but count the amount of ticks recieved in a 30 second period?
I'm asking for the actual code that can be executed. I will be forever grateful.

Carl Schreiber
5937
Carl Schreiber 2015.02.09 19:34  

Every time OnTick() is executed you have received a new tick.

But bear in mind you don't get all the ticks!

You can use Volume[] which is not the trades (money-) volume but the amount of ticks of that bar. Look in the editor's reference for Volume

whroeder1
13600
whroeder1 2015.02.09 20:16  
lovromirnik: I'm asking for the actual code that can be executed.
  1. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. int      count = 0;
    datetime countingBegin=0
    int start(){
       datetime now = TimeCurrent()
       if( condition ) countingBegin = now; count = 0; // Begin counting
       if(now - countingBegin < 30) ++count;           // Still counting
       Print(count);                                   // current count.
    
    Was that so hard?
  3. The above does not handle missed-ticks. For that you would have to capture Volume before and after and handle new bar.
Lovro Mirnik
54
Lovro Mirnik 2015.02.09 21:02  
WHRoeder:
  1. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.


I am grateful. Worry not.


I have no plans on using the community as my codebase, I merely suffered from the inability to proceed any coding whatsoever beacuse of this issue and needed it resolved not via suggestions, but cold hard code that I can use. Immediately upon reading your result I've thought up of a workaround which serves me well.
Thanks again.

Chris.h
40
Chris.h 2016.11.07 21:09  
Carl Schreiber:

Every time OnTick() is executed you have received a new tick.

But bear in mind you don't get all the ticks!


What do you mean by that? Don't I get all the ticks by the OnTick() event? And why? Also sent you a private message.
Carl Schreiber
5937
Carl Schreiber 2016.11.07 21:17  
Chris.h:
What do you mean by that? Don't I get all the ticks by the OnTick() event? And why? Also sent you a private message.

I just realized that after a new bar has begun and I compare my tracking against the values of the bar[1]:

  1. If I count the ticks I get during a 1-minute-bar the number is smaller than the number in the tick-volume[1].
  2. If I track higs and lows of a 1-minute-bar the might differ from the high[1] and low[1].

So especially in times of a very high tick-volume a client doesn't get all the ticks.

whroeder1
13600
whroeder1 2016.11.07 21:28  
Chris.h: What do you mean by that? Don't I get all the ticks by the OnTick() event? And why?
Perhaps you should read the manual.
NewTick event handler. While the event of a new tick receipt is being processed, no other events of this type are received.
If a tick arrives while OnTick (or start) is running, it is ignored and Predefined Variables - MQL4 Reference are not updated.

Predefined Variables - MQL4 Reference
Predefined Variables - MQL4 Reference
  • docs.mql4.com
Predefined Variables - MQL4 Reference
/
To add comments, please log in or register