Streaming data from MT4

 

Hi,

I'm trying to stream tick data from the MT4 terminal to a postgres database, but I have a couple of questions that I would like to try to clarify first.


1. I'm considering on using ZMQ for this purpose. Have anyone tried this before? Is there a better alternative? I saw a post talking to how to connect to a mysql database. Is this replicable to a Postgres database?


2. Is it possible to get tick data directly from the market watch? Like, monitoring events in the market watch. I think it's not possible, because an EA that even looks to the market watch would be triggered by a tick on the corresponding chart. Eg: if I have attached an EA to the EURUSD, then it will be the EURUSD's ticks that will trigger the EA and not the EURGBP (or whatever other instrument present in the marketwatch). Is this correct?

 

Hello you can omit the onTick() function and use the OnTimer() in stead.

Then you can specify the symbol in the calls.

Here is an example: https://www.mql5.com/en/docs/series/copyticks

Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
  • www.mql5.com
CopyTicks - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Marco vd Heijden:

Hello you can omit the onTick() function and use the OnTimer() in stead.

Then you can specify the symbol in the calls.

Here is an example: https://www.mql5.com/en/docs/series/copyticks

Wow, thank you! Absolutely going to take a look at this :)

Btw, the OnTimer() isn't triggered by ticks of the chart the EA is attached, but by some time rule, right? For example, it can be called every 1000 ms using the EventSetMillisecondTimer() function, right?

Using this would retrieve every selected symbol's bid/ask using the CopyTicks(), but this would not necessarily mean that a tick happened, unless COPY_TICKS_INFO flag is used. I am correct?

Oh, and btw...which alternative do I have to CopyTicks() in MT4? I just noticed that CopyTicks() is available only for MT5 :(

Documentation on MQL5: Working with Events / EventSetMillisecondTimer
Documentation on MQL5: Working with Events / EventSetMillisecondTimer
  • www.mql5.com
EventSetMillisecondTimer - Working with Events - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: