VWMA
Source
https://github.com/quadcode-tech/quadcodescript-library/blob/master/averages/ma_vwma.lua
Syntax Format
vwma(series, period)
Overview
VWMA
(Volume Weighted Moving Average) indicates not only the price values but volume values as well. Moreover, the price values during high volume are given more weight in the Moving Average calculation.
Parameters
Parameter | Type | Purpose |
---|---|---|
source | series | Input series, taken into calculation |
period | numeric | Moving Average period |
Returns: series
.
Example
instrument { name = "Volume Weighted Moving Average", short_name = "VWMA", overlay = true, icon="indicators:MA" }
period = input (20, "period", input.integer, 1)
source = input (1, "source", input.string_selection, inputs.titles_overlay)
input_group {
"VWMA Line",
color = input { default = "#FF6C58", type = input.color },
width = input { default = 1, type = input.line_width}
}
local sourceSeries = inputs [source]
plot (vwma (sourceSeries, period), "VWMA", color, width)
Formula
The formula for calculating VWMA
is:
The sum of the chosen price series and the volume value are divided by the volume values, assigned to different weight.