- Here you find dozens of articles about python and how to use it: https://www.mql5.com/en/search#!keyword=Python&module=mql5_module_articles
- For the future: Please use the code botton (or Alt+S) for your code.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
When I execute the code in Meta Trader 5,
it does not execute all the scripts,
but only prints the message. (((Hello))). Does anyone know the solution, please?
# Copyright 2022, MetaQuotes Ltd.
# https://www.mql5.com
import MetaTrader5 as mt5
mt5.initialize()
print("hello")
if not mt5.initialize():
print("initialize() failed")
# Define the symbol for which you want to check bid and ask prices
symbol = "EURUSD"
# Get bid and ask prices
ticks = mt5.copy_ticks_from(symbol, mt5.TIMEFRAME_TICK, 0, 1)
if ticks is not None and len(ticks) > 0:
bid = ticks[0].bid
ask = ticks[0].ask
print(f"Bid Price for {symbol}: {bid}")
print(f"Ask Price for {symbol}: {ask}")
else:
print(f"No tick data available for {symbol}")