MetaTrader 5 Python Questions

 

My settings:

Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32

MetaTrader 5 x64 build 3311 started for MetaQuotes Software Corp.
Windows 11 build 22000, 12 x Intel Core i7-9750H  @ 2.60GHz, 22 / 31 Gb memory, 711 / 947 Gb disk, UAC, GMT+2
C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

I'm trying to run in MetaEditor the code from positions_get documentation

In MetaEditor I am getting the error

positions_get.py started        positions_get.py        1       1
SyntaxError: Non-UTF-8 code starting with '\xff' in file C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Scripts\Python\positions_get.py on line 1, but no encoding declared; see https://python.org/dev/peps/pep-0263/ f      positions_get.py        1       1
positions_get.py finished in 143 ms             1       1

If I run 'Python 3.9 (64-bit)', I see that the cursor does not exit the 'if' loop

And it should be like this:


Any idea why the cursor doesn't leave the 'if' loop?


 
The same code ( positions_get ) run from jupyter notebook works fine. I can't understand why the error when running the code in the terminal and through 'Python 3.9 (64-bit)'
Documentation on MQL5: Integration / MetaTrader for Python / positions_get
Documentation on MQL5: Integration / MetaTrader for Python / positions_get
  • www.mql5.com
positions_get - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
I solved my problem - my python script on my computer was not in 'UTF-8' encoding. I converted this file to 'UTF-8' using 'Noteepad++' and it worked.