> For the complete documentation index, see [llms.txt](https://help.signals.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.signals.network/knowledge-base/indicators/trend-analysis/volume-weighted-moving-average-vwma.md).

# Volume-weighted Moving Average (VWMA)

VMWA is a Moving Average indicator which includes data from Volume in its calculation. This indicator places more importance on the closing prices which had a higher volume.

**Trading application**\
It is possible to interpret VWMA in a similar manner to other Moving Averages. Its main use, however, arises when it is used in conjunction with a SMA. A WMVA moving below an SMA indicates bearish conditions, while a WMVA moving above an SMA indicates bullish conditions. Seeing a WMVA moving between the price chart and the SMA indicates there will be a trending market. Both lines growing closer together might also suggest an exit point.

### **Calculation**

$$
VWMA (3) = \[(P(1)\*V(1)+ P(2)\*V(2) + P(3)\*V(3)] / \[(V(1)+ V(2)+ V(3))]
$$

*P(n): Closing price from n period*\
*V(n) = Volume from n period*

{% hint style="info" %}
The above calculation was limited to the 3 most recent periods as a matter of simplicity
{% endhint %}

### **Parameters**

#### Input Parameters

| Name       | Type         | Range of value    | Description                             |
| ---------- | ------------ | ----------------- | --------------------------------------- |
| `period`   | int          | <1, int.MaxValue> | Number of bars used in the calculation. |
| `barValue` | BarValueType |                   |                                         |

#### Output Parameters

Indicator ouptuts a single value.

| Type   | Range of value       |
| ------ | -------------------- |
| double | (0, double.MaxValue) |

### Examples

```csharp
// Prints the current value of a 20 period VWMA using
// the daily bars close price value.
vwma = indicators.VWMA(20, BarValueType.Volume).OnSeries(dailyBars);
Log("The current VWMA value is " + vwma.Value.ToString());

// Prints the previous value of VWMA.
vwma = indicators.VWMA(20, BarValueType.Volume).Keep(2).OnSeries(dailyBars);
Log("The previous VWMA value is " + vwma.Values[1].ToString());
```

#### Complete example

```csharp
using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.VWMA;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBars;
    private VWMA vwma;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
        vwma = indicators.VWMA(20, BarValueType.Volume).Keep(2).OnSeries(dailyBars);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBars).Do(() =>
        {   
            // Prints the current VWMA value
            Log("The current VWMA value is " + vwma.Value.ToString());

            // Prints the previour VWMA value
            Log("The previous VWMA value is " + vwma.Values[1].ToString());
        });
    }
}
```
