Bid & Ask price always zero for most of the symbols using python

 

Hi,

Bid & Ask price always zero for  most of the symbols using python

symbol = "CAG"
symbol_info = mt5.symbol_info(symbol)
print(symbol_info.bid)
print(symbol_info.ask)


for below symbols price are available

AAPL__188.28
ADBE__495.32
ADI__190.6
ADM__78.61
AES__21.07
CFG__26.75
DAL__48.17
K__67.11
KEY__9.49
MSFT__330.36
UAL__55.97
USB__33.6 

any suggestions

thanks

Documentation on MQL5: Python Integration / symbol_info
Documentation on MQL5: Python Integration / symbol_info
  • www.mql5.com
symbol_info - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Documentation on MQL5: Python Integration / symbol_info_tick
Documentation on MQL5: Python Integration / symbol_info_tick
  • www.mql5.com
symbol_info_tick - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

same results with symbol_info_tick  also

symbol = "CAG"
symbol_info = mt5. symbol_info_tick (symbol)
print(symbol_info.bid)
print(symbol_info.ask)


thanks

Documentation on MQL5: Python Integration / symbol_info
Documentation on MQL5: Python Integration / symbol_info
  • www.mql5.com
symbol_info - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Please post the full code to be able to reproduce it.
 
 import MetaTrader5 as mt5

if not mt5.initialize():
    print("Failed to initialize MetaTrader 5")
    exit(1)
 
login = 123456 
password = "xxxxxxxx" 
server = "000.00.000.000:443"  
 
if not mt5.login(login, password, server):
    print("Failed to connect to the MT5 server")
    mt5.shutdown()
    exit(1)

my_array =['AAPL','CIG','KO','LEN','LLY','LUV','LVS','LYV','CAG','MA','MCD','MDT','META','MGM','MSFT','GM','GOOG','GOOGL','GS','HAL','HBAN','ES','HON','HPE','HPQ','HWM','IBM','ICE','INTC','IPG','IR','JNJ','JNPR','JPM','KMI','KO','LEN','LLY','LUV','LVS','LYV','MA','MCD','MDT','META','MGM','MMM','MNST','MO','MOS','MPC','MRK','MRO','MS','NDAQ','NEE','NFLX','NI','NXPI','OKE','OMC','ON','ORCL','OXY','PARA','PCAR','PEG','PEP','PFE','PM','PNC','PPL','PSX','PXD','PYPL','QCOM']
for element in my_array:
    try:
        price = mt5.symbol_info_tick(element).ask
        price2 = mt5.symbol_info_tick(element).bid
        print( element + "__" + str(price) + "__" + str(price2))
    except Exception as e:
        print(element + "_____")


I am able to get ask/bid prices if i run the below code

selected=mt5.symbol_select("GOOGL",True)
if not selected:
    print("Failed to select. error code =",mt5.last_error())
else:
    print("Selected") 
Should i select the symbol before sending the order or is there any thing to do

thanks
 

any help

thanks

 
arjunender pabba #:

any help

thanks

I have the same issue... Are you solved?