mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 05:27:43 +00:00
24e86d762a
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Price Volume Trend (PVT)", "PVT", overlay=false)
|
|
|
|
//@function Calculates Price Volume Trend, cumulative volume adjusted by relative price changes
|
|
//@param src Source price for calculation (typically close)
|
|
//@param src_vol Volume data
|
|
//@returns float The cumulative PVT value
|
|
pvt(series float src, series float src_vol) =>
|
|
float price_change = src - nz(src[1], src)
|
|
float price_prev = nz(src[1], src)
|
|
float price_change_ratio = price_prev != 0 ? price_change / price_prev : 0.0
|
|
float volume_adjustment = nz(src_vol, 0.0) * price_change_ratio
|
|
var float cumulative_pvt = 0.0
|
|
cumulative_pvt += volume_adjustment
|
|
cumulative_pvt
|
|
|
|
// ---------- Main Calculation ----------
|
|
|
|
// Parameters - PVT typically doesn't need input parameters as it's cumulative
|
|
|
|
// Calculation
|
|
pvt_line = pvt(close, volume)
|
|
|
|
// ---------- Plots ----------
|
|
|
|
plot(pvt_line, "PVT", color.yellow, 2)
|
|
hline(0, "Zero Line", color.gray, linestyle=hline.style_dashed)
|
|
|
|
// Signal line (optional smoothed version)
|
|
signal_length = input.int(14, "Signal Line Period", minval=1)
|
|
pvt_signal = ta.sma(pvt_line, signal_length)
|
|
plot(pvt_signal, "PVT Signal", color.red, 1)
|
|
|
|
// Background coloring for trend indication
|
|
bgcolor(pvt_line > pvt_signal ? color.green : color.red)
|