Skip to content

Latest commit

 

History

History
71 lines (61 loc) · 4.47 KB

File metadata and controls

71 lines (61 loc) · 4.47 KB

How to Build a MetaTrader 5 Python Trading Bot (Expert Advisor) Series

This is the code for my series How to Build a MetaTrader 5 Python Trading Bot found on Medium @appnologyjames

The five part series covers all you need to get started building your very own Python Trading Bot. Each episode in the series contains working code samples to help you build your own.

Join Our Community

We love connecting with our audience! Join us on the following links:

  1. Discord
  2. Telegram
  3. TradeOxy Platform
  4. Upcoming Content
  5. Upcoming Features
  6. Custom Trading Bot development

Requirements

  • Windows 10 or above endpoint (for whatever reason, MetaTrader doesn't support their Python API on macOS or Linux)
  • MetaTrader 5 (note MetaTrader 4 doesn't have a Python API)
  • A basic knowledge of Python, such as functions and variables
  • Python 3 installed (my build version is 3.10)
  • An IDE (I used JetBrains Pycharm Community Edition)

Blog Articles Series

This episode covers everything you need to get started building your Python Trading Bot, including:

  • How to set up your files
  • How to securely import your settings, including username/password
  • How to initialize your project through ___main___
  • Where to find the MetaTrader 5 Python API

This episode shows you how to make and modify trades on MetaTrader 5. It covers:

  • How to enable a trade symbol on MetaTrader 5
  • Placing Trades
  • Canceling an Order
  • Modifying an open position

This episode demonstrates how to break down a strategy into a series of codified steps. By the end of the episode, you can take an untested strategy and implement it in your code. It covers:

  • Setting up a program structure
  • Design considerations
  • Algorithmic decision making
  • Initiating trades based on decisions Note: The algorithm used in this episode is simplistic and not recommended. It is for demonstration purposes only!

Demonstrates how to close the loop on your automated strategy, including:

  • Design considerations for parallel processing, polling method for data
  • Managing order queue
  • Some further improvements to consider

This episode shows you how to implement one of the most requested features I get: a trailing stop. It includes:

  • An overview of a trailing stop
  • Ways to take this code and improve it
  • How to use the modify_position() function to trail a price
  • How update an existing position

YouTube Episodes

Our YouTube channel TradeOxy contains tons of helpful content on how to use the AutoTrading Bot or build one for yourself. Check out these episodes:

  1. Secure Setup
  2. Connect To MetaTrader 5 with Python
  3. Retrieve 50000 Candlesticks from MetaTrader
  4. Add the EMA Indicator to Your Algorithmic AutoTrading Bot
  5. How to Install TALib on Windows
  6. Build Your Own AutoTrading Bot EMA Cross Detector
  7. How to Trade the EMA Cross Strategy with Your AutoTrading Bot
  8. How to Convert Your AutoTrading Bot Strategy into BUY and SELL Signals
  9. How to Calculate Lot Size for Your MetaTrader 5 Python Trading Bot
  10. How to Create Orders with Your MetaTrader Python Trading Bot