SubmitOrderUnmanaged()

View as Markdown

Definition

Generates an Unmanaged order.

Method Return Value

An Order read-only object that represents the order. Reserved for experienced programmers, additional information can be found within the Unmanaged Approach section.

Syntax

SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity)

SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice)

SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice)

SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string oco)

SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string oco, string signalName)

Parameters

ParameterDescription
selectedBarsInProgressThe index of the Bars object the order is to be submitted against. This determines what instrument the order is submitted for. Note: See the BarsInProgress property.
orderActionDetermines if the order is a buy or sell order. Possible values:
OrderAction.Buy
OrderAction.BuyToCover
OrderAction.Sell
OrderAction.SellShort
orderTypeDetermines the type of order submitted

Possible values:

  • OrderType.Limit
  • OrderType.Market
  • OrderType.MIT
  • OrderType.StopMarket
  • OrderType.StopLimit
ParameterDescription
quantitySets the number of contracts to submit with the order
limitPriceOrder limit price. Use “0” should this parameter be irrelevant for the OrderType being submitted.
stopPriceOrder stop price. Use “0” should this parameter be irrelevant for the OrderType being submitted.
ocoA string representing the OCO ID used to link OCO orders together

Note: OCO strings should not be reused. Use unique strings for each OCO group, and reset after orders in that group are filled/canceled

ParameterDescription
signalNameA string representing the name of the order. Max 50 characters.

Examples

1private Order entryOrder = null;
2protected override void OnBarUpdate()
3{
4 // Entry condition
5 if (Close[0] > SMA(20)[0] && entryOrder == null)
6 SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "Enter Long");
7}
8protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
9{
10 // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
11 // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
12 if (order.Name == "Enter Long" && orderState == OrderState.Filled)
13 entryOrder = order;
14}