Creating an API using PHP for getting trading informations

 

Hello World!

I am new here, and i have searched for creating an API to get the trades that a user does using METATRADER 5 , user wants to show the history of his trades on his website, is there any possible way to do this? is there is any documentations for developers for creating RESTful API's using METATRADER? i want to get all the information's about a certain account, please help me on this, Thanks a lot!

 
I would go as following about it:

Develop a service in mql to feed an external MySQL database with the Infos needed.

Have the PHP Script Connect to MySQL reading the data from there.

The main challenge will be to feed the database.

This could be started with a local SQlite DB as a file, since this is already integrated into mql.

Later this could be exchanged to be an MySQL.

To use an external MySQL, an adaptor needs to be developed, utilizing MySQL.dll

I suggest to have separate machines for mql and MySQL since the MySQL will be exposed to PHP which in turn is exposed to the internet.
For security reasons.
 
Warednsour: I am new here, and i have searched for creating an API to get the trades that a user does using METATRADER 5 , user wants to show the history of his trades on his website, is there any possible way to do this? is there is any documentations for developers for creating RESTful API's using METATRADER? i want to get all the information's about a certain account, please help me on this, Thanks a lot!

MetaTrader can export trade history reports automatically via the FTP protocol: https://www.metatrader5.com/en/terminal/help/startworking/settings#ftp

However for a more sophisticated implementation, instead of trying to find a way of accessing MetaTrader data via REST API, invert the strategy.

Run a MQL5 Service on the MetaTrader 5 terminal, which monitors the trade history, and every time there is new data (or all of it on the first run), it "pushes" that data onto the website via a simple web-service. You can write the web-service in which ever way you want. You could have the data be pushed as JSON for example.

In this way, the MQL5 Service can be coded in pure MQL and only need to use the WebRequest function to push the data. There will be no need to create any intermediate steps or keep a separate a database on the MetaTrader side and keeps the CPU and RAM usage low.
 
Fernando Carreiro:

MetaTrader can export trade history reports automatically via the FTP protocol: https://www.metatrader5.com/en/terminal/help/startworking/settings#ftp

However for a more sophisticated implementation, instead of trying to find a way of accessing MetaTrader data via REST API, invert the strategy.

Run a MQL5 Service on the MetaTrader 5 terminal, which monitors the trade history, and every time there is new data (or all of it on the first run), it "pushes" that data onto the website via a simple web-service. You can write the web-service in which ever way you want. You could have the data be pushed as JSON for example.

In this way, the MQL5 Service can be coded in pure MQL and only need to use the WebRequest function to push the data. There will be no need to create any intermediate steps or keep a separate a database on the MetaTrader side and keeps the CPU and RAM usage low.

Thats a good idea to go about it. - Doing POSTs on a receiving web service. I did not think about that... And it is quite secure.

 
Fernando Carreiro #:

MetaTrader can export trade history reports automatically via the FTP protocol: https://www.metatrader5.com/en/terminal/help/startworking/settings#ftp

However for a more sophisticated implementation, instead of trying to find a way of accessing MetaTrader data via REST API, invert the strategy.

Run a MQL5 Service on the MetaTrader 5 terminal, which monitors the trade history, and every time there is new data (or all of it on the first run), it "pushes" that data onto the website via a simple web-service. You can write the web-service in which ever way you want. You could have the data be pushed as JSON for example.

In this way, the MQL5 Service can be coded in pure MQL and only need to use the WebRequest function to push the data. There will be no need to create any intermediate steps or keep a separate a database on the MetaTrader side and keeps the CPU and RAM usage low.

interesting, Can I get a guide on how to do this?

Reason: