Two Brokers with API

 

Hello everybody,


I need your help. I code a Program with two brokers respectively two MT4 Instances.

The program opens a Buy Trade on Broker1 and a Sell Trade on Broker2 at a specific time. 

So in the next step I am going to close all trades at a later time.

Both trades have to close at 0€. This means: if the Sell Trade is -0.20 € we have to close the Buy Trade at +0.20€.

The program may only stop trading if both instances come out at 0€.


Example:

If(TimeCurrent() == 16:00)

{Buy Broker1 && Sell Broker2}

If(TimeCurrent() == 18:00){

if(OrderProfit() == Broker1 && Broker2){

Close Broker1 && Broker2 }

}


How can I best program this? I know I need the Mql4-Api. But the beginning is difficult for me, how do I program it e.g. in C #?


 
Predatoy:

Hello everybody,


I need your help. I code a Program with two brokers respectively two MT4 Instances.

The program opens a Buy Trade on Broker1 and a Sell Trade on Broker2 at a specific time. 

So in the next step I am going to close all trades at a later time.

Both trades have to close at 0€. This means: if the Sell Trade is -0.20 € we have to close the Buy Trade at +0.20€.

The program may only stop trading if both instances come out at 0€.


Example:


How can I best program this? I know I need the Mql4-Api. But the beginning is difficult for me, how do I program it e.g. in C #?


When you need to create applications spawning multiple brokers I guess you have to either use some third-party API like MetaApi or code the communication between MetaTrader terminal instances in MQL language. It is up to you to choose, but the advantage of external API is that you can use any programming language you know so that you can implement the app faster and of higher quality.

Professional REST and websocket API for your MetaTrader terminals#
  • metaapi.cloud
Note to reader: We aimed to create a powerful yet simple API. If you'll find a missing feature you need, please drop us a message via online chat. We will be fanatically improving our product to keep it the best and most convenient option on the market, so there are good chances that your request will be fulfilled in a timely manner. Please do...
 
ROMAN KISILENKO:

When you need to create applications spawning multiple brokers I guess you have to either use some third-party API like MetaApi or code the communication between MetaTrader terminal instances in MQL language. It is up to you to choose, but the advantage of external API is that you can use any programming language you know so that you can implement the app faster and of higher quality.

But how i can programming the communication in MQL4? I need only the Signal: Broker 1 and Broker2 Orders Profit is 0. Then i Close the Trades and i have no Profit or Losses. Both MT4 instances run on a Windows server.
 
Predatoy:
But how i can programming the communication in MQL4? I need only the Signal: Broker 1 and Broker2 Orders Profit is 0. Then i Close the Trades and i have no Profit or Losses. Both MT4 instances run on a Windows server.

I think it should be possible to use filesystem API calls and exchange data between MT terminals via filesystem. Check https://docs.mql4.com/files/fileopen and https://www.mql5.com/en/articles/503.

FileOpen - File Functions - MQL4 Reference
FileOpen - File Functions - MQL4 Reference
  • docs.mql4.com
[in]  The name of the file can contain subfolders. If the file is opened for writing, these subfolders will be created if there are no such ones. [in]  value to be used as a separator in txt or csv-file. If the csv-file delimiter is not specified, the default delimiter is ";". If the txt-file delimiter is not specified, then no separator is...
Reason: