Python integration - Volume always shows up as 0 when using symbol_info_tick

 

I'm new to python and mql5, I'm teaching myself both currently. Can someone explain why this code always prints volume equal to 0? (blocked my user & pass for my mt5


import MetaTrader5 as mt5
from datetime import datetime


mt5.initialize()
if not mt5.initialize():
    print(f"initialize() failed, error code = {mt5.last_error()}")
    mt5.shutdown()
    quit()

authorized = mt5.login(xxx, password="xxx", server="MetaQuotes-Demo")

if not authorized:
    print("failed to connect to the demo account #{}, error code: {}".format(5014437991, mt5.last_error()))
    mt5.shutdown()
    quit()

symbol = "EURJPY"
timeframe = mt5.TIMEFRAME_M1

from_time = datetime.now()
count = 5


tick = mt5.symbol_info_tick(symbol)


print(tick)

The output is this:

Tick(time=1686903346, bid=153.955, ask=153.962, last=0.0, volume=0, time_msc=1686903346462, flags=6, volume_real=0.0)
 
Your topic has been moved to the section: Expert Advisors and Automated Trading — In the future, please consider which section is most appropriate for your query.
 
Michael StanCan someone explain why this code always prints volume equal to 0? (blocked my user & pass for my mt5

You are retrieving a single tick of data, so tick volume is 0. Only when obtaining bar information will the tick volume be reported.

Also, for Forex and other non-centralised symbols, real volume information is not usually available, and only tick volume is available for bar data.

You will however, get real volume, for centralised exchange symbols like Futures, Stocks, etc.

 
Fernando Carreiro #:

You are retrieving a single tick of data, so tick volume is 0. Only when obtaining bar information will the tick volume be reported.

Also, for Forex and other non-centralised symbols, real volume information is not usually available, and only tick volume is available for bar data.

You will however, get real volume, for centralised exchange symbols like Futures, Stocks, etc.

How do I obtain bar info?
 
Michael Stan #: How do I obtain bar info?

For MQL5: Documentation on MQL5: Timeseries and Indicators Access

For Python: Python Integration

copy_rates_from

Get bars from the MetaTrader 5 terminal starting from the specified date

copy_rates_from_pos

Get bars from the MetaTrader 5 terminal starting from the specified index

copyrates_range

Get bars in the specified date range from the MetaTrader 5 terminal

Documentation on MQL5: Timeseries and Indicators Access
Documentation on MQL5: Timeseries and Indicators Access
  • www.mql5.com
Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
this does not work. last and volume are zeros even with the copy function. don't know the issue
 
@Michael De #: this does not work. last and volume are zeros even with the copy function. don't know the issue
"Last" and "Volume" are only available for exchange based assets, like Futures or Stocks. It is not available for non-centralised assets, like Forex, CFDs, etc.