Main Content


Obtain next valid order identification number



id = orderid(ib) obtains the next valid order identification number for Interactive Brokers® connection ib.


collapse all

Create an IB Trader Workstation℠ connection on the local machine using port number 7496.

ib = ibtws('',7496);

Obtain the next valid order identification number using ib.

id = orderid(ib)
id =


id contains the next valid order identification number. To create an order, use this number in createOrder.

Close the IB Trader Workstation℠ connection.


Input Arguments

collapse all

IB Trader Workstation connection, specified as an IB Trader Workstation connection object created using ibtws.

Output Arguments

collapse all

Next valid order identification number, returned as a numeric scalar.


If the variable ibBuiltInErrMsg appears in the MATLAB® workspace, check the status of the connection and function execution by displaying the contents of this variable. ibBuiltInErrMsg contains messages related to:

  • Connection

  • Information resulting from executing functions

  • Errors

Introduced in R2015a