There are 16 order filters, one of each type of order.
Here are the 8 corresponding to the position entry orders:
unsigned
int onBuyAtMarket( INDEX bar,
unsigned int shares ) const
|
And these are the 8 order filters corrsponding to the 8 position exit orders:
bool
onSellAtMarket( INDEX bar ) const
|
The user may choose to define any number of these, including none, in which case all orders will go through unchanged.
When one of the order functions is called and before the order is sumbitted, the corresponding order filter function is called. Depending on the value returned by the order filter, the order will be submitted unchanged, with a different size, or not submitted at all.
Order filters corresponding to position entry orders take the bar on which the order has been submitted and the number of shares of the original order. The return value is the new number of shares or 0 if the order is to be blocked. If the function is not defined in the user code, the default behavior is to return the same number of shares as the order, which will allow the order to be submitted unchanged. atLimit and atStop order filters also receive the original order price parameter.
Order filters corresponding to position exit orders are very similar with the exception that they do not receive the number of shares, and they return a boolean indicating whether to submit the position (if true) or not (if false). The default behavior, in case there is no corresponding user defined order filter is to allow the order to be submitted.
The purpose of these order filter functions is to separate the trading system position entry/exit logic from extra criteria that may be used to decide the position size and whether to submit trades or not, such as liquidity based criteria, or other.
© 2006-2010 Tradery.com
info@tradery.com