TickVolume is not available MT5 from python

 

When I access MT5 from python, I can get date and price information, but not last and tick_volume.

I couldn't get them with my own code, nor with the official sample code. The result is always 0.

from datetime import datetime
import MetaTrader5 as mt5
import pandas as pd

if not mt5.initialize():
    print("initialize() failed")
    mt5.shutdown()
    exit()

symbol = "USDJPY"
start_date = datetime(2024, 12, 3, 3, 0)
end_date = datetime(2024, 12, 3, 15, 59)
ticks = mt5.copy_ticks_range(symbol, start_date, end_date, mt5.COPY_TICKS_ALL)

mt5.shutdown()

ticks_frame = pd.DataFrame(ticks)

print("Ticks DataFrame Head:")
print(ticks_frame.head())

ticks_frame['time'] = pd.to_datetime(ticks_frame['time'], unit='s')

trade_ticks = ticks_frame[ticks_frame['volume'] > 0]

print(trade_ticks[['time', 'bid', 'ask', 'last', 'volume']].head())
print(f"Total trade ticks retrieved: {len(trade_ticks)}")


Is there any person who can see tick_volume information in this method?

 

There is no last or volume data in the ticks tab either . 

It's probably empty on yours too.

The tick volume is essentially the changes of bid or ask , so you could construct it yourself with each tick . 

The last , maybe the last changed value 

for forex pairs 


 
Lorentzos Roussos #:

There is no last or volume data in the ticks tab either . 

It's probably empty on yours too.

The tick volume is essentially the changes of bid or ask , so you could construct it yourself with each tick . 

The last , maybe the last changed value 

for forex pairs 


Thanks for your reply.

I just noticed that too.

Since tick is once by itself, there cannot be a tickVolume.

tickVolume = tick count in an unit time.

I had to set the Period.


Thank you!

 

MoukemasSu: When I access MT5 from python, I can get date and price information, but not last and tick_volume. I couldn't get them with my own code, nor with the official sample code. The result is always 0. Is there any person who can see tick_volume information in this method?

ticks = mt5.copy_ticks_range(symbol, start_date, end_date, mt5.COPY_TICKS_ALL)

There is no such thing as tick volume on ticks data, only on bar rates data.

Tick volume is simply a tick count, so for tick data each reading is simply a single tick.