
MetaTrader 5 made Python Trading Bot development significantly simpler. Suddenly it was possible to access the vast range of features available on MetaTrader without going through the pain of learning C++.
For Python developers, it was a double win. Python has a huge range of free libraries available for just about any time of computing discipline you can imagine, and it’s incredibly easy to integrate them together. My company, Creative Appnologies, uses this feature of Python for much of our analysis. An open-source version of our Python Trading Bot is being developed and is available on GitHub.
One of the key functions you need in a Trading Bot is the ability to list all your open positions. This can be especially useful if you’re tracking multi-day trades.
Join our amazing Discord community here.
To do this on MetaTrader 5, do the following:
Integrate the following code:
# Function to retrieve all open positions
def get_open_positions():
# Get position objects
positions = MetaTrader5.positions_get()
# Return position objects
return positionsSubscribe to receive more amazingly helpful tips.
No comments yet