mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-20 03:28:05 +00:00
fix(docs): correct .md documentation across errors, dynamics, filters, forecasts, momentum, numerics, oscillators, reversals, statistics, trends, volatility, volume
Deep review of all indicator categories verified .md headers against .cs WarmupPeriod, parameters, inputs, and outputs. Fixes include warmup corrections, parameter documentation, output type accuracy, and Pine Script alignment.
This commit is contained in:
@@ -9,8 +9,6 @@ indicator("Chaikin A/D Oscillator (ADOSC)", "ADOSC", overlay=false)
|
||||
//@returns (float) The ADOSC value for the current bar (difference between short and long EMAs of ADL)
|
||||
adosc(simple int shortPeriod, simple int longPeriod) =>
|
||||
float EPSILON = 1e-10
|
||||
if shortPeriod <= 0 or longPeriod <= 0
|
||||
runtime.error("Periods must be greater than 0")
|
||||
short_alpha = 2.0 / (shortPeriod + 1)
|
||||
long_alpha = 2.0 / (longPeriod + 1)
|
||||
one_minus_long_alpha = 1.0 - long_alpha
|
||||
@@ -36,4 +34,4 @@ longPeriod = input.int(10, "Long Period", minval=1)
|
||||
osc = adosc(shortPeriod, longPeriod)
|
||||
|
||||
// ---------- Plotting ----------
|
||||
plot(osc, "ADOSC", color.new(color.yellow, 0, color=color.yellow, linewidth=2), linewidth=2)
|
||||
plot(osc, "ADOSC", color=color.yellow, linewidth=2)
|
||||
|
||||
@@ -25,7 +25,7 @@ aobv(src, vol) =>
|
||||
resArr = array.new_float(2, na)
|
||||
for i = 0 to array.size(periods) - 1
|
||||
period = array.get(periods, i)
|
||||
alpha = 2.0 / math.max(period, 1)
|
||||
alpha = 2.0 / (period + 1)
|
||||
beta = array.get(betaArr, i)
|
||||
if beta == 0.0
|
||||
beta := 1.0 - alpha
|
||||
@@ -50,8 +50,8 @@ aobv(src, vol) =>
|
||||
[array.get(resArr, 0), array.get(resArr, 1)]
|
||||
|
||||
// ---------- Inputs ----------
|
||||
src = input(close, "Source")
|
||||
vol = input(volume, "Volume")
|
||||
src = input.source(close, "Source")
|
||||
vol = input.source(volume, "Volume")
|
||||
|
||||
// ---------- Calculations ----------
|
||||
[aobvFast, aobvSlow] = aobv(src, vol)
|
||||
|
||||
@@ -11,10 +11,6 @@ indicator("Chaikin Money Flow (CMF)", "CMF", overlay=false)
|
||||
//@param src_vol The volume (default: built-in volume)
|
||||
//@returns float CMF value between -1 and 1
|
||||
cmf(len = 20, src_high = high, src_low = low, src_close = close, src_vol = volume) =>
|
||||
// Validate parameters
|
||||
if len < 1
|
||||
runtime.error("Length must be >= 1")
|
||||
|
||||
// Calculate Money Flow Multiplier
|
||||
float mfm = 0.0
|
||||
if not na(src_high) and not na(src_low) and not na(src_close)
|
||||
|
||||
@@ -9,8 +9,6 @@ indicator("Elder's Force Index (EFI)", "EFI", overlay=false)
|
||||
//@param src_vol The volume (default: built-in volume)
|
||||
//@returns float The smoothed Force Index value
|
||||
efi(len = 13, src = close, src_vol = volume) =>
|
||||
if len < 1
|
||||
runtime.error("Length must be >= 1")
|
||||
var float prev_src = src
|
||||
float raw_force = (nz(src) - nz(prev_src)) * nz(src_vol)
|
||||
prev_src := src
|
||||
|
||||
@@ -9,8 +9,6 @@ indicator("Ease of Movement (EOM)", "EOM", overlay=false)
|
||||
//@returns float Ease of Movement value
|
||||
//@optimized for performance and dirty data
|
||||
eom(i_smoothing, i_vol_scale, i_high=high, i_low=low, i_volume=volume) =>
|
||||
if i_smoothing < 1 or i_vol_scale <= 0
|
||||
runtime.error("Smoothing or Volume scale out or range")
|
||||
var float oldMidPoint = na
|
||||
midPoint = (i_high + i_low) * 0.5
|
||||
midPointChange = midPoint - nz(oldMidPoint, midPoint)
|
||||
|
||||
@@ -10,8 +10,6 @@ indicator("Elastic Volume Weighted Moving Average (EVWMA)", "EVWMA", overlay=tru
|
||||
//@returns EVWMA value where high-volume bars get more weight (faster response)
|
||||
//@optimized O(1) per bar via circular buffer for running volume sum
|
||||
evwma(series float src, series float vol, simple int period) =>
|
||||
if period <= 0
|
||||
runtime.error("Period must be greater than 0")
|
||||
var int p = math.max(1, period), var int head = 0, var int count = 0
|
||||
var array<float> vol_buffer = array.new_float(p, 0.0)
|
||||
var float sum_vol = 0.0
|
||||
|
||||
@@ -28,7 +28,7 @@ iii(simple int period, simple bool cumulative=false, series float h=high, series
|
||||
valid_count := not na(raw_iii) ? valid_count + 1 : valid_count
|
||||
array.set(buffer, head, raw_iii)
|
||||
head := (head + 1) % period
|
||||
smoothed_iii = sum / period
|
||||
smoothed_iii = valid_count > 0 ? sum / valid_count : 0.0
|
||||
cumulative_value := cumulative_value + raw_iii
|
||||
cumulative ? cumulative_value : smoothed_iii
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ indicator("Money Flow Index (MFI)", "MFI", overlay=false)
|
||||
//@returns float The MFI value (0-100)
|
||||
//@optimized Uses circular buffers for O(1) performance with proper NA handling
|
||||
mfi(simple int len, series float src_high=high, series float src_low=low, series float src_close=close, series float src_vol=volume) =>
|
||||
if len < 1
|
||||
runtime.error("Invalid parameter: len must be >= 1")
|
||||
float typical_price = (src_high + src_low + src_close) / 3.0
|
||||
float raw_money_flow = typical_price * nz(src_vol, 0.0)
|
||||
float prev_typical_price = nz(typical_price[1], typical_price)
|
||||
|
||||
@@ -12,8 +12,6 @@ indicator("Price Volume Divergence (PVD)", "PVD", overlay=false)
|
||||
//@returns Smoothed divergence value
|
||||
//@optimized for performance and dirty data
|
||||
pvd(simple int price_period, simple int volume_period, simple int smoothing_period, series float c=close, series float vol=volume ) =>
|
||||
if smoothing_period <= 0
|
||||
runtime.error("Smoothing period must be greater than 0")
|
||||
float close_price = nz(c, close)
|
||||
float volume_val = math.max(nz(vol, 0.0), 1.0)
|
||||
float prev_close = bar_index < price_period ? close_price[math.max(bar_index, 1)] : close_price[price_period]
|
||||
|
||||
@@ -11,10 +11,6 @@ indicator("Percentage Volume Oscillator (PVO)", "PVO", overlay=false)
|
||||
//@returns tuple with [pvo, signal, histogram] values
|
||||
//@optimized Beta precomputation for EMA warmup compensation
|
||||
pvo(series float vol, simple int fast_period, simple int slow_period, simple int signal_period) =>
|
||||
if fast_period <= 0 or slow_period <= 0 or signal_period <= 0
|
||||
runtime.error("All periods must be greater than 0")
|
||||
if fast_period >= slow_period
|
||||
runtime.error("Fast period must be less than slow period")
|
||||
float vol_val = nz(vol, 0.0)
|
||||
float fast_alpha = 2.0 / (fast_period + 1)
|
||||
float slow_alpha = 2.0 / (slow_period + 1)
|
||||
|
||||
@@ -22,4 +22,4 @@ i_price_source = input.source(close, "Price Source")
|
||||
pvr_value = pvr(i_price_source)
|
||||
|
||||
// Plot
|
||||
plot(pvr_value, "PVR", color=color.yellow, linewidth=2, plot.style_stepline)
|
||||
plot(pvr_value, "PVR", color=color.yellow, linewidth=2, style=plot.style_stepline)
|
||||
|
||||
@@ -11,8 +11,6 @@ indicator("Volume Oscillator (VO)", "VO", overlay=false)
|
||||
//@returns Volume Oscillator value
|
||||
//@optimized for performance and dirty data
|
||||
vo(simple int short_period, simple int long_period, simple int signal_period, series float vol=volume) =>
|
||||
if short_period >= long_period
|
||||
runtime.error("Short period must be less than long period")
|
||||
volume_val = math.max(nz(vol, 0.0), 1.0)
|
||||
var p_short = short_period
|
||||
var buffer_short = array.new_float(p_short, na)
|
||||
|
||||
@@ -10,9 +10,6 @@ indicator("Volume Rate of Change (VROC)", "VROC", overlay=false)
|
||||
//@returns Volume Rate of Change value
|
||||
//@optimized for performance and dirty data
|
||||
vroc(simple int period, simple bool calc_type, series float vol = volume) =>
|
||||
if period <= 0
|
||||
runtime.error("Period must be greater than 0")
|
||||
|
||||
float current_volume = vol
|
||||
float historical_volume = vol[period]
|
||||
if na(current_volume) or na(historical_volume)
|
||||
|
||||
@@ -12,8 +12,6 @@ indicator("Volume Weighted Accumulation/Distribution (VWAD)", "VWAD", overlay=fa
|
||||
//@returns VWAD value representing volume-weighted accumulation/distribution
|
||||
//@optimized for performance and dirty data
|
||||
vwad(simple int period, series float src_high = high, series float src_low = low, series float src_close = close, series float src_vol = volume) =>
|
||||
if period <= 0
|
||||
runtime.error("Period must be greater than 0")
|
||||
var int p = math.max(1, period), var int head = 0
|
||||
var array<float> vol_buffer = array.new_float(p, na)
|
||||
var float sum_vol = 0.0
|
||||
|
||||
@@ -10,8 +10,6 @@ indicator("Volume Weighted Moving Average (VWMA)", "VWMA", overlay=true)
|
||||
//@returns VWMA value representing volume-weighted moving average
|
||||
//@optimized for performance and dirty data
|
||||
vwma(series float src, series float vol, simple int period) =>
|
||||
if period <= 0
|
||||
runtime.error("Period must be greater than 0")
|
||||
var int p = math.max(1, period), var int head = 0, var int count = 0
|
||||
var array<float> price_buffer = array.new_float(p, na)
|
||||
var array<float> vol_buffer = array.new_float(p, na)
|
||||
|
||||
Reference in New Issue
Block a user