Trade Management Strategy scripts have multiple use-cases such as implementing position entry strategies, implementing position exit strategies and implementing advanced order management systems, among others.



Setup


A Trade Management Strategy script can be set up in the Trade Pad of a Standard Desktop and then triggered each time a new order is generated from it. This script type is not supported in a Strategy Desktop.


Functions


Name

Description

OnInitialize()

This function is used for accepting the script parameters and for initializing the script prior to all other function calls.

OnBarUpdate(int, int)

This function is called after each new bar belonging to the symbol that triggered the Trade Management Strategy. It can be used to evaluate the symbol and its new bar in order to submit, modify or cancel orders. The TradeManagementStart function must first be called in order for the platform to start calling this function.

OnEntryOrder(int, int)

This function is called once for the entry order that triggered the script. It's called before the order is submitted and can be used for setting attached orders and OCA groups.

OnShutdown()

This function is called when the script is shutdown.


Function Details


OnInitialize()

This function is used for accepting the script parameters and for initializing the script prior to all other function calls.


OnBarUpdate(int symbolIndex, int dataSeries)

This function is called after each new bar belonging to the symbol that triggered the Trade Management Strategy. It can be used to evaluate the symbol and its new bar in order to submit, modify or cancel orders. The TradeManagementStart function must first be called in order for the platform to start calling this function.


Parameters


Type

Identifier

Description

int

symbolIndex

The index of the symbol in the symbol table

int

dataSeries

The number indicating the data series from which the symbol was updated. 0 for the main data series which streams tick data, 1 for the second data series which streams minute bars that are updated on bar update. Use the DataSeriesSwitch function to switch between them.


OnEntryOrder(int symbolIndex, int orderIndex)

This function is called once for the entry order that triggered the script. It's called before the order is submitted and can be used for setting attached orders and OCA groups.


Parameters


Type

Identifier

Description

int

symbolIndex

The symbol index of the order that triggered the script

int

orderIndex

The order index that triggered the script


OnShutdown()

This function is called when the script is shutdown.