• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 3:37am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 3:37am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Account size and trading size 12 replies

Trade Logger Journal 0 replies

EA Logger 0 replies

Online Transaction Logger for Dealbook? 1 reply

Spread logger 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 8
Attachments: Tick Size, Tick Rate, Tick Spread, and Tick Logger indicators
Exit Attachments

Tick Size, Tick Rate, Tick Spread, and Tick Logger indicators

  • Last Post
  •  
  • Page 1 2
  • Page 1 2
  •  
  • Post #1
  • Quote
  • First Post: Edited May 12, 2012 5:39am May 2, 2012 7:50am | Edited May 12, 2012 5:39am
  •  rooicol
  • Joined Jan 2010 | Status: Trader | 494 Posts
Hi all,

Here are four indicators i made up to display more information about the flow of incoming ticks.

Attached Image (click to enlarge)
Click to Enlarge

Name: Screen Shot 2012-05-02 at 12.24.14.jpg
Size: 170 KB


The red histogram values are the values for each tick, and the green lines are the moving averages of the last 100 ticks. The moving average period can be set in the indicator's inputs. The indicators can also be toggled to run on all ticks, or only on ticks where the bid price changes. This compresses the data a little so you get a greater time period in one screen.

The tick spread histogram shows the spread of each tick. The tick size shows the change in bid price between current bid and the previous incoming bid. The tick rate histogram shows the number of seconds each tick lasts for, the moving average shows the average number of incoming ticks per second. Global Variables are set for each of the MA's current value, so they can easily be imported by other indicators/scrips/ea's.

The tick logger records date (column a), server time (b), bid (c), ask (d), bid price change from last tick (e), ask price change from last tick (f), spread (g), and the number of milliseconds until the next tick arrived (h). You must first create a folder called "Tick Log" in your MT4/experts/files folder first.

I have found these tools very useful when it comes to brøker comparisons, as they give detailed information about the their price feed. They are particularly useful at news times, as the indicators show the tick for tick values, as well as moving averages.
Attached Files
File Type: ex4 rooicol - Tick Logger.ex4   3 KB | 2,489 downloads | Uploaded May 12, 2012 5:36am
File Type: ex4 rooicol - Tick Rate.ex4   4 KB | 2,567 downloads | Uploaded May 12, 2012 5:36am
File Type: ex4 rooicol - Tick Size.ex4   4 KB | 2,386 downloads | Uploaded May 12, 2012 5:36am
File Type: ex4 rooicol - Tick Spread.ex4   4 KB | 2,466 downloads | Uploaded May 12, 2012 5:36am
  • Post #2
  • Quote
  • Edited at 2:36pm May 2, 2012 1:17pm | Edited at 2:36pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting rooicol
Disliked
Here are four indicators i made up to display more information about the flow of incoming ticks.
Ignored
Nicely done!

On a somewhat related note that I'm sure you have noticed...

It always surprises me how many ticks are missed by EAs and live indicators, especially during heavy activity.

The attached indicator simply counts the live volume per bar. It "should" match the MT4 volume for each bar. But it seldom does. Why? Because (as I'm sure you know), EAs/Indicator take time (sometimes just a few milliseconds, somethings more) to process each tick. Any ticks arriving during an iteration of the start() function will be discarded. Even a very simple indicator like the attached (I can't think of a simpler indicator) will miss ticks. Although, there may be other explanations for the missing ticks as well (ie, processor speed). But that is a whole different issue.

I did a little testing of this on a M1 chart for two brokers: IBFX and MBTrading. On IBFX, the missing ticks were usually < 20%. On MBTrading, it was noticably more. I would guess the difference is due to the quote feeds and latency for different brokers.

And these numbers are during New York afternoon using a very "fast" indicator. You could imagine how many ticks would be missed during heavy trading using an EA that takes 200+ milliseconds per iteration.

Anyway...thanks for your efforts!
Attached File
File Type: mq4 LiveVolume.mq4   2 KB | 2,588 downloads
  • Post #3
  • Quote
  • May 2, 2012 2:33pm May 2, 2012 2:33pm
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
zznbrm

I have a question, How can one fill a buffer to form a histogram, when your not defineing its element, as the code is writen the only element that is filled is the zero element. Now I know your a better coder then that.


Keit





Inserted Code
 
