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);
You can see the return value is not in the error code list.Position close signal sent, uid:-721204922, checking if position is closed already
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.