A single order can be submitted using the SubmitNewOrder method on the AccountList object:
' Reference to a submitted order.
Private WithEventsAs Order
…
' Get an account to submit the order for.
Dim oAccount As Account = moAccounts(0)
' Get a market to submit the order in.
Dim oMarket As Market = moFilter(0)
' Submit an order.
moOrder = moAccounts.SubmitNewOrder( _
oAccount, _
oMarket, _
BuySell.Buy, _
PriceType.Market, _
TimeType.Normal, _
1, _
0)
The parameters for the SubmitNewOrder method are described
here.
The method returns the new order object. That object contains the details of the order, including its UniqueID and all updates to the order will be made to that order object.
To revise an order use the Revise method on the Order object:
' Check to see if the order is working.
If moOrder.IsWorking Then
' Revise the order.
moOrder.ReviseTicks(2, moOrder.CurrentLimitTicks)
End If
The parameters for the Revise method are described
here.
If you need to revise the account for an order then you must pull the order and submit a new order in the correct account.
To pull an order use the Pull method on the order object:
' Check to see if the order is working.
If moOrder.IsWorking Then
' Pull the order.
moOrder.Pull()
End If
Changes to the orders are raised as events from the Order object itself, as well as from the Position object, Account and AccountList objects. The
OrderUpdate event occurs whenever the order has been updated, for example following submission, revision, pulling and fills:
' Event raised when the order has been updated.
Private Sub moOrder_OrderUpdate(ByVal poOrder As T4.API.Order) Handles moOrder.OrderUpdate
' Display some of the detais.
Trace.WriteLine("OrderUpdate: " & poOrder.UniqueID & _
", Status: " & poOrder.Status.ToString & ", " & _
poOrder.StatusDetail & ", Change: " & _
poOrder.Change.ToString)
End Sub
When an order gets a fill then the
OrderFill event is raised. This occurs once only per fill:
' Event raised when the order has received a fill.
Private Sub moOrder_OrderFill(ByVal poOrder As T4.API.Order, ByVal poTrade As T4.API.Order.Trade) Handles moOrder.OrderFill
' Display some of the fill details.
Trace.WriteLine("OrderUpdate: " & poOrder.UniqueID & _
", Fill: " & poTrade.Volume & "@" & _
poOrder.Market.ConvertTicksDisplay(poTrade.Ticks))
End Sub
The Order object properties are described
here.