MT4/5 data to a postgres db

 

Hi all, 

I would like to set up a process that syncs the MT4/5 server data to a postgres db. I would like for it to be live and run continuously to sync the two dbs. 

Can someone point me to the right approach and choice of tools required?


Thank you.

 

Well, its for mysql, but should give you an idea on how to go about it...

EDIT:


I just noticed, you will need the MQLplus error library from code base...

I have attached the current version and here is the link to the published version:

https://www.mql5.com/en/code/32083;

Or you remove the corresponding error handling functions from the file lib_mysql.mqh.

MQL Plus Enhanced Error Handler Support
MQL Plus Enhanced Error Handler Support
  • www.mql5.com
An (optional) include file to enhance error code handling experience.
Files:
 

Thank you!

Hopefully i can make it work with PostgreSQL as well.

Dominik Egert #:

Well, its for mysql, but should give you an idea on how to go about it...

EDIT:


I just noticed, you will need the MQLplus error library from code base...

I have attached the current version and here is the link to the published version:

https://www.mql5.com/en/code/32083;

Or you remove the corresponding error handling functions from the file lib_mysql.mqh.

 
Share if you succeed.


 
Dominik Christian Egert #:
Share if you succeed.



Could you, please, share with us hints or how-to (setup) about PostgreSQL database access of your application? I would like to store some EA data on PostgreSQL.

Thanks,

 
See my post #1, it's for MySQL. The integration of PostgreSQL is similar.

You'll need to adapt it on your own.
 
Dominik Christian Egert #:
See my post #1, it's for MySQL. The integration of PostgreSQL is similar.

You'll need to adapt it on your own.
Hi! Can you please share a tutorial or something to help for building a file like pgsql.mqh or  libpq.mqh for database connection with postgresql with mt4 
 
Daniela Orellana #:
Hi! Can you please share a tutorial or something to help for building a file like pgsql.mqh or  libpq.mqh for database connection with postgresql with mt4 
Sorry, but you will have to adapt it yourself. I never did it up to today and currently I have no plans to do so.

But it is not very hard, in fact, if you take a close look it's just changing the client DLL and adapting the function calls accordingly. Maybe you would want error messages as well, then you need to adapt the error messages, Copy/paste work....


 
Daniela Orellana #:
Hi! Can you please share a tutorial or something to help for building a file like pgsql.mqh or  libpq.mqh for database connection with postgresql with mt4 

I couple of weeks ago I took some notes about MQL5 and Postgres connection.

https://www.mql5.com/en/articles/12308

Depending on your needs, it may be of some help.

How to connect MetaTrader 5 to PostgreSQL
How to connect MetaTrader 5 to PostgreSQL
  • www.mql5.com
This article describes four methods for connecting MQL5 code to a Postgres database and provides a step-by-step tutorial for setting up a development environment for one of them, a REST API, using the Windows Subsystem For Linux (WSL). A demo app for the API is provided along with the corresponding MQL5 code to insert data and query the respective tables, as well as a demo Expert Advisor to consume this data.