Envelope around a moving average - FXB.ta.Envelope

The FXB.ta.Envelope class calculates the "envelope" around a moving average: the average plus/minus a fixed percentage. It is a value-based calculation, and can be applied to any series of values including the output of another FXB.ta calculation. Parameters are as follows:

Parameter

Description

period

Rolling period for the calculation

bandPercent

Fixed percentage for the plus/minus envelope (defaults to 0.1 - in other words, addition/subtraction of the moving average x 0.001)

maType

Type of moving average. Defaults to a simple moving average (sma / 0).

The primary output value - GetValue() - of the calculation is the moving average. The calculation also sets the signal value - GetSignalValue() - to the size of the envelope: each moving average multiplied by the bandPercent divided by 100. And the calculation provides some helper functions for getting the upper and lower bands:

Parameter

Description

GetUpper(idx)

Gets the upper band at index #idx: the main value plus the deviations parameter times the signal value

GetLower(idx)

Gets the lower band at index #idx: the main value minus the deviations parameter times the signal value

GetUpperArray()

Returns an array of all upper-band values

GetLowerArray()

Returns an array of all lower-band values