Can Fill Order Script

Top  Previous  Next

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

 

Example

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

 ENDIF

 

 IF instrument.IsStock THEN

         newMarginValue = order.Quantity * instrument.close * instrument.conversionRate * instrument.stockSplitRatio

 ENDIF

 

 IF test.totalMargin + newMarginValue > test.totalEquity THEN

         order.Reject( "Over the margin limit" )

 ENDIF

 

 

ENDIF