Trading Strategy Scripts
Trading Strategy scripts are used for trading one symbol at a time such that each symbol gets its own strategy instance. Common use-cases include momentum strategies, crossover strategies and overbought / oversold strategies, all of which need to evaluate only a single symbol at a time in order to make trading decisions.
Setup
A Trading Strategy script can be set up from the Desktop Strategy Wizard when a new strategy is added to a Desktop.
Functions
Name |
Description |
This function is used for accepting the script parameters and for initializing the script prior to all other function calls. Once the script is assigned to a Desktop strategy, its parameter values can be specified by the user and can be selected for optimization. |
|
This function is called after each new bar of each symbol assigned to the Desktop strategy. It should evaluate the specified symbol and its new bar in order to determine whether to generate new orders for it. Never create indicators, signals or patterns from OnBarUpdate, for performance reasons those should be created from OnInitialize. |
|
This function is called for each new order fill. |
|
This function is called when an order is executed or cancelled. |
|
This function is called when a position is opened or closed. |
|
This function is called when a session is opened or closed. |
|
This function is called when a news update is received and only if the [NO_NEWS_UPDATES] comment is removed. |
|
This function is called when an RSS update is received and only if the [NO_RSS_UPDATES] comment is removed. |
|
This function is called when an alert update is received and only if the [NO_ALERT_UPDATES] comment is removed. |
|
This function is called when a journal update is received and only if the [NO_JOURNAL_UPDATES] comment is removed. |
|
This function is called when a data connection update is received and only if the [NO_DATA_CONNECTION_UPDATES] comment is removed. |
|
This function is called when a broker connection update is received and only if the [NO_BROKER_CONNECTION_UPDATES] comment is removed. |
|
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. Once the script is assigned to a Desktop strategy, its parameter values can be specified by the user and can be selected for optimization. |
OnBarUpdate(int symbolIndex, int dataSeries) |
|||||||||
This function is called after each new bar of each symbol assigned to the Desktop strategy. It should evaluate the specified symbol and its new bar in order to determine whether to generate new orders for it. Never create indicators, signals or patterns from OnBarUpdate, for performance reasons those should be created from OnInitialize. Parameters
|
OnOrderFillUpdate(int symbolIndex, int orderIndex, int orderFillIndex) |
||||||||||||
This function is called for each new order fill. Parameters
|
OnOrderUpdate(int symbolIndex, int orderIndex, C_Status status) |
||||||||||||
This function is called when an order is executed or cancelled. Parameters
|
OnPositionUpdate(int symbolIndex, int positionIndex, C_PositionStatus status) |
||||||||||||
This function is called when a position is opened or closed. Parameters
|
OnSessionUpdate(int symbolIndex, C_SessionStatus status) |
|||||||||
This function is called when a session is opened or closed. Parameters
|
OnNewsUpdate(int symbolIndex, long dateTime, string title, string message, C_MessageType type) |
||||||||||||||||||
This function is called when a news update is received and only if the [NO_NEWS_UPDATES] comment is removed. Parameters
|
OnRSSUpdate(int symbolIndex, long dateTime, string title, string message, C_MessageType type) |
||||||||||||||||||
This function is called when an RSS update is received and only if the [NO_RSS_UPDATES] comment is removed. Parameters
|
OnAlertUpdate(int symbolIndex, long dateTime, string message, C_MessageType type) |
|||||||||||||||
This function is called when an alert update is received and only if the [NO_ALERT_UPDATES] comment is removed. Parameters
|
OnJournalUpdate(int symbolIndex, long dateTime, string title, string message, C_MessageType type) |
||||||||||||||||||
This function is called when a journal update is received and only if the [NO_JOURNAL_UPDATES] comment is removed. Parameters
|
OnDataConnectionUpdate(int symbolIndex, long dateTime, string message, C_MessageType type) |
|||||||||||||||
This function is called when a data connection update is received and only if the [NO_DATA_CONNECTION_UPDATES] comment is removed. Parameters
|
OnBrokerConnectionUpdate(long dateTime, string message, C_MessageType type) |
||||||||||||
This function is called when a broker connection update is received and only if the [NO_BROKER_CONNECTION_UPDATES] comment is removed. Parameters
|
OnShutdown() |
This function is called when the script is shutdown. |