Building your first algo

Building your first algo

Entering a position

The entry order portion of your algo will take the instrument defined by the instrument block, the Best Bid for the instrument and a defined quantity; then use these inputs to enter a buy order. This portion of your algo needs the following blocks:

  • An Order block configured to submit a Buy Limit order.
  • A Field block to set the order price to the Best Bid price of the instrument.
  • A Number block to set the order quantity.

Add-PIC

Adding the Order block

To place the Order block for the entry order:

  1. From the Blocks panel, click and drag the Order block for the Buy side order on to the ADL canvas.

    Once placed, the Order block will be highlighted to indicate that it is the currently selected block. In the Block Properties panel you can view and edit the poperties for the highlighted block.

    Note the messages in the Problems tab of the Information Panel indicating that the Order block you just placed is missing input connections. As you add more blocks and connect them to the Order block, these messages will disappear.

    Add pic

  2. In the Blocks Properties panel, specify the following properties.

    • Ensure the Type is Limit and the Side is Buy.
    • Optionally, specify "Entry Order" for the Name to make it easier to identify the block.

  3. To set the instrument for the entry order, connect the Instrument block to the the Order block by clicking and dragging the left mouse button from the Instrument block's output port to the Order block's inst input port.

Adding the Field block for the order price

Next, you need to specify the price of the entry order. This algo uses a Field block to extract the Best Bid price of the instrument. You can use the Search feature to simplify the process of locating and pre-populating blocks.

To place the Field block and make the necessary connections:

  1. From the Blocks panel Search field, type "bid".

    Notice how the list of blocks in the panel includes only those blocks whose names or properties that contain the string, "bid."

  2. From the Blocks panel, click and drag the Field (bidPrice) block for the Buy side order on to the ADL canvas.

  3. In the Blocks Properties panel, specify the following properties.

    • Notice that the Field Name drop-down is already selected based on the search you used.
    • Ensure that the Lookup Type is Best.
    • Optionally, specify "Best Bid" for the Name to make it easier to identify the block.

  4. Press and hold the Shift key to display dashed lines for suggested connections from the Instrument block to the Field block and from the Field block to the price port of the Order block.

  5. While pressing the Shift key, click the two dashed lines to make the connections.

Adding the Number block for the order quantity

Finally, your entry order needs an order quantity. The algo uses a Number block to set the order quantity to 1.

To place the Number block and make the necessary connections:

  1. From the Blocks panel Search field, type "1".

    Notice how the panel automatically shows a Number block with its value already set to 1.

  2. Click and drag the Number block on to the ADL canvas.

  3. In the Blocks Properties panel, specify the following properties.

    • Notice that the Value drop-down is already set to 1. based on the search you used.
    • Optionally, specify "Order Qty" for the Name to make it easier to identify the block.

  4. Press and hold the Shift key to display dashed lines for suggested connections from the Number block to the qty port of the Order block.

  5. While pressing the Shift key, click the dashed line to make the connection.

You have now have the entry order portion of your algo which will place a 1-lot order at the best bid for the instrument defined by the Instrument block. The next step is to define the exit order for your algo.