This project uses the ⭐🚀 tradeo 🚀⭐ library to build a forex bot using MetaTrader 5.
I used Docker to create an image that contains Wine 🍷 and MetaTrader 5. I create a bind between the Docker container and the project to have access to the files generated by the bot.
Only first time is required to install tonistiigi/binfmt image before run the docker-compose:
docker run --privileged --rm tonistiigi/binfmt --install allRun "make run_docker" to activate MetaTrader. If a connection error occurs on Debian repository packages, run the "make run_docker" command again. If a permission error occurs, use "sudo chmod -R 777" to metatrader folder.
Once it's available, access it through the browser at localhost:3000.
- Log in to your broker account.
- Add the symbols you want to trade. There is the option for the bot to open them automatically, but I do not recommend it.
- Locate the data folder. To do so, you need to go to File > Open Data Folder.
The usual thing is that the folder is located in two possible locations:
- drive_c/Program Files/MetaTrader 5
- drive_c/users/abc/AppData/Roaming/MetaQuotes/Terminal/<hexadecimal code>
- Download mt_tb_expert.ex5 file. This expert is used by the Tradeo library to communicate with MetaTrader; it does not execute trades on its own unless instructed by the user. Put the file in the proper directory: <data folder>/MQL5/Experts/Advisors/mt_tb_expert.ex5
- Activate the "Algo Trading" button at the top of MetaTrader.
- Double click in the expert to activate it in any symbol chart (e.g. USCAD, M5), it does not matter which chart you use. But only in one of them.
We copy the ".env" file suggested by the README of the Tadeo library.
I edit de crontab (crontab -e):
@reboot cd ~/git/sorul_tradingbot/ && make start_docker
*/5 * * * 0-5 cd ~/git/sorul_tradingbot/ && make run_forexYou can use the simulator to test your strategies without using real money.
First, make sure you have the required data file. You can find a sample data file at sorul_tradingbot/strategy/simulator/data/sp500_5m_test.csv. If you want to use your own data, place it in the same directory.
To run the simulator, use the debug configuration provided in .vscode/launch.json called "Simulator".
