VIDYA
Source
https://github.com/quadcode-tech/quadcodescript-library/blob/master/averages/ma_vidya.lua
Syntax Format
vidya(source, period)
Overview
VIDYA
(Variable Index Dynamic Average) is one of the more complex averages, where several factors are considered. This function is called dynamic because it adjusts its data based on the current volatility of an asset. Also, the responsiveness of the VIDYA
is dynamic as well, as it is based on the CMO (Chande Momentum Oscillator)
.
Parameters
Parameter | Type | Purpose |
---|---|---|
source | series | Input series, taken into calculation |
period | numeric | Moving Average period |
Returns: series
.
Example
instrument { name = "Variable Index Dynamic Average", short_name = "VIDYA", overlay = true, icon="indicators:MA" }
period = input (9, "period", input.integer, 1)
source = input (1, "source", input.string_selection, inputs.titles_overlay)
input_group {
"VIDYA Line",
color = input { default = "#B42EFF", type = input.color },
width = input { default = 1, type = input.line_width}
}
local sourceSeries = inputs [source]
plot (vidya (sourceSeries, period), "VIDYA", color, width)
Formula
The formula for calculating VIDYA
is:
The CMO is used to determine the factor, which is based on volatility of the chosen price series and period. This factor is used to adjust the results to dynamically changing volatility value.