## Building Formulas

Many of the ADL blocks allow you to define formulas to calculate output values. The Formula Builder contains a canvas onto which you can drag-and-drop components of an equation, including:

• Logical operators
• Numerical operators
• Variables, including numbers, values of other ADL blocks, values of message fields, and values of input connectors
• Misc symbols to define the order of operations

Example Define a formula that compares a fill quantity with the quantity available at the Best Ask.

Note Based on the block type, some Formula Builders will provide or restrict components that do not pertain to the block functionality.

### Variable fields

The Formula Builder includes tiles that allow you to add values that update dynamically as the algo runs.

• : Lets you to enter a specific number.

• : Lets you reference the output of any other block in the algorithm.

• : Lets you extract any of the following information embedded within a discrete event message.

• limitPrice: Price of an new order
• orderQuantity: Total order quantity
• workingQuantity: Working quantity of an order
• fillPrice: Price of a fill
• fillQuantity: Quantity of a fill
• cumQuantity: Sum of fill quantities
• disclosedQuantity: Quantity of a disclosed order visible in the market
• deletedQuantity: Canceled quantity of a deleted order
• stopTrigger: Price at which the respective stop order is activated
• isQuotingOrder: Whether the message was generated by a submitted quote order (valid only for Autospreader order blocks)
• isHedgeOrder: Whether the message was generated by a submitted hedge order (valid only for Autospreader order blocks
• isExternalEvent: Whether the message was generated from a source outside of the algorithm
• isTriggered: Whether an order resulted from a trigger condition
• instrument: Instrument associated with the message
• userFieldN: One of four empty fields that can be populated by a Value Injector and then accessed by a Value Extractor
• : (Alert block only) Lets you add customized text to a message string.

### Blocks that use the Formula Builder

The following ADL blocks allow you to create custom formulas.

• Discrete blocks

• Misc blocks

### How to create a formula

To create a formula:

1. From an ADL block, open the Formula Builder.

2. Drag a field tile onto the canvas.

3. If necessary, select a value for the field and click OK.

The field updates with the selected value.

4. Drag another field tile onto the canvas, in this case the + operator.

Notice in this case, the canvas turns red after adding the operator. The red canvas indicates that the formula currently on the canvas is not valid.

5. Continue adding field tiles until the formula is complete. In this case, you add a Block Value field and select the Price Incr block to add one tick to the fill price.

6. When finished, click OK.