AddOrder ( int type , IDataHolder condition , IDataHolder price , IDataHolder tradeSize , CustomColor tickColor , CustomColor arrowColor , String name );
Default values:
type: OrderType.BUY_AUTO
price: open[-1]
tradeSize: specified by strategy settings
tickColor: Color.MAGENTA
arrowColor: Color.MAGENTA
name: "<strategy name>"
Description
Adds an order of specified side and position effect for the next bar when the condition is true.
Input parameters
Parameter | Default value | Description |
---|---|---|
type | OrderType.BUY_AUTO | Defines order side and position effect using the OrderType constants. |
condition | - | Defines condition upon which the order is added. |
price | open[-1] | Defines price at which the order is added. |
tradeSize | - |
Defines the number of contracts traded. Note that this value overrides the trade size specified in Strategy Global Settings. |
tickColor | Color.MAGENTA | Defines the color of tick marking the trade price. |
arrowColor | Color.MAGENTA | Defines the color of signal arrow. |
name | strategy name | Defines the order name which will be displayed on "Orders" tabs in strategy settings, in strategy report, and as captions to the Buy/Sell signal arrows on chart. By default, all orders use the same name as the strategy itself. |
Example
AddOrder(OrderType.BUY_AUTO, close > close[1], open[-1], 50, Color.ORANGE, Color.ORANGE, "Sample buy @ " + open[-1]);
If the current Close price is higher than the previous, the code opens the long position or closes the short one at the Open price of the next bar. The trade size will be equal to 50, signals will be colored orange, and each signal will display the buying price.