ADL®

Loop Block

The Loop Block generates and outputs a user-specified number of empty discrete event messages, one after another, to facilitate designs which require loops.

  • The user must specify the total number of discrete event messages to be generated by the block.
  • When a discrete event message triggers the Loop Block, the block will update its output to "1" and then output its first discrete event message.
  • The Loop Block will increment its index by 1 and then generate its second discrete event message output. This step will repeat for the specified number of loop iterations.
  • After the last message is generated, the Loop Block generates and outputs another discrete event message to indicate that the loop sequence has been completed.

Note The Loop Block updates the counter before the actual message is generated and output.

Timing considerations

It is important to note that the Loop Block does not allow any "actor" block (i.e., a block that can take tangible actions such as placing an order) to take an action while it is performing the loop.

Example Using a Loop Block to decrement an order price.

In this example, the Loop Block is designed to loop up to three times, and at each iteration it decrements the price input of the Order Block by one price increment. At a glance, it might seem that the Order Block will generate three change requests to incrementally move its child orders down the market. However, the Loop Block does not allow the Order Block to take any actions during the loop. It is only after the loop has completed that the Order Block can take an action using the final resulting price input.

The following sequence of events occurs when this algorithm is started:

  1. The Order Block joins the best bid price with a 1-lot child order.
  2. The Generator Block generates and pushes a discrete event message downstream, triggering the Loop Block.
  3. The Loop Block loops up to three times, and at each iteration it decrements the price input of the Order Block by one price increment. However, the Order Block cannot take any action during this step.
  4. After the loop completes, the Order Block changes its child order based on the final resulting price input.

Block settings

To change default block settings, double-click the block to open the Block Editor.

Setting Description
Name Name to display beneath the block on the ADL canvas
BodyColor Background color of the block
Description Optional text to explain how the block is used