ADL®

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.

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 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
MovingAvg Formula

Equation used to calculate the value of the block

If not yet defined, the field displays a Click to edit formula link that opens the Formula Builder.

Description Optional text to explain how the block is used