Python – Metatrader – Backtesting part 3

YouTube Video Thumbnail

The third stage of backtesting a python trading robot. I’ve removed most of the dirty code from the ma cross strategy now so it doesn’t need a lot of modification to work in test or live mode.

In this code I use pandas_ta as a technical analysis library. As of the time fo writing this there is an incompatibility between the released version of pandas_ta and versions of numpy from 2.0.0 onwards. To work around the problem I forked the repository and made a quick one line change to pandas_ta. This is a quick hack and in no way associated with the ongoing development of pandas_ta but you are welcome to use my custom version if it helps.

I did not change the version numbers from the release version so if you already have pandas_ta installed I recommend uninstalling first.

To install my custom version


pip uninstall pandas_ta
pip install -U git+https://github.com/OrchardForexTutorials/pandas-ta.git --no-cache-dir

You can download the code from this tutorial here

Looking for a broker? Support the channel by using one of these links. We receive a commission on your trades from the broker at no cost to you:

For Australian customers without trading restrictions – Black Bull
Outside Australia – FXTrading

Scroll to Top