Negative UID but successful action when sending order

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

Negative UID but successful action when sending order

Post by hkenrique »

Hi,

It appears that the return value of order send function sometimes can be negative but successful.

Code: Select all

	long uid= __ib.order_send(__conid_EURUSD
            ,orderType // defined in file include/trade-commander.com/ibplugin_types.mqh                    
             ,size
             ,0
             ,targetPrice
             ,0
             ,0
             ,IntegerToString(magicNumber)+","+IntegerToString(posOpen)+"C"
             ,0
             ,0);
       PrintFormat("Position close signal sent, uid:%d, checking if position is closed already",uid);
       
Log reads:
Position close signal sent, uid:-721204922, checking if position is closed already
You can see the return value is not in the error code list.
Can this be another defect of the ibgORDER_SEND function?
I found this issue during my test, where I close my position twice and result in duplicate positions.
Debugging shows the code thinks the position close action failed and closed again where it actually succeeded and I can see two identical trades in IB.

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

Re: Negative UID but successful action when sending order

Post by board_admin »

In a prior version negative uids where possible to use full range of integer 64 bit.
In latest version 1503 (and i believe version before 1502) uid should always be positive. Microseconds since 2010.

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

Re: Negative UID but successful action when sending order

Post by hkenrique »

I am not sure how to check the version number of the plugin?

Post Reply