Hi, I'm trying to make a bot for trading, I'm still very new to this. I use Meta Trader 5.
I tested the code to get a price on Jupyter Lab, and it worked fine. Then I copy pasted the same exact code to Visual Code Studio and getting an error, how come the same exact code works on one editor and not on the other editor ?
This is the code :
But on Visual Code Studio, it doesn't work and gave me this error message AttributeError: 'NoneType' object has no attribute 'ask'
I also have tried running this code on both Jupyter and Visual Code Studio :
from sysconfig import get_paths as gp; print(gp()['include'])
and it refers to the same folder path. C:\Users\Name\AppData\Local\Programs\Python\Python310\Include
Can anyone please tell how to fix it ?
-edit-
Problem solved.
I have to logout and use :
authorized=mt5.initialize(path="C:/Program Files/[THIS IS THE BROKER'S FOLDER APP]/terminal64.exe",login=accountnumber, server="demoserver",password="yourownpass")
It should use the terminal64.exe from the broker's folder app, and it has to be initialized first to use it.
Please close the thread. It's solved.
I tested the code to get a price on Jupyter Lab, and it worked fine. Then I copy pasted the same exact code to Visual Code Studio and getting an error, how come the same exact code works on one editor and not on the other editor ?
This is the code :
import MetaTrader5 as mt5 from datetime import datetime symbol = 'XAUUSD.GK' price = mt5.symbol_info_tick(symbol).ask print (price)On Jupyter It gave me the exact thing I want, 1973.035 , which is the price I want to check.
But on Visual Code Studio, it doesn't work and gave me this error message AttributeError: 'NoneType' object has no attribute 'ask'
I also have tried running this code on both Jupyter and Visual Code Studio :
from sysconfig import get_paths as gp; print(gp()['include'])
and it refers to the same folder path. C:\Users\Name\AppData\Local\Programs\Python\Python310\Include
Can anyone please tell how to fix it ?
-edit-
Problem solved.
I have to logout and use :
authorized=mt5.initialize(path="C:/Program Files/[THIS IS THE BROKER'S FOLDER APP]/terminal64.exe",login=accountnumber, server="demoserver",password="yourownpass")
It should use the terminal64.exe from the broker's folder app, and it has to be initialized first to use it.
Please close the thread. It's solved.