TickVol in MT4

 

Hello! I know that mt4 doesnt have a tick history. So I was thinking if I can make one. Like an indicator which can start recording, and displaying as a hystogram,as soon as it is loaded on the chart.

I started to right something to record the ticks for the current bar into and EA : 

void OnTick()
  {
//---
   pricecheck();
   tick++;
   if(Newbar())
     {
     Comment("tick=",tick," tickup=",tickup," tickdwn=",tickdwn);

      tick=0;
      tickdwn=0;
      tickup=0;
      pretbid=Bid;pretask=Ask;
      
     }
  }
//+------------------------------------------------------------------+
bool Newbar()
  {

   datetime static prev=0;
   if(prev!= Time[0])
     {
      prev=Time[0];
      return true;
     }
   return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void pricecheck()
  {
   if(Bid>pretbid || Ask>pretask)
      {tickup++;pretbid=Bid;pretask=Ask;}
  
      if(Bid<pretbid ||Ask< pretask)
         {tickdwn++;pretbid=Bid;pretask=Ask;}
  }

But not sure how to continue from here. How to keep records of this, and display as hystogram for an indicator so it can have a separate window.

Kindly advice!

 

There are several "tick recorders" for MT4 in the CodeBase if you wish to study them. Here are a few examples from a quick search ...

Code Base

Tick Chart and Record

Artem Goritsky, 2013.09.19 07:22

Record, storage and displays of data, fully tick chart in MetaTrader.

Code Base

LogTickData

Rozana Sustar, 2014.11.27 11:43

Easy to use ticks recorder.

Code Base

Tick Collector TickSave

Andrey Khatimlianskii, 2008.01.28 11:01

The Expert Advisor collects tick history for specified symbols into csv-files.

Code Base

TickRecorder

davidruzicka, 2016.08.22 16:17

Continuously records tick data in format "DateTime, Bid, Ask, Volume" even after restart.


 
Daniel Cioca:

Hello! I know that mt4 doesnt have a tick history. So I was thinking if I can make one. Like an indicator which can start recording, and displaying as a hystogram,as soon as it is loaded on the chart.

I started to right something to record the ticks for the current bar into and EA : 

But not sure how to continue from here. How to keep records of this, and display as hystogram for an indicator so it can have a separate window.

Kindly advice!

Good morning .

If i'm not mistaken the Volume[x] is the tick volume in MT4 

(ow i just saw the tickdwn++ , sorry)

You can capture the points deviation too and store just that , if you establish that one entry represents one tick .

You can then record per time period and the timing of the bars is handy for that as when a new bar opens you will know you need to start a new file and close the previous.

There is one problem you cannot work around though , connection loss and shutdowns

 
Lorentzos Roussos #:

Good morning .

If i'm not mistaken the Volume[x] is the tick volume in MT4 

(ow i just saw the tickdwn++ , sorry)

You can capture the points deviation too and store just that , if you establish that one entry represents one tick .

You can then record per time period and the timing of the bars is handy for that as when a new bar opens you will know you need to start a new file and close the previous.

There is one problem you cannot work around though , connection loss and shutdowns

I dont need to save the history. I only need the history only from when I put the indicator on the chart, forward. So instead of writing in the files, I was thinking to an array, or two arrays, one for upticks and one for downticks … but not sure how to draw the histogram on that 
 
Daniel Cioca #: I dont need to save the history. I only need the history only from when I put the indicator on the chart, forward. So instead of writing in the files, I was thinking to an array, or two arrays, one for upticks and one for downticks … but not sure how to draw the histogram on that 
Study the examples I mentioned. At least one of them draws the ticks, so you can study that one to get some ideas.
 
Fernando Carreiro #:
Study the examples I mentioned. At least one of them draws the ticks, so you can study that one to get some ideas.
Thank you! I did study them. They are good technics to keep records into files of the price of every tick. What I need is like a volume, but splited. Count how many ticks were positive and how many were negative, and display the results at the end of every candle .
But thank you! 
Reason: