Receive requests infinitely in EA

 
Hi, I am making an EA that communicates with a C# application using sockets (w/ the help of ZeroMQ), I am using a publisher socket to publish the candle data on each new candle, which is working fine. However, I would like to also, have a response socket that is constantly waiting to receive requests (from the C# app) and respond to the request. I was thinking on something like while(true) { responseSocket.recv() ... } but as this will block the strategy tester. What would be a good solution? Thanks!
 
Suraj Rohira:
Hi, I am making an EA that communicates with a C# application using sockets (w/ the help of ZeroMQ), I am using a publisher socket to publish the candle data on each new candle, which is working fine. However, I would like to also, have a response socket that is constantly waiting to receive requests (from the C# app) and respond to the request. I was thinking on something like while(true) { responseSocket.recv() ... } but as this will block the strategy tester. What would be a good solution? Thanks!
Your only option is non-blocking polling of the socket on some sort of repeating timer.
 
kdufgh #:
... only ...

Outside the strategy tester, the following approach is theoretically possible:

  • Two EAs: main EA, and a slave network worker
  • The slave EA uses blocking calls to receive data immediately
  • On receipt of data, it notifies the main EA via EventChartCustom().

But that is indescribably horrible in itself, and isn't applicable if, as you say, you want to do this in the strategy tester.

 
kdufgh #:
... only ...

Given that you are already using C#, there are other options involving DLLs, but again they're restricted if you need to be able to use them in the strategy tester. The key problem which the strategy tester creates is blocking off the routes which allow lower latency than the repeated non-blocking polling of the socket.  

Reason: