Kinzel / mt5R

Easy integration between R and MT5 using socket connection, tailored to fit Machine Learning users and traders needs
https://kinzel.github.io/mt5R
GNU General Public License v2.0
34 stars 11 forks source link

Server socket no created #21

Open Camilo-Mora opened 1 year ago

Camilo-Mora commented 1 year ago

I have had this issue before, and cannot recall how to fix so it will be good to leave a trial for the future. Basically, I have not been able to create a socket connection. I get this error in R, after the function Ping MT5.Ping() Error in base::socketConnection(host = "localhost", port = iPort, blocking = TRUE, : cannot open the connection In addition: Warning message: In base::socketConnection(host = "localhost", port = iPort, blocking = TRUE, : localhost:23456 cannot be opened [1] FALSE

Do you know how to fix it?

Camilo-Mora commented 1 year ago

This problem appears to be in MT5 when having more than two accounts set. I presume there is only one channel of communication between R and MT5. What worked in my case was :

  1. Remove the expert from MT5. It seems it gets stuck in the socket of the original account. For this, right click on the chart where the expert was loaded, click on "Experts List", select the MT5R expert and click "remove". Alternatively, delete the expert from the "Navigator" tab, and load it again.
  2. Log in into the trading account you want to use (In the Navigator tab).
  3. Right click on the MT5R expert (In the Navigator tab), and attach to chart.
  4. You may need to reboot MT5 .

This is an amazing package, but there is very little information on how to deal with different scenarios (like how to use when more than two accounts are active in MT5).

Valdsonmaia commented 1 year ago

Boa noite, Estou tendo um problema, será que poderia me ajudar. Consigo conectar mas logo desconecta e aparece essa msg: Error in if (server_resp == "") return(NULL) : argument is of length zero.