Called as part of the fill process, the Can Fill Order script let's you determine by examining the trade day's price data, whether this order would be filled or not. This only gets called if Trading Blox has determined that this order should be filled based on a bar's price data. You can call order.Reject to override this determination. In addition, you can override the fill price, quantity, and stop in certain circumstances.
The entire order object is available properties and functions. See the Order object for more information.
If multiple Can Fill scripts are in a system, the order will be rejected if ANY Can Fill script rejects the order.
NOTE: The following order types CANNOT be canceled:
• Exit Orders placed by Trading Blox Builder to exit all open positions at the end of the test
• Entries or Exits placed for Actual Broker Positions
• Exit Orders placed automatically as a result of a reversal - i.e. the position is long and a new short entry order triggers
The following is a Can Fill Order script that checks for max margin.
IF order.IsEntry THEN
IF instrument.IsFuture THEN
newMarginValue = order.quantity * instrument.margin
IF instrument.IsStock THEN
newMarginValue = order.Quantity _
* instrument.close _
* instrument.conversionRate _
IF test.totalMargin + newMarginValue > test.totalEquity THEN
order.Reject( "Over the margin limit" )
This scripts section will not normally execute when a instrument date record is not available. A current record is a record date for the same date on which this script is executing. This means a test date must have an instrument date in order for this script to execute. When it does have a missing instrument record any orders that were active for the active test date will not be filled or expired by the brokerage process. However, when an order is still active after the brokerage process, it will be available to execute an order fill or allowed to expire on the next available instrument date trading session.
Edit Time: 5/10/2017 8:49:32 AM
Topic ID#: 185