On Approximating the Price Change per Tick (Per Unit of Tick Volume) in Historical Data

 

I have a question for everyone, and I would greatly appreciate your insights.

I would like to approximate the price change per tick (i.e., per unit of tick volume) in historical data.

The reason is that I would like to use this per-tick price change as a basis for allocating tick volume into buy-side and sell-side components.

For the current bar, this allocation is straightforward: in real time, we can simply check whether the price moved up or down compared to the previous tick, which gives us an accurate distribution.
However, for past bars, tick-by-tick data is not available, so the only option is to calculate some kind of approximation.

One idea I have considered is the following:

  1. Calculate the standard deviation (or median) of tick volume, and focus on the parts where the Z-score is less than or equal to zero.

  2. Further restrict this to cases where the tick volume is greater than or equal to 1.

  3. In other words, take the average per-tick price change over a chosen period, but only in situations where trading activity is relatively low.

My reasoning is that in such conditions, there is less likelihood of buy and sell forces canceling each other out, so the price movement per tick is more directly reflected in one direction.

That said, if anyone has ideas or suggestions for a more accurate way to estimate the per-tick price change in historical data, I would be very grateful to hear them.

Thank you very much.

 
History of real ticks is ususally provided by most of brokers - why not to use it?
 
テリーHowever, for past bars, tick-by-tick data is not available ...

It is available for MT5 on all brokers I know about, but how far it goes back, depends. Some brokers only offer a few months, while others offer many years of historical tick data.

So, yes you can read the available tick data for each bar and analyse it to calculate whatever metric you wish. I have done this quite often, for calculating things like the max/min/average spread, or the mid-prices for OHLC values, etc.

CopyTicks

Gets ticks in the MqlTick format into ticks_array

CopyTicksRange

Gets ticks in the MqlTick format within the specified date range to ticks_array

Besides doing it programmatically, you can also use the Symbols (Ctrl-U) panel to request and view the tick data.



Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
  • www.mql5.com
The function receives ticks in the MqlTick format into ticks_array. In this case, ticks are indexed from the past to the present, i.e. the 0...
 

To  Stanislav Korotky  &  Fernando Carreiro

Thank you all very much for your valuable feedback.

For now, I plan to work on creating code that allocates tick volume using the CopyTicks function.
Since I am still quite inexperienced when it comes to coding, I expect that I will have more questions to bring up in future conferences. I would be very grateful for your guidance and advice at those times as well.

 
テリー #:

To  Stanislav Korotky  &  Fernando Carreiro

Thank you all very much for your valuable feedback.

For now, I plan to work on creating code that allocates tick volume using the CopyTicks function.
Since I am still quite inexperienced when it comes to coding, I expect that I will have more questions to bring up in future conferences. I would be very grateful for your guidance and advice at those times as well.

Note that the volume retrieved via MqlTick is real volume for stocks and futures and not the tick volume seen in forex. If you want to extract volume tick-by-tick, I made an indicator to do that before, and the ticks are taken from tick_volume buffer.

I made an indicator which splits incoming buyer volume and seller volume, and also made another indicator which plots incoming volume in tick time.
 
@Conor Mcnamara #Note that the volume retrieved via MqlTick is real volume for stocks and futures and not the tick volume seen in forex. 
Not quite! "Tick Volume" is just a count of each tick change, so all you have to do is count them per the required time interval when processing the tick data. It's that simple!
 
Fernando Carreiro #:
Not quite! "Tick Volume" is just a count of each tick change, so all you have to do is count them per the required time interval when processing the tick data. It's that simple!
That is true actually for tick volume, that it's simply a counter.
But what I'm saying is that if he's doing the indicator for forex markets, then he should avoid using CopyTicks for volume as it always returns 0. It doesn't count anything.

CopyTickVolume on the other hand, will copy the same tick volume retrieved from the tick_volume parameter in the OnCalculate signature, while also giving the option to count the quantity of ticks on different timeframe bars
 
@Conor Mcnamara #That is true actually for tick volume, that it's simply a counter. But what I'm saying is that if he's doing the indicator for forex markets, then he should avoid using CopyTicks for volume as it always returns 0. It doesn't count anything. CopyTickVolume on the other hand, will copy the same tick volume retrieved from the tick_volume parameter in the OnCalculate signature, while also giving the option to count the quantity of ticks on different timeframe bars

You still missing the point—CopyTicks for tick volume does not return 0—it is in itself the tick volume. The volume field in ticks is the real volume, because the tick-volume for a tick is in fact just "1".

How do you think MetaQuotes comes up with the value to place in the "tick_volume" in that field in the first place?

All the M1 bar data was first originally build up from the tick data, and the "tick_volume" field was calculated by simply counting the ticks.

So no, the OP does not have to use the CopyTickVolume() when processing ticks. They simply have to count the ticks to derive the tick volume, because the tick-volume for a tick is simply "1".

 

He was also talking about an idea of calculating a standard deviation of ticks which would be involving bars of tick volume if it is timeframe based. The most simple thing to use for calculation is tick_volume, that's all. 

Fernando Carreiro #:

So no, the OP does not have to use the CopyTickVolume() when processing ticks. They simply have to count the ticks to derive the tick volume, because the tick-volume for a tick is simply "1".

All I have said here originally was that it's pointless to waste time with CopyTicks or CopyTick (which uses the MqlTick struct)

 
@Conor Mcnamara #He was also talking about an idea of calculating a standard deviation of ticks which would be involving bars of tick volume if it is timeframe based.

The OP wants to calculate the standard deviation of the tick volume in regards to "per-tick price change" and "allocating tick volume into buy-side and sell-side".

There is no way to avoid using CopyTicks() and the tick volume has to be counted based on direction or any other conditions the OP has.

Using the bar's volume (e.g. CopyTickVolume) would be useless for the requirements posted.

 
Fernando Carreiro #:

The OP wants to calculate the standard deviation of the tick volume in regards to "per-tick price change" and "allocating tick volume into buy-side and sell-side".

What I interpreted from that is that it gathers the data from previous bars first, and then continues on tick by tick =>as all indicators do

In regard to splitting tick volume into buy side and sell side, that has been published in the codebase

Code Base

Bull Bear Volume

Conor Mcnamara, 2025.07.29 20:05

An indicator that provides a clear visualization of volume pressure on each side of the market

Btw as you guys may know, we don't have order book level 2 data in Forex. Each bid price corresponds to an ask price. So the "buy side" and "sell side" in forex is completely artificial and there is no real imbalance of asks and bids, as there's no centralized order book