The If Then block outputs one of two values, based on the value of a Boolean input. When the input value is TRUE, the block outputs a value based on the block's ThenValue condition. When the input value is false, the block outputs a value based on the block's ElseValue condition.
Like the Equal block, the If Then block uses yellow variable input ports, which allow you to specify different types of data (numeric, Boolean, or instrument). Because both inputs must be the same type of data, the block automatically sets the data type for the second input port as soon as you connect the other port. Also, the output port dynamically adjusts to match the data type of the input ports.
The following examples uses an If Then block to determine a quantity to use when submitting an order. The If Then block checks the current Bid quantity for the ES Sep16 instrument. If the bid quantity is greater than 50, the If Then block outputs 10 to the Order block's Quantity port. Otherwise, it outputs 5.
Example Use an If Then block to determine order quantity dynamically
You can link multiple If Then blocks together to define nested if-then statements as shown in the following example. To find the correct output of nested If Then blocks, always start with the right-most If Then block and trace the logical pathway to the left until arriving at an output.
Example Using nested If Then blocks
To customize the block, update the Block Properties.
|Name||Name to display beneath the block on the ADL canvas|