Backtesting using python

 
Does anyone know how to use Python scripts in backtesting, as the socket function doesn't seem to work there?
 

I found some video about "Backtesting the 3-candle-setup with Python" - post #69 
and "Python & MetaTrader Back Testing Systems" - post  #67 
more on this thread: Python in algorithmic trading 

Python in algorithmic trading - Metatrader 5 for python, Streamlit; Building a web application using MetATRader 5 with Streamlit
Python in algorithmic trading - Metatrader 5 for python, Streamlit; Building a web application using MetATRader 5 with Streamlit
  • 2023.04.13
  • www.mql5.com
Building a web application using python and metatrader 5 with streamlit. The python code uses the streamlit and metatrader 5 libraries, along with pandas for importing data frames and plotly for graphing
 
Sergey Golubev #:

I found some video about "Backtesting the 3-candle-setup with Python" - post #69 
and "Python & MetaTrader Back Testing Systems" - post  #67 
more on this thread: Python in algorithmic trading 

I think the question Marius was trying to ask was about using the MT5 strategy tester for backtesting an EA that is connecting with Python via sockets.

The article you have posted is describing Python controlling MT5 (without the need for an EA) via the Python Metatrader5 library. In that case the backtesting is done by Python, not the MT5 strategy tester.


Why would we want to connect an EA with Python via sockets?

Suppose you have an EA that whenever it's about to enter a trade following the rules in its only logic it also checks with an "external oracle" that some additional conditions are met. For example, this oracle could be a Python system that implements several machine learning models. Imagine for instance a ML model that is monitoring news sites and estimating market sentiment, another model that has previously trained with data from a number of other trading instruments that are correlated with the EA's main instrument to predict price direction, and so on). This kind of machine learning model can be implemented in MQL5, but it is a lot simpler to build, train and run in Python.