Discrete blocks

Discrete blocks

Moving Average block

The Moving Average block maintains an internal collection of numeric values (such as LTP) and outputs the average of the most recent user-specified number of values (#Bars). The block conceptually creates a new bar for a chart. Every time the block receives a message on its Intervals port, it performs the following actions:

  1. Updates its internal collection with the value calculated by the block's formula, based on values from the input discrete event message or the value of another block.
  2. Calculates the average of the #bars number of values and sends the value through its avg output port.
  3. Passes the original intervals message unchanged through its msg output port.

Example Calculate the moving average for the last-traded price (LTP)

Optionally, you can also configure the following ports:

  • ready: This port can be used to determine whether the block has collected sufficient number of bars to satisfy the [#bars] input. If the block does not have sufficient number of bars, the ready port will output False. When the block accumulates sufficient number of bars, the ready port will output TRUE.

  • reset: This port can be used to force the Moving Average block to delete its internal data collection and reset the Avg to a NaN (Not A Number) when a discrete event message triggers the reset port.

Block properties

To customize the block, update the Block Properties.

Property Description
Name Name to display beneath the block on the ADL canvas
MovingAvg Formula

Equation used to calculate the value of the block

The edit link opens the Formula Editor.