How to set order type of a trading system programmatically
Updated on 2011-11-08 03:37:11
Order types can be specified in the "Update Trading System" form by updating the fields just above buy, sell, short and cover rules controls.
Buy using limit order at tomorrow (limit = close)
Here are the trading order types that are available in QuantShare:
Market at open
Market at close
Stop limit order
To change an order type using QL (QuantShare Language):
- Select "Create trading system using the formula editor" tab
- Type the next lines to associate a limit order to buy signals
SetSimTiming(_Buy, _Limit, 0);
BuyPrice(close * 0.99, 10);
The "SetSimTiming" function allows you to specify an order type to associate with a signal type. Here, we associate limit order type to buy signals. We set "0" in the third parameter to indicate that we want to execute the order tomorrow (signal date + 1).
The "BuyPrice" function allows you to specify the limit or/and stop price of an order. Here, we indicate that the limit price is 1% below the close price and that the order is valid for 10 days only. After this period, the order is automatically removed.
To get the list of available fields in a parameter, click on this parameter then use the CONTROL+SPACE shortcut.