Page 1 of 1

Correct way of unloading objects/functions to avoid connection issue

Posted: Fri Jan 22, 2021 2:22 pm
by hkenrique
Hello sir,

Following the issue below that I believed to be the license issue:
It seems restart of MT may result in such connection issues. I then need to restart my TWS to resolve this.

I was told in email that it could be caused by unproper unload of the object/connections. But I did not experience the same issue in the old version.

Could you instruct how I should write my unload function to prevent such issue?

My current code:

Code: Select all

 
 __ib.disconnect();
   deinit_ib_trader;
 
Thanks.

Re: Correct way of unloading objects/functions to avoid connection issue

Posted: Fri Jan 22, 2021 3:29 pm
by board_admin
Usually there is no need to call
disconnect
at all. The plugin keeps connection and if you should change connection parameters,
just call connect again with new parametes.

Also deinit is not really required.


What happens if you skip both: disconnect ant deinit ?


I recommend to drop the wrapper and to use DLL functions directly.

I made a test with 10 times connect and disconnect on 3 symbols, then close MT reopen MT and this 3 times.
No issues, if i call deinit in OnDeinit or not.


Find the script attached. This should work also smooth on your side.
It is for MT4 but should compile on MT5 as well.


What TWS version do you have ?

Best use always time tested version, because we use it for test also.
https://www.interactivebrokers.eu/de/index.php?f=16876

Re: Correct way of unloading objects/functions to avoid connection issue

Posted: Mon Feb 01, 2021 2:06 am
by hkenrique
Thanks. This does not seem to happen recently.