Correct way of unloading objects/functions to avoid connection issue

IBPlugin is further development of TWSLink.It is focused for the useage with MetaTrader. But as it is a DLL, you can use it everywhere on Windows which supports DLL, e.g. in Trade Station or C++ applications or make wrapper for Perl, Python etc.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
hkenrique
Posts: 28
Joined: Tue Jul 28, 2020 3:23 pm

Correct way of unloading objects/functions to avoid connection issue

Post 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.

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

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

Post 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
Attachments
ibplugin_test1.zip
(1.1 KiB) Downloaded 482 times

hkenrique
Posts: 28
Joined: Tue Jul 28, 2020 3:23 pm

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

Post by hkenrique »

Thanks. This does not seem to happen recently.

Post Reply