MetaTrader Integration - TradeDevs
Many steps were taken to add the BEM API endpoints and the relevant request functions and their parameters to mql5 to make it possible to send, cancel and track orders.
This article covers the steps that one needs to follow to install the custom libraries and send signals to the BOTS platform.
Step 1 - Add the correct endpoint URL to MetaTrader
To add the URL to MetaTrader, click on MetaTrader5>Tools>Options>Expert Advisor and add the required endpoint (paper or production) as shown in the image.
Step 2 - Install necessary libraries and files
All files for algorithmic trading (ready-made programs) and application development in MetaEditor environment are located in the /MQL5 (/MQL4) directory of the trading platform. To quickly jump to it, click open Data Folder in the File menu.
Out of the many folders, you will find the the ‘Include’ folder - folder for storing common *.mqh files included in various programs and the ‘Experts’ folder - folder for storing compiled (*.ex5, *.ex4) and source files of EAs (*.mq5, *.mqh, *.mq4).
To install our custom library, you will need to simple copy and paste the BEMAPI.mqh file and the JAson file into the include folder of your local MQL5/MQL4 folder.
You will find the required files on our Github Repository.
Step 3 - Testing the bridge using our custom expert advisor
To give you a better idea of how this bridge works, we have created a custom moving average EA that you can use for testing the bridge and possibly using it as reference for your future EAs. The script for this can also be found on our Github Repository. Copy this script into the ‘Experts’ folder and compile it.
Now, all you have to do is fill the parameters and you are all set.
As shown in the picture above, you can fill in your bot name and api key as well the quantity percentage while loading the EA. This can come in handy if you decide to make your bot trade in multiple assets at a time.
The BEMAPI library also makes it possible to receive responses from the api. For instance, if the order is placed, you will receive a message to confirm the order success and in the case of rejection, you will receive the reason for rejection. An example of this is shown in the picture below.