Commands and Valid Parameters
Previous Topic  Next Topic 

The following section is only relevant for the File, DLL and COM interfaces. All three interfaces share common interface functions/methods that take as arguments the parameters defined in the tables below. You can automate your trading through eight different commands. Command definitions are also provided below.


PARAMETERS

VALID VALUES

COMMAND

CANCEL, CANCELALLORDERS, CHANGE, CLOSEPOSITION, CLOSESTRATEGY, FLATTENEVERYTHING, PLACE, REVERSEPOSITION

ACCOUNT

The name of the account the command is to be processed

INSTRUMENT

Instrument name

ACTION

BUY, SELL

QTY

Any integer value

ORDER TYPE

MARKET, LIMIT, STOP, STOPLIMIT

LIMIT PRICE

Any decimal value (use decimals not commas 1212.25 for example)

STOP PRICE

Any decimal value

TIF

DAY, GTC

OCO ID

Any string value

ORDER ID

Any string value (must be unique for each line/file)

STRATEGY

Strategy template name (must exist in NinjaTrader)

STRATEGY ID

Any string value (must be unique for each line/file)



The following table displays required (R) and optional (O) values for each different command value.


COMMAND

ACCOUNT

INSTRUMENT

ACTION

QTY

ORDER TYPE

LIMIT PRICE

STOP PRICE

TIF

OCO ID

ORDER ID

STRATEGY

STRATEGY ID

CANCEL










R


O

CANCELALLORDERS













CHANGE




O


O

O



R


O

CLOSEPOSITION

R

R











CLOSESTRATEGY












R

FLATTENEVERYTHING













PLACE

R

R

R

R

R

O

O

R

O

O

O

O

REVERSEPOSITION

R

R

R

R

R

O

O

R

O

O

O

O



Folllowing are descriptions of each available command.


CANCEL COMMAND

This command will cancel an order and requires an order id value and an optional strategy id value. The order id value must match either the order id value given to an order placed through the PLACE command or, an order name such as ENTRY*, EXIT*, STOP*, SIMSTOP* or TARGET*. The star (*) represents an integer value such as TARGET1 or TARGET2. Order names are only valid if a valid strategy id value is passed. The strategy id value must match a strategy id value given to a strategy in the PLACE command.



CANCELALLORDERS COMMAND
This command will cancel all active orders across all accounts and broker connections.



CHANGE COMMAND

This command will change the parameters of an order and requires an order id value, optional price and quantity values and an optional strategy id value. The order id value must match either the order id value given to an order placed through the PLACE command or, an order name such as ENTRY*, EXIT*, STOP*, SIMSTOP* or TARGET*. The star (*) represents an integer value such as TARGET1 or TARGET2. Order names are only valid if a valid strategy id value is passed. Pass in zero (0) values for price and quantity if you do not wish to change these order parameters. Price values must be in US decimal format. 1212.25 is correct while 1212,25 is not. 



CLOSEPOSITION COMMAND

This command will close a position and requires an account name value and an instrument name value. The instrument name value is the name of the NinjaTrader instrument including the exchange name. For equities, the symbol is sufficient. This command will cancel any working orders and flatten the position.



CLOSESTRATEGY COMMAND

This command will close a strategy and requires a strategy id value. The strategy id value must match a strategy id given to a strategy in the PLACE command. This command will close the specified strategy.



FLATTENEVERYTHING COMMAND

This command will cancel all active orders and flatten all positions across all accounts and broker connections.



PLACE COMMAND

This command will place orders, place orders that initiate a NinjaTrader position strategy or place orders that are applied to an active NinjaTrader position strategy. Providing the optional strategy name field with a valid strategy template name will result in execution of that strategy once the order is partially or completely filled. Pass in an optional unique string value for the strategy id in order to reference that strategy via other commands. To apply an order to an active strategy (existing strategies stop loss and target orders are amended) pass in the active strategy id value and leave the strategy name field blank. Pass in an optional unique string value for the order id in order to reference that order via other commands. If specifying a strategy template name, there is no need to pass in an order id as the strategy based orders can be referenced by their internally generated names such as TARGET1, STOP1 and so on.



REVERSEPOSITION COMMAND

This command will reverse the current position and place an order in the opposite direction. The field requirements are identical to the PLACE commmand.