int start()
    {  
 
         gadblVolume[color=red][0][/color] += 1.0;   
 
     return(0);
 
    }



Quoting zznbrm
Disliked
Nicely done!

On a somewhat related note that I'm sure you have noticed...

It always surprises me how many ticks are missed by EAs and live indicators, especially during heavy activity.

The attached indicator simply counts the live volume per bar. It "should" match the MT4 volume for each bar. But it seldom does. Why? Because (as I'm sure you know), EAs/Indicator take time (sometimes just a few milliseconds, somethings more) to process each tick. Any ticks arriving during an iteration of the start() function will be discarded. Even a very...
Ignored
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #4
  • Quote
  • May 2, 2012 3:03pm May 2, 2012 3:03pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting CockeyedCowboy
Disliked
I have a question, How can one fill a buffer to form a histogram, when your not defineing its element, as the code is writen the only element that is filled is the zero element. Now I know your a better coder then that.
Ignored
The indicator is maintaining a count of the number of live ticks per bar received by the indicator. Since we are only interested in the live ticks, the current bar (index = 0) should be the only one that is ever changed.

Remember...the purpose of this indicator is to help show the difference between the total number of ticks received/processed by a very simple indicator and the actual tick volume per MT4 bar.

I can't imagine a more efficient way of doing this.
  • Post #5
  • Quote
  • May 2, 2012 3:15pm May 2, 2012 3:15pm
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
I under stand a little more now of what your doing but still comfused, are you createing a histogram on the data as in a history or just the open bar and disregarding any history. if your only looking at the open bar then you still need to zero that buffer off on the start of each bar, or am I still in the wood here, the way the code is your going to add to only one element all the while the indie is runing, I though you were counting the ticks per bar??

Keit

Quoting zznbrm
Disliked
The indicator is maintaining a count of the number of live ticks per bar received by the indicator. Since we are only interested in the live ticks, the current bar (index = 0) should be the only one that is ever changed.

Remember...the purpose of this indicator is to help show the difference between the total number of ticks received/processed by a very simple indicator and the actual tick volume per MT4 bar.

I can't imagine a more efficient way of doing this.
Ignored
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #6
  • Quote
  • May 2, 2012 3:54pm May 2, 2012 3:54pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting CockeyedCowboy
Disliked
I under stand a little more now of what your doing but still comfused, are you createing a histogram on the data as in a history or just the open bar and disregarding any history. if your only looking at the open bar then you still need to zero that buffer off on the start of each bar, or am I still in the wood here, the way the code is your going to add to only one element all the while the indie is runing, I though you were counting the ticks per bar??

Keit
Ignored
rooicol - Sorry for the diversion here. Any or all of these posts will be deleted if you want.

CockeyedCowboy -

Ok...I see what you are saying now. The histogram is not being used for this exercise...the buffer data is the important piece. I simply copied an old (very simply) indicator that drew a histogram, but did not pay attention to it at all. Also, history does not matter for this indicator. Since there is no tick history in MT4, any past data is irrelevent.

Now, to your main question (I think) about the zeroing out of the buffer for a new bar. This line in the init takes care of that:

SetIndexEmptyValue( 0, 0.0 );

Without that line, the buffer value for each new bar is initialized to what appears to be the integer maximum value. But with this line in there, the buffer value for each new bar is initialized to zero.

Is that the proper way to initialize each bar to 0? Maybe not, but for this exercise it appears to work. We are not talking about a production-ready indicator here. This is simply a basic indicator to quickly test something out.

You can remove the histogram part of it and just run this code:

Inserted Code
  
#property indicator_chart_window
#property indicator_buffers 1
 
double gadblVolume[];
 
int init()
{
   IndicatorShortName( "LiveVolume" );
   IndicatorDigits( 0 );   
   SetIndexBuffer( 0, gadblVolume );
   SetIndexLabel( 0, "Live Volume" );
   SetIndexStyle( 0, DRAW_NONE );
   SetIndexEmptyValue( 0, 0.0 );                 
   return(0);
}
 
int start()
{  
   gadblVolume[0] += 1.0;   
   return(0);
}
  • Post #7
  • Quote
  • May 2, 2012 4:07pm May 2, 2012 4:07pm
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
Ok lets remove the histogram part.

Its still not right, the function call 'SetIndexEmptyValue()' only sets the value of the buffer if it has no value, and the init() function only gets executed once at the start of the program. there after only the start() function runs, Untill you stop it then the deinit() will run on exit,

but if your runing this code the only thing that the start() function does is add one to the zero element of the buffer on each tick, it never empties that element when a new bar opens so what your counting is every tick that arrives sence the program has started. and keeps on adding till its stoped. so you not getting a true count of ticks per bar your getting ticks while the program is on,

Keit
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #8
  • Quote
  • May 2, 2012 4:14pm May 2, 2012 4:14pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting CockeyedCowboy
Disliked
Ok lets remove the histogram part.

Its still not right, the function call 'SetIndexEmptyValue()' only sets the value of the buffer if it has no value, and the init() function only gets executed once at the start of the program. there after only the start() function runs, Untill you stop it then the deinit() will run on exit,
Ignored
Yep, that is correct.

Quote
Disliked
but if your runing this code the only thing that the start() function does is add one to the zero element of the buffer on each tick, it never empties that element when a new bar opens so what your counting is every tick...

Well, I don't know what to tell you...it is working exactly how it should for me.

Add the indicator to a M1 chart and I'm sure you will see that it is counting the ticks per bar as expected.
  • Post #9
  • Quote
  • May 2, 2012 4:46pm May 2, 2012 4:46pm
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
zznbrm

See I said in my first post, your a better coder that;

I totally miss the boat on this one. It apperars you dont need to litterage the buffers to fill them MT does that for us. See all this dialog one can learn for it, I added print statments to see when a new bar opens MT will move the data back with out any work on our part. And here I was writing loops for nothing.


Keit
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #10
  • Quote
  • May 2, 2012 6:43pm May 2, 2012 6:43pm
  •  rooicol
  • Joined Jan 2010 | Status: Trader | 494 Posts
Quoting zznbrm
Disliked
Nicely done!
Ignored
Thank you, glad you like them!

Quoting zznbrm
Disliked
rooicol - Sorry for the diversion here. Any or all of these posts will be deleted if you want.
Ignored
That's fine, don't worry.

Quoting zznbrm
Disliked
On a somewhat related note that I'm sure you have noticed...
Ignored
Yes, i have one of these too, just didn't think most people would be interested in it. I did mine a little differently, though i prefer yours now as it is much more elegant.

This is what mine looks like:

Inserted Code
#property copyright "Coded by rooicol :)"
#property indicator_chart_window

int start()
  {
   static int TickCount;
   static datetime CandleOpenTime;
   if(CandleOpenTime!=Time[0])
     {
      CandleOpenTime=Time[0];
      TickCount=0;
     }
   TickCount++;
   double PercentageProcessed=(TickCount/Volume[0])*100;
   Comment(DoubleToStr(PercentageProcessed,1),"%");
   return(0);
  }

However i don't believe the reason the number of ticks processed is the reason you mentioned (that incoming ticks during the execution of the the special function start() are ignored). The time taken to run this pice of code is miniscule. Even if you create a loop, and make it run the code 10,000 times for each tick, and time it to do so, it takes bout 200 milliseconds:

Inserted Code
#property copyright "Coded by rooicol :)"
#property indicator_chart_window

int start()
  {
   int ms1=GetTickCount();
   for(int i=0; i<10000; i++)
     {
      static int TickCount;
      static datetime CandleOpenTime;
      if(CandleOpenTime!=Time[0])
        {
         CandleOpenTime=Time[0];
         TickCount=0;
        }
      TickCount++;
      double PercentageProcessed=(TickCount/Volume[0])*100;
      Comment(DoubleToStr(PercentageProcessed,1),"%");
     }
   int ms2=GetTickCount();
   int Duration=ms2-ms1;
   Comment(Duration);
   return(0);
  }

This code above takes my computer about 200 ms, so 2/100 of a millisecond per iteration. I think it is too unlikely that so many ticks are arriving during this minuscule window.

I would be interested to know why it is that the Volume[] != number of ticks.
  • Post #11
  • Quote
  • May 2, 2012 6:58pm May 2, 2012 6:58pm
  •  rooicol
  • Joined Jan 2010 | Status: Trader | 494 Posts
Quoting CockeyedCowboy
Disliked
Ok lets remove the histogram part.

Its still not right, the function call 'SetIndexEmptyValue()' only sets the value of the buffer if it has no value, and the init() function only gets executed once at the start of the program. there after only the start() function runs, Untill you stop it then the deinit() will run on exit,

but if your runing this code the only thing that the start() function does is add one to the zero element of the buffer on each tick, it never empties that element when a new bar opens so what your counting is every...
Ignored
Yes, when you attach his indicator the special function int init() sets gadblVolume[0] to 0. It only does this once. Then for every tick after that it adds 1 to it. When a new candle is made, gadblVolume[0] is set back to 0 again (MT does this like you say in later post), and then it starts counting up +1 on each tick again. Beautiful; but i don't see the point in knowing how many ticks MT is not receiving without understanding WHY it is not receiving them
  • Post #12
  • Quote
  • May 2, 2012 8:51pm May 2, 2012 8:51pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting CockeyedCowboy
Disliked
See I said in my first post, your a better coder that;

I totally miss the boat on this one. It apperars you dont need to litterage the buffers to fill them MT does that for us. See all this dialog one can learn for it, I added print statments to see when a new bar opens MT will move the data back with out any work on our part. And here I was writing loops for nothing.
Ignored
I'm glad you worked it out. Regarding trading and programming, I learn something new every single day.

Quoting rooicol
Disliked
However i don't believe the reason the number of ticks processed is the reason you mentioned (that incoming ticks during the execution of the the special function start() are ignored). The time taken to run this pice of code is miniscule. Even if you create a loop, and make it run the code 10,000 times for each tick, and time it to do so, it takes bout 200 milliseconds:

This code above takes my computer about 200 ms, so 2/100 of a millisecond per iteration. I think it is too unlikely that so many ticks are arriving during this minuscule window....
Ignored
Yep, you are absolutely correct. These simple indicators take maybe 1 millisecond to process a tick. My best guess is that there is other internal MT4 processing (occurring before/after our indicators start function executes) that is causing the delay in processing new ticks.

It's hard to speculate without seeing the internal MT4 code. Incoming ticks are probably received via some type of message queue. I think indicators are on their own thread for execution. Not sure about EAs.

For indicators/EAs, there is probably some minimal amount of "overhead" associated with processing each tick (outside of our start function). This overhead may be 10 ms or 100 ms depending on the complexity of the charts.

I bet the mql4.com website has some information about the stuff that happens for every incoming tick. Regardless, I bet the answer is out there somewhere...but the explanation is probably very technical and involves messages queues and single/multi-threaded processes and is way beyond my understanding of MT4.
  • Post #13
  • Quote
  • May 2, 2012 9:19pm May 2, 2012 9:19pm
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
zznbrm

Thanks for the lesson today, there are only a few people I will look at their code, your one.

....

My understanding of how indicators run in MT is that all indicators run on what MT calls the Main thread along with the platform, and EAs and scripts run on the execution thread. EAs do not receive ticks per say but make a copy of the data from the main thread to run on. that is why if you run a script in a loop and use it to trade you have to use the refresshrate() funcition. or the script will never see fressh data.

If an EA or Script calls an indicator with say the iCustom function, it actually loads a second copy of the indicator on the back of the EAs so the more indicator it calls the more code is loaded on the back of the EA the slower the ea will run, the indcator on the chart are not accessed by an EA.

all so I notice that you can have two charts open with the same symbol and all the same indicators on each window. that only one windows is updated at a time, The window with the title bar hi lighted is run first with the others run in z-order one at a time. I loaded down two windows with code to slow down execution, to check this out.

Keit
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #14
  • Quote
  • May 3, 2012 2:56am May 3, 2012 2:56am
  •  rooicol
  • Joined Jan 2010 | Status: Trader | 494 Posts
Quoting CockeyedCowboy
Disliked
zznbrm

all so I notice that you can have two charts open with the same symbol and all the same indicators on each window. that only one windows is updated at a time, The window with the title bar hi lighted is run first with the others run in z-order one at a time. I loaded down two windows with code to slow down execution, to check this out.

Keit
Ignored
That's interesting, never really thought about that before, I just vaguely presumed it kind of did it all at once sort of, but I guess it has to work it's way through in an sequential order. This is useful information regarding GlobalVariableSet() and FileWrite(), if you have other charts running GlobalVariableGet() and FileRead().
  • Post #15
  • Quote
  • May 3, 2012 10:52pm May 3, 2012 10:52pm
  •  zznbrm
  • Joined Jul 2008 | Status: Member | 878 Posts
Quoting CockeyedCowboy
Disliked
My understanding of how indicators run in MT is that all indicators run on what MT calls the Main thread along with the platform, and EAs and scripts run on the execution thread. EAs do not receive ticks per say but make a copy of the data from the main thread to run on. that is why if you run a script in a loop and use it to trade you have to use the refresshrate() funcition. or the script will never see fressh data.

If an EA or Script calls an indicator with say the iCustom function, it actually loads a second copy of the indicator on the back...
Ignored
Very good information, CockeyedCowboy. Thanks for all of your efforts!

Both you and rooicol are MT4 wizards!
  • Post #16
  • Quote
  • May 4, 2012 7:16am May 4, 2012 7:16am
  •  rooicol
  • Joined Jan 2010 | Status: Trader | 494 Posts
Quoting zznbrm
Disliked
Very good information, CockeyedCowboy. Thanks for all of your efforts!

Both you and rooicol are MT4 wizards!
Ignored
Thanks for the vouch
  • Post #17
  • Quote
  • May 4, 2012 10:25am May 4, 2012 10:25am
  •  CockeyedCowboy
  • | Joined Apr 2006 | Status: Trader Keit | 286 Posts
rooical

sorry for eating up your thread with unrelated posts.


zznbrm

As I said in the earlier post theres only a few people that I will bother to read and look at code, your one, and thanks for the heads up on rooicol will be look hard at his work too, but dont tell him.

I will give you a sneake preview on one of my new projects, will be making in it so one can lock it to their desk top, but dont tell no one yet.

keit


Quoting zznbrm
Disliked
Very good information, CockeyedCowboy. Thanks for all of your efforts!

Both you and rooicol are MT4 wizards!
Ignored
Attached Image (click to enlarge)
Click to Enlarge

Name: ticker tape.jpg
Size: 20 KB
Trader Keit ... Methods Of A Dirt Road Mad Man....
  • Post #18
  • Quote
  • May 9, 2012 4:24am May 9, 2012 4:24am
  •  luckygold
  • | Joined May 2009 | Status: Member | 12 Posts
Thanks CockeyedCowboy

good indicators ... i like it
  • Post #19
  • Quote
  • May 14, 2012 9:07am May 14, 2012 9:07am
  •  recidiviste
  • | Commercial Member | Joined May 2009 | 777 Posts
Quoting rooicol
Disliked
Hi all,

Here are four indicators i made up to display more information about the flow of incoming ticks.

Attachment 960909

The red histogram values are the values for each tick, and the green lines are the moving averages of the last 100 ticks. The moving average period can be set in the indicator's inputs. The indicators can also be toggled to run on all ticks, or only on ticks where the bid price changes. This compresses the data a little so you get a greater time period in one screen.

The tick spread histogram shows the spread...
Ignored
-------------

hello rooicol good day to you

pls can you help me with process for tick logger

tick logger is an indicator i put in the chart ? or where pls ?

i created a file name Tick Log in mt4/expert = OK


inside the Tick Log file must put what excel sheet to recieve data ???

thanks

all other are working fine !

tick spread is ok always + data

tick size is + & - data i think ? (does a histo around zero help ? )

tick rate is + data ok

my big problem is that they are not syncronised/syncronisation ....

think you can make an interesting indicator out of those

outputs if i could study output/visualize it ?

thanks for your time regards
:peace: BROKENGLISH
  • Post #20
  • Quote
  • May 14, 2012 1:06pm May 14, 2012 1:06pm
  •  recidiviste
  • | Commercial Member | Joined May 2009 | 777 Posts
2012.05.14 19:03:57rooicol - Tick Logger: cannot open file Crogram FilesADSS MT4 TerminalexpertsfilesTick Log/145028574/EURUSD 2012-05-14.csv


thanks for help
:peace: BROKENGLISH
  • Platform Tech
  • /
  • Tick Size, Tick Rate, Tick Spread, and Tick Logger indicators
  • Reply to Thread
    • Page 1 2
    • Page 1 2
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021