My code works in Jupyter , but not in Visual Code Studio

 

My code works in Jupyter , but not in Visual Code Studio.

This is the code I want to run :

import MetaTrader5 as mt5
from datetime import datetime

symbol = 'XAUUSD.GK'

price = mt5.symbol_info_tick(symbol).ask

print (price)

Improperly formatted code edited by moderator. 

In Jupyter Lab it gave me the exact price 1973.035. 

In VSCode it gave me this error : AttributeError: 'NoneType' object has no attribute 'ask'


How come the same exact code works differently using different editor. I also have checked using 

from sysconfig import get_paths as gp; print(gp()['include']) and it refers to the same include folder. 


What alternative to Python for Meta Trader 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
 
  1. You are discussing 3rd party editors, and their functionality or configuration, have nothing to do with MetaTrader or MetaQuotes. Please consult with the editor's support services.
  2. Your code is a Python application which will run according to the Python interpreter's rules and not according to the editor's.
  3. An alternative to Python is to use MetaTrader's own programming language, namely MQL5, which has advantages:
    1. It is compiled instead of interpreted.
    2. It is faster than Python.
    3. It is event driven.
    4. It exposes much more of MetaTrader's functionality, than Python is able to access.
 

Improperly formatted code edited by moderator. Please use the CODE button (Alt-S) when inserting code.

Code button in editor

 
Fernando Carreiro #:
  1. You are discussing 3rd party editors, and their functionality or configuration, have nothing to do with MetaTrader or MetaQuotes. Please consult with the editor's support services.
  2. Your code is a Python application which will run according to the Python interpreter's rules and not according to the editor's.
  3. An alternative to Python is to use MetaTrader's own programming language, namely MQL5, which has advantages:
    1. It is compiled instead of interpreted.
    2. It is faster than Python.
    3. It is event driven.
    4. It exposes much more of MetaTrader's functionality, than Python is able to access.

Ok thanks. I'll ask about it in other forum. Coz I saw questions about python codes just now so I just went with it. You can close or delete the thread now. 

I will consider that , I'm still new anyway.