0% found this document useful (0 votes)
417 views5 pages

Volumatic VIDYA Indicator Script

The document is a Pine Script code for a trading indicator called the Volumatic Variable Index Dynamic Average (VIDYA). It includes input parameters for length, momentum, and source data, along with functions to calculate the VIDYA, detect trends, and plot liquidity levels. The script also visualizes trend changes and displays volume statistics on the chart.

Uploaded by

sarwarcryp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
417 views5 pages

Volumatic VIDYA Indicator Script

The document is a Pine Script code for a trading indicator called the Volumatic Variable Index Dynamic Average (VIDYA). It includes input parameters for length, momentum, and source data, along with functions to calculate the VIDYA, detect trends, and plot liquidity levels. The script also visualizes trend changes and displays volume statistics on the chart.

Uploaded by

sarwarcryp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//@version=5

indicator("Volumatic Variable Index Dynamic Average [BigBeluga]", "Volumatic VIDYA


[BigBeluga]",
overlay = true, max_lines_count = 500, max_labels_count = 500)

// INPUTS
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
――――――――――――――――――――――{
// Input parameters for length, momentum, and source data
int vidya_length = [Link](10, "VIDYA Length") // Length of the VIDYA
calculation
int vidya_momentum = [Link](20, "VIDYA Momentum") // Momentum length for
VIDYA
float band_distance = [Link](2, "Distance factor for upper/lower bands", step
= 0.1) // Distance factor for upper/lower bands
// Define pivot parameters
int pivot_left_bars = 3 // Left side
pivot bars
int pivot_right_bars = pivot_left_bars // Right side
pivot bars

float source = [Link](close, "Source") // Source for VIDYA


calculation

// Define colors for up and down trends


color up_trend_color = input(#17dfad, "+", group = "Color", inline = "c") //
Color for uptrend
color down_trend_color = input(#dd326b, "-", group = "Color", inline = "c") //
Color for downtrend
bool shadow = [Link](true, "Shadow", group = "Color", inline = "c")

// Initialize variables for line, volume, and trend state


var line pivot_line = na // Variable for storing line references
var float volume_value = na // Variable for storing volume data
float smoothed_value = na // Smoothing variable for VIDYA trend levels
var bool is_trend_up = na // Boolean variable for tracking trend direction

// Initialize arrays for storing line and volume information


var array<line> liquidity_lines_low = [Link]<line>(500) // Array for storing
lines for lows
var array<line> liquidity_lines_high = [Link]<line>(500) // Array for storing
lines for highs

var float up_trend_volume = na // Volume accumulated during uptrend


var float down_trend_volume = na // Volume accumulated during downtrend
// }

// FUNCTION
S――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
―――――――――――――――――――――――――――{

// Define VIDYA (Variable Index Dynamic Average) function


vidya_calc(src, vidya_length, vidya_momentum) =>
float momentum = [Link](src)
float sum_pos_momentum = [Link]((momentum >= 0) ? momentum : 0.0,
vidya_momentum)
float sum_neg_momentum = [Link]((momentum >= 0) ? 0.0 : -momentum,
vidya_momentum)
float abs_cmo = [Link](100 * (sum_pos_momentum - sum_neg_momentum) /
(sum_pos_momentum + sum_neg_momentum))
float alpha = 2 / (vidya_length + 1)
var float vidya_value = 0.0
vidya_value := alpha * abs_cmo / 100 * src + (1 - alpha * abs_cmo /
100) * nz(vidya_value[1])

[Link](vidya_value, 15)

// Method to extend lines and add labels for liquidity levels


method extend_liquidity_lines(array<line> line_array, float price_level, bool
is_cross, volume_val)=>
if line_array.size() > 0 and last_bar_index - bar_index < 5000
for i = 0 to line_array.size()-1
if i < line_array.size()
line liquidity_line = line_array.get(i)
float current_line_level = line.get_y2(liquidity_line)
bool price_cross = is_cross
? price_level < current_line_level and
price_level[1] >= current_line_level
: price_level > current_line_level and
price_level[1] <= current_line_level

bool is_short_line = bar_index - line.get_x1(liquidity_line) < 50

if price_cross and is_short_line


line.set_x2(liquidity_line, bar_index)
line_array.remove(i)

// Add volume label to the liquidity zone


[Link](bar_index-1, price_level[1],
[Link](volume_val, [Link]),
color = [Link](0, 0, 0, 99),
style = is_cross ? label.style_label_lower_left :
label.style_label_upper_left,
textcolor = chart.fg_color,
size = [Link])

// Add a circle label to represent liquidity zone


[Link](bar_index-1, price_level[1],
text = "◉",
color = #00000003,
textcolor = is_cross ? down_trend_color :
up_trend_color,
style = label.style_label_center,
size = [Link])
// }

// CALCULATION
S――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
――――――――――――{
// Calculate the Average True Range (ATR)
float atr_value = [Link](200) // ATR calculation with length of 200

// Calculate the VIDYA (Variable Index Dynamic Average)


vidya_value = vidya_calc(source, vidya_length, vidya_momentum)
// Calculate upper and lower bands based on VIDYA and ATR
float upper_band = vidya_value + atr_value * band_distance
float lower_band = vidya_value - atr_value * band_distance

// Detect trend direction using crossovers of source with bands


if [Link](source, upper_band)
is_trend_up := true
if [Link](source, lower_band)
is_trend_up := false

// Set trend-based smoothing variable


if is_trend_up
smoothed_value := lower_band
if not is_trend_up
smoothed_value := upper_band
if [Link](is_trend_up)
smoothed_value := na

// Calculate pivot highs and lows for price action


float pivot_high = [Link](pivot_left_bars, pivot_right_bars)
float pivot_low = [Link](close, pivot_left_bars, pivot_right_bars)

// Create and store lines for pivot lows (support zones)


if low[pivot_right_bars] > smoothed_value and pivot_low
pivot_line := [Link](
bar_index[pivot_right_bars],
low[pivot_right_bars],
bar_index[pivot_right_bars]+5,
low[pivot_right_bars],
color = [Link](up_trend_color, 50)
)

liquidity_lines_low.push(pivot_line)
volume_value := [Link](volume, pivot_right_bars + pivot_left_bars) /
(pivot_right_bars + pivot_left_bars)

// Create and store lines for pivot highs (resistance zones)


if high[pivot_right_bars] < smoothed_value and pivot_high
pivot_line := [Link](
bar_index[pivot_right_bars],
high[pivot_right_bars],
bar_index[pivot_right_bars]+5,
high[pivot_right_bars],
color = [Link](down_trend_color, 50)
)

liquidity_lines_high.push(pivot_line)
volume_value := [Link](-volume, pivot_right_bars + pivot_left_bars) /
(pivot_right_bars + pivot_left_bars)

// Extend lines to track price movements


liquidity_lines_high.extend_liquidity_lines(smoothed_value, true, volume_value)
liquidity_lines_low.extend_liquidity_lines(smoothed_value, false, volume_value)

// Detect changes in the trend direction


bool trend_cross_up = not is_trend_up[1] and is_trend_up
bool trend_cross_down = not is_trend_up and is_trend_up[1]

// Reset volume counters when trend changes


if [Link](trend_cross_up) or [Link](trend_cross_down)
up_trend_volume := 0
down_trend_volume := 0

// Accumulate volume during trends


if not([Link](trend_cross_up) or [Link](trend_cross_down))
up_trend_volume += (close > open ? volume : 0)
down_trend_volume += (close < open ? volume : 0)

// Calculate average volume


float avg_volume_delta = (up_trend_volume + down_trend_volume) / 2

// Determine the color of the trend


color trend_color = is_trend_up ? up_trend_color
: not is_trend_up ? down_trend_color
: chart.fg_color

// Calculate delta volume percentage


string delta_volume =
[Link](((up_trend_volume - down_trend_volume) /
avg_volume_delta) * 100, [Link]) == "NaN%"
? "0%"
: [Link](((up_trend_volume - down_trend_volume) /
avg_volume_delta) * 100, [Link])

// }

// PLOT
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
――――――――――――――――――――――――――{
// Display labels for volume and trend statistics on the last bar
if [Link]
[Link](
[Link](bar_index, smoothed_value,
"Buy: " + [Link](up_trend_volume, [Link])
+ "\n Sell: " + [Link](down_trend_volume, [Link])
+ "\nDelta Volume: " + delta_volume,
color = [Link](trend_color, 90),
style = is_trend_up ? label.style_label_upper_left :
label.style_label_lower_left,
textcolor = chart.fg_color
)[1])

[Link]([Link](bar_index, smoothed_value,
text = "✪",
color = #00000003,
textcolor = trend_color,
style = label.style_label_center,
size = [Link])[1])

// Plot the VIDYA trend line


p1 = plot(smoothed_value, color = trend_color, linewidth = 2, style =
plot.style_linebr)
p2 = plot(hl2, display = [Link])

// Fill between the plot and the VIDYA line


fill(p1, p2, smoothed_value, hl2, [Link](trend_color, shadow ? 80 : 100), na)
// Plot trend change markers (up and down arrows)
plotshape(
series = trend_cross_up[1] ? smoothed_value[0] : na,
title = "Trend Up",
style = [Link],
location = [Link],
color = [Link](up_trend_color, 50),
text = "▲",
textcolor = chart.fg_color
)

plotshape(
series = trend_cross_down[1] ? smoothed_value[0] : na,
title = "Trend Down",
style = [Link],
location = [Link],
color = [Link](down_trend_color, 50),
text = "▼",
textcolor = chart.fg_color
)
// }

Common questions

Powered by AI

Color-coding is employed in the strategy to distinguish between uptrends and downtrends; uptrend areas are marked with the color #17dfad while downtrends use #dd326b. These colors are applied to various indicators such as trend lines, liquidity zones, and labels to immediately convey the market sentiment. This visual representation is effective for traders as it reduces cognitive load, allowing for quicker recognition of trend patterns and decisions without relying purely on numerical data .

The 'delta volume percentage' is significant as it measures the relative difference between the volume of uptrends and downtrends, scaled by the average volume delta. It serves as an indicator of market strength and internal sentiment. In volatile markets, this percentage highlights whether bullish or bearish forces dominate, aiding in making more informed decisions. A positive delta volume suggests stronger buying pressure, while a negative delta indicates stronger selling pressure. These insights are crucial for traders to gauge trend sustainability and the potential for reversals .

Liquidity lines in the Volumatic VIDYA strategy are used to represent support and resistance zones by storing pivot highs and lows. Volume information is reinforced by these lines; when a price cross occurs at these critical levels, it suggests significant market activity. The strategy further differentiates between up and down trends by accumulating volume data during these periods and using this data to generate liquidity labels and a delta volume percentage. This approach allows traders to visualize market strength at these pivot points .

Trend cross detection is critical in the Volumatic VIDYA implementation as it identifies transitions between bullish and bearish phases. When the system detects a trend change, visual markers such as arrows signal these crossings, making traders aware of essential turning points. Such detection triggers adjustments in the trend-based smoothing variable, which alters the trajectory of liquidity lines and volume calculations. Consequently, it ensures the strategy adapts quickly and allows for recalibration, thus maintaining relevance and efficacy through volatile market conditions .

'Pivot highs' and 'pivot lows' are key components in identifying potential reversal points or continuation in the market. The strategy calculates these by evaluating multiple bars to determine local highs and lows, which serve as critical points for support and resistance. Graphically, these points are represented as lines on a chart, using different colors to denote market trends. For instance, pivot lines are created at these levels to show potential liquidity and price action zones, supporting traders in making informed decisions on buying or selling .

The Average True Range (ATR) is used in the trading strategy to determine the distance of upper and lower bands from the VIDYA value by multiplying the ATR with a specified band distance factor. The bands are used to detect trend changes; a crossover of the source with the upper band suggests an upward trend, whereas a crossunder with the lower band indicates a downward trend. This application of the ATR allows the system to adjust the sensitivity of trend detection based on market volatility, providing a more robust measure for identifying true market trends .

The strategy aggregates volume data by continuously accumulating volume during identified uptrends and downtrends. This is done by summing the trade volumes where the closing price exceeds the opening price for uptrends and vice versa for downtrends. This aggregated volume data is useful as it provides insights into the strength of current trends, helping to anticipate reversals or continuations. Moreover, the delta between these aggregated volumes underscores the prevailing market bias, providing traders with actionable insights on potential entry or exit points .

Support and resistance zones are dynamically adjusted by calculating pivot highs and lows and evaluating whether these price levels exceed or fall below the calculated VIDYA value adjusted with market momentum. This ensures that zones align with current volatility and trend conditions, keeping these zones relevant to real-time market activity. As market conditions change, the strategy recalculates these zones based on updated VIDYA values and market momentum, providing traders with a continuously adapting landscape of potential price action levels .

The strategy computes volatility through the ATR, which measures price range expansion over a 200-period length. This volatility measure is then incorporated in extending liquidity lines by dictating the magnitude of the distance factor applied to upper and lower bands derived from the VIDYA value. When there is a significant price cross at these levels, liquidity lines are extended based on this volatility information and the corresponding volume, allowing traders to track market movements and the liquidity built around these critical zones .

The Variable Index Dynamic Average (VIDYA) is used to adapt to the volatility of the market by adjusting the smoothing factor. Unlike simple moving averages which apply a fixed weight to all data points, VIDYA dynamically adjusts based on market momentum. It calculates the momentum as the change in price and computes separate sums for positive and negative momentum over the specified VIDYA momentum period. An absolute Chaikin Money Flow Oscillator (CMO) is then calculated to scale the smoothing factor, allowing the VIDYA to respond faster during volatile periods while remaining stable in quieter markets .

You might also like