# Moving Average

**Definition**: A customized momentum indicator that measures the convergence/divergence of a short length trend line and long length trend line.

**Syntax**:

`macd(shortLength, longLength)`

**Arguments**

`shortLength`

: The number of previous values in calculating for short trend.`longLength`

: The number of previous values in calculating the long trend.

**Return**: Time series measuring convergence/divergence

**Description**: The Moving Average Convergence Divergence (MACD) is a popular technical indicator that measures the relationship between two moving averages of an asset's price. It is calculated by subtracting the 26-period exponential moving average (EMA) from the 12-period EMA. The MACD line can be used to identify trend changes, momentum, and potential buy and sell signals.

**Example**

macdValue = BTC.close -> macd(15, 30)

**Syntax**:

`adma(windowSize, longLength, shortLength)`

**Definition**: Calculates the adaptive moving average, which is a moving average that adjusts the smoothing factor based on market volatility.

**Arguments**:

`windowSize`

: The number of previous values to use in the calculation.`longLength`

: The number of previous values to use for the long trend line calculation.`shortLength`

: The number of previous values to use for the short trend line calculation.

**Return**: Time series of adaptive moving average values

**Description**: The Adaptive Average is a technical indicator that adjusts the smoothing factor of a moving average based on the volatility of the asset's price. It uses the Efficiency Ratio (ER) to calculate the optimal period for the moving average, which can help to reduce lag and improve accuracy in volatile markets. Traders can use the Adaptive Average to identify trend changes and potential buy and sell signals.

**Example**:

avgAdaptiveValue = BTC.close -> adma(10, 26, 12)

**Syntax**:

`sma(length)`

**Arguments**:

`length`

= the number of previous values used in the calculation**Return**: A time series of smoothed values

**Description**: Simple moving average (SMA) is a widely used technical indicator that calculates the average price of an asset over a specific time period. It is a lagging indicator, meaning it responds slowly to changes in price. Traders use SMAs to identify trends and potential buy and sell signals, with longer periods (e.g., 50-day SMA) used for long-term trends and shorter periods (e.g., 10-day SMA) used for short-term trends.

**Example**:

avgSimpleValue = BTC.close -> sma(30)

**Definition**: Moving average, where the most recent values are weighted more heavily than earlier values, with weights decreasing linearly.

**Syntax**:

`wma(length)`

**Arguments**:

`length`

= the number of previous values used in the calculation**Return**: A time series of smoothed values

**Description**: Linearly Weighted Moving Average (LWMA) is a technical indicator that assigns more weight to recent prices than past prices, giving it a greater responsiveness to current market conditions. It is calculated by multiplying each price point by a specific weight, with the weights increasing linearly over time. Traders use the LWMA to identify trends and potential buy and sell signals, with shorter periods (e.g., 5-day LWMA) used for short-term trends and longer periods (e.g., 50-day LWMA) used for long-term trends.

**Example**:

avgWeightedValue = BTC.close -> wma(20)

**Definition**: Moving average that applies more weight to the most recent values, with weights decreasing exponentially.

**Syntax**:

`ema(length)`

**Arguments**:

`length`

= weighting value used in the calculation**Return**: A time series of smoothed values

**Description**: The Exponential Moving Average (EMA) is a technical indicator that gives more weight to recent prices than past prices, making it more responsive to current market conditions than the Simple Moving Average (SMA). It is calculated by using a smoothing factor that emphasizes recent data points more heavily.

**Example**:

avgExponentialValue = BTC.close -> ema(20)

**Syntax**

`ema3x(fastLength, slowLength, innerLength)`

**Arguments**

`fastLength`

: the length of the exponential moving average with the shorter lookback`slowLength`

: the length of the exponential moving average with the longer lookback`innerLength`

: the length of the exponential moving average of the double exponential moving average

**Return**A time series of smoothed values

**Description**A technical indicator that uses a triple smoothing technique to reduce lag and improve accuracy. It is calculated by taking the difference between a single exponential moving average and a double exponential moving average, which is then added to the double exponential moving average.

**Example**

tripleXavgValue = BTC.close -> ema3x(10, 26, 12)

**Syntax**:

`hma(length)`

**Arguments**:

`length = the number of previous values used in the calculation`

**Return**: A time series of smoothed values

**Description**: Calculated as wavg(2*wavg(length/2) − wavg(length)), sqrt(length)).

**Example**:

hullValue = BTC.close -> hma(40)

**Definition**: Tilson moving average, also known as generalized double exponential moving average.

**Syntax**:

`tilson(length, volumeFactor)`

**Arguments**:

`length`

: the number of previous values used in the calculation`volumeFactor`

: relative weighting of exponential and double exponential components

**Return**: A time series of smoothed values

**Description**: Calculated as: ema(length)*(1+volumeFactor) - ema(ema(length),length)*volumeFactor

**Example**:

tilsonValue = BTC.close -> tilson(40, 0.7)

**Definition**: T3 moving average, from three applications of Tilson moving average.

**Syntax**:

`t3(length)`

**Arguments**:

`length`

= the number of previous values used in the calculation**Return**: A time series of smoothed values

**Description**: Calculated with three applications of Tilson, using volumeFactor of 0.7: tilson(tilson(tilson(length, 0.7), length, 0.7), length, 0.7)

**Example**:

t3Value = BTC.close -> t3(40)

**Definition**: Combines values from a list of input time series. The values from all inputs at each point in time are combined using a specified calculation.

**Syntax**:

`combineLists(combine)`

**Arguments**:

`combine`

- what calculation to use when combining values**Return**: Single time series of combined values from each point in time

**Description**: Supported combination methods are:

`avg`

,`mean`

- value is the average of values from inputs`max`

- value is the maximum of values from inputs`min`

- value is the minimum of values from inputs`sum`

- value is the sum of values from inputs

The default value is

`combine=”avg”`

.**Example**:

combined_values = [BTC, ETH, SOL].close -> combine_lists(combine=”max”)

Last modified 8d ago