Creating Orders:

All signals require an order to generate an instrument position.  Each order contains information about how the user intended the order to be executed, and in some cases protected.  All orders are generated by a Broker Object function.  These functions decide if the order is for entry or exit.  Entry orders create positions when an instrument's prices satisfies the order's conditions to enable a trade.  Exit orders will terminate, or exit a position when the conditions given to the order to exit are enabled in the market, or when the adjusted quantity remaining in a position is reduced to zero.


Once an Entry order is initiated by a Broker function order details are sent to the Unit Size script where the logic in that script can assign a quantity to the order.  All Trading Blox supplied money manager modules will, by design, reject orders that are sized with a quantity less than the instrument.roundLot property value.  Orders with zero quantity can be used to create positions, however without a quantity of at least at or above the instrument.roundLot value the math that is applied to the price change and trade expenses will be rounded to zero.  In order to generate zero quantity orders it will be necessary to modify the logic changes in the Unit Sizing script so a zero quantity order is not rejected.


Entry orders not rejected are then sent to the Can Add Unit script section where other rules and conditions can be applied to allow or reject the order.  Rejected orders will no longer exist after the Can Add Unit script terminates execution.  Orders that are not rejected will be accessible in the script where the Broker function created the order.  Orders rejected because an instrument's canTradeLong or canTradeShort properties are set to False will create a rejection record that will appear in the Filtered Log report.  Rejected orders by either of these two properties will not be accessible in the Unit Size or Can Add Unit script sections.


Exit orders can only be created when an instrument has an active position.  Exit orders do not get processed by the Unit Size or the Can Add Unit scripts.


All Entry and Exit orders that are not rejected before being tested on the next instrument's date are processed through the Can Fill Order script section.  In addition, all Entry orders are processed by the Entry Order Filled script section, and all Exit orders are processed by the Exit Order Filled script section.


Each order generated and enabled by the market is applied to either create a position, or is to be added to an existing existing position as an additional unit with be assigned its own unit identifying number.  If only one signal is applied, then only one unit is used as that instrument's position information.  Order for creating a new unit will show a unitNumber as zero.  Orders don't create units, but instead executed orders create units.  When an exit order is created, the unitNumber property will show a value of at least one for the first order.


All rejected orders are listed in the Trading Blox Filter Log file available under the Main menu's File -> Results -> Filtered Trades selection:

Filtered Trade Log Menu Access

Filtered Trade Log Menu Access

Order object information that is available can be accessed in any of the above order scripts using the Order Object "order" prefix.  An example is an Entry Orders script after a successful Broker function call finishes.   An example on how to know if the order was created successfully is shown in this next code example that is placed after the completing Broker function.



See Broker Object Examples





See Broker Object Examples



' Check if the Broker Object created an Order,...
If system.orderExists() THEN
  '  Apply Order Detail To Trade Information
  order.SetRuleLabel( sRuleLabel )
  '  Apply Order Details To Order Information
  order.SetOrderReportMessage( sRuleLabel )
ENDIF '  s.orderExists


Above code snippet example uses the System Object property orderExists() to discover when an order was successful created, or rejected. Use this property after the broker order execution returns to the script section where the broker object was executed.


before using the Order Object's functions to update the Positions & Orders Report and Trade Log record with the signal rule information that created the order.  Testing to be sure the order exist is critical for preventing errors.  To attempt to access an order that doesn't exist will cause Trading Blox to generate an error because the script is trying to assign information to an object that doesn't exist.



AlternateOrder Object, AlternateSystem Object, Order Functions, Order Object, Order Properties

See Also:

User's Guide Generating Orders


Edit Time: 5/29/2017 8:25:16 AM

Topic ID#: 240


Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software