Search code examples
c#metatrader4mt4

Custom data sources, how to fill the market data into the MT4 server?


I have custom data sources, but I do not know how to fill the market data into the MT4 server.

So how do I insert new market data to MetaTrader 4 server?

I got the DataReed API (read function) in the document, but in my mind it's used for MT4 to read market data from us.

Is it "MetaTrader 4" -> "API" -> "Server API" -> "Price Data" -> "HistoryAddTick"?

But this is history data - I want real-time data.


Solution

  • I was using two different approaches for similar task:

    1. You can simulate MQ Data Feeder, for this you will need to understand protocol which is used. It's not complicated, but there is no documentation.

    2. You can use manager API to send ticks to server, method name: SymbolSendTick. Manager API provided as c++ dll with headers. But since you marked your question with C# tag, I assume that you want to do it via .NET. So you might want to use managed wrapper. It will look like:

      using (var metatrader = new ClrWrapper(new ConnectionParameters
          {
              Login = 123456,
              Password = "managerPassword",
              Server = "123.123.123.123:443"
          }))
      {
          metatrader.SymbolSendTick("#SYMBOL", 1.5, 2.3);
      }