MetaEditor HelpDeveloping programsWorking with Python

Working with Python

The are a lot of machine learning, process automation, as well as data analysis and visualization libraries for the Python language. The advanced language possibilities can now be applied in the platform through the Python integration module.

  • Exchange data can be easily and quickly obtained from the trading platform and then analyzed using Python tools: hundreds of thousands of financial symbol ticks can be requested with one command
  • Obtain account trading state and trading history to calculate statistics
  • Perform trading operations following your own algorithm

Python scripts run directly on platform charts, similarly to regular MQL5 programs.

MetaEditor features special integrated functions for Python development: a wizard for creating blank scripts, the ability to run directly from the editor, output of messages and errors to the common log, and so on.


To get started, specify the path to the Python executable in MetaEditor settings:

Specify the path to the Python executable

If Python is not installed on your computer, click Install to download the installation file.

Creating a script

Open MQL5 Wizard and select "Python Script". Next, specify the script name and select library dependencies to be included in the code.

Creating a Python script

Scripts can be created using the MQL5 Wizard, while you can instantly add required library dependencies in the code.

Running the script

To run a script, press "Compile" (F7). This will open a trading platform, and the script will be launched on the current chart. Messages from the Python console (stdout, stderr) will be displayed under the Errors section.

Running a script in the editor

To enable the use of the MetaTrader 5 library, install it using the following command:

pip install MetaTrader5

For Python integration details please read the relevant documentation.