PINE LIBRARY
업데이트됨 TAUtilityLib

Library "TAUtilityLib"
Technical Analysis Utility Library - Collection of functions for market analysis, smoothing, scaling, and structure detection
log_snapshot(label1, val1, label2, val2, label3, val3, label4, val4, label5, val5)
Creates formatted log snapshot with 5 labeled values
Parameters:
label1 (string)
val1 (float)
label2 (string)
val2 (float)
label3 (string)
val3 (float)
label4 (string)
val4 (float)
label5 (string)
val5 (float)
Returns: void (logs to console)
f_get_next_tf(tf, steps)
Gets next higher timeframe(s) from current
Parameters:
tf (string): Current timeframe string
steps (string): "1 TF Higher" for next TF, any other value for 2 TFs higher
Returns: Next timeframe string or na if at maximum
f_get_prev_tf(tf)
Gets previous lower timeframe from current
Parameters:
tf (string): Current timeframe string
Returns: Previous timeframe string or na if at minimum
supersmoother(_src, _length)
Ehler's SuperSmoother - low-lag smoothing filter
Parameters:
_src (float): Source series to smooth
_length (simple int): Smoothing period
Returns: Smoothed series
butter_smooth(src, len)
Butterworth filter for ultra-smooth price filtering
Parameters:
src (float): Source series
len (simple int): Filter period
Returns: Butterworth smoothed series
f_dynamic_ema(source, dynamic_length)
Dynamic EMA with variable length
Parameters:
source (float): Source series
dynamic_length (float): Dynamic period (can vary bar to bar)
Returns: Dynamically adjusted EMA
dema(source, length)
Double Exponential Moving Average (DEMA)
Parameters:
source (float): Source series
length (simple int): Period for DEMA calculation
Returns: DEMA value
f_scale_percentile(primary_line, secondary_line, x)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
x (int): Lookback bars for percentile calculation
Returns: Scaled version of secondary_line
calculate_correlation_scaling(demamom_range, demamom_min, correlation_range, correlation_min)
Calculates scaling factors for correlation alignment
Parameters:
demamom_range (float): Range of primary series
demamom_min (float): Minimum of primary series
correlation_range (float): Range of secondary series
correlation_min (float): Minimum of secondary series
Returns: [scale_factor, offset] tuple for alignment
getBB(src, length, mult, chartlevel)
Calculates Bollinger Bands with chart level offset
Parameters:
src (float): Source series
length (simple int): MA period
mult (simple float): Standard deviation multiplier
chartlevel (simple float): Vertical offset for plotting
Returns: [upper, lower, basis] tuple
get_mrc(source, length, mult, mult2, gradsize)
Mean Reversion Channel with multiple bands and conditions
Parameters:
source (float): Price source
length (simple int): Channel period
mult (simple float): First band multiplier
mult2 (simple float): Second band multiplier
gradsize (simple float): Gradient size for zone detection
Returns: [meanline, meanrange, upband1, loband1, upband2, loband2, condition]
analyzeMarketStructure(highFractalBars, highFractalPrices, lowFractalBars, lowFractalPrices, trendDirection)
Analyzes market structure for ChoCH and BOS patterns
Parameters:
highFractalBars (array<int>): Array of high fractal bar indices
highFractalPrices (array<float>): Array of high fractal prices
lowFractalBars (array<int>): Array of low fractal bar indices
lowFractalPrices (array<float>): Array of low fractal prices
trendDirection (int): Current trend (1=up, -1=down, 0=neutral)
Returns: [choch, bos, newTrend] - change signals and new trend direction
Technical Analysis Utility Library - Collection of functions for market analysis, smoothing, scaling, and structure detection
log_snapshot(label1, val1, label2, val2, label3, val3, label4, val4, label5, val5)
Creates formatted log snapshot with 5 labeled values
Parameters:
label1 (string)
val1 (float)
label2 (string)
val2 (float)
label3 (string)
val3 (float)
label4 (string)
val4 (float)
label5 (string)
val5 (float)
Returns: void (logs to console)
f_get_next_tf(tf, steps)
Gets next higher timeframe(s) from current
Parameters:
tf (string): Current timeframe string
steps (string): "1 TF Higher" for next TF, any other value for 2 TFs higher
Returns: Next timeframe string or na if at maximum
f_get_prev_tf(tf)
Gets previous lower timeframe from current
Parameters:
tf (string): Current timeframe string
Returns: Previous timeframe string or na if at minimum
supersmoother(_src, _length)
Ehler's SuperSmoother - low-lag smoothing filter
Parameters:
_src (float): Source series to smooth
_length (simple int): Smoothing period
Returns: Smoothed series
butter_smooth(src, len)
Butterworth filter for ultra-smooth price filtering
Parameters:
src (float): Source series
len (simple int): Filter period
Returns: Butterworth smoothed series
f_dynamic_ema(source, dynamic_length)
Dynamic EMA with variable length
Parameters:
source (float): Source series
dynamic_length (float): Dynamic period (can vary bar to bar)
Returns: Dynamically adjusted EMA
dema(source, length)
Double Exponential Moving Average (DEMA)
Parameters:
source (float): Source series
length (simple int): Period for DEMA calculation
Returns: DEMA value
f_scale_percentile(primary_line, secondary_line, x)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
x (int): Lookback bars for percentile calculation
Returns: Scaled version of secondary_line
calculate_correlation_scaling(demamom_range, demamom_min, correlation_range, correlation_min)
Calculates scaling factors for correlation alignment
Parameters:
demamom_range (float): Range of primary series
demamom_min (float): Minimum of primary series
correlation_range (float): Range of secondary series
correlation_min (float): Minimum of secondary series
Returns: [scale_factor, offset] tuple for alignment
getBB(src, length, mult, chartlevel)
Calculates Bollinger Bands with chart level offset
Parameters:
src (float): Source series
length (simple int): MA period
mult (simple float): Standard deviation multiplier
chartlevel (simple float): Vertical offset for plotting
Returns: [upper, lower, basis] tuple
get_mrc(source, length, mult, mult2, gradsize)
Mean Reversion Channel with multiple bands and conditions
Parameters:
source (float): Price source
length (simple int): Channel period
mult (simple float): First band multiplier
mult2 (simple float): Second band multiplier
gradsize (simple float): Gradient size for zone detection
Returns: [meanline, meanrange, upband1, loband1, upband2, loband2, condition]
analyzeMarketStructure(highFractalBars, highFractalPrices, lowFractalBars, lowFractalPrices, trendDirection)
Analyzes market structure for ChoCH and BOS patterns
Parameters:
highFractalBars (array<int>): Array of high fractal bar indices
highFractalPrices (array<float>): Array of high fractal prices
lowFractalBars (array<int>): Array of low fractal bar indices
lowFractalPrices (array<float>): Array of low fractal prices
trendDirection (int): Current trend (1=up, -1=down, 0=neutral)
Returns: [choch, bos, newTrend] - change signals and new trend direction
릴리즈 노트
v2Added:
f_safeArrayGet(arr, index)
Safe array access that prevents out-of-bounds errors
Parameters:
arr (array<float>): The array to access (float array)
index (int): The index to access (can be negative or exceed array size)
Returns: The value at the safe index, or 0.0 if array is empty
f_safeArrayGetInt(arr, index)
Safe array access for integer arrays
Parameters:
arr (array<int>): The array to access (int array)
index (int): The index to access
Returns: The value at the safe index, or 0 if array is empty
f_safeArrayGetBool(arr, index)
Safe array access for boolean arrays
Parameters:
arr (array<bool>): The array to access (bool array)
index (int): The index to access
Returns: The value at the safe index, or false if array is empty
f_safeArrayGetString(arr, index)
Safe array access for string arrays
Parameters:
arr (array<string>): The array to access (string array)
index (int): The index to access
Returns: The value at the safe index, or empty string if array is empty
Updated:
f_scale_percentile(primary_line, secondary_line, lookback, percentile)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
lookback (int): Lookback bars for percentile calculation
percentile (simple float)
Returns: Scaled version of secondary_line
Removed:
calculate_correlation_scaling(demamom_range, demamom_min, correlation_range, correlation_min)
Calculates scaling factors for correlation alignment
릴리즈 노트
v3Updated:
f_scale_percentile(primary_line, secondary_line, lookback, percentile, chart_level)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
lookback (int): Lookback bars for percentile calculation
percentile (simple float)
chart_level (float)
Returns: Scaled version of secondary_line, with chart vertical offset
릴리즈 노트
v4Added:
getfractalSweepRange(fractalBar, fractalPrice, isFractalHigh, prevFractalBar, prevFractalWasHigh)
Enhanced function to get the true sweep range for fractals
Parameters:
fractalBar (int): Bar index of the current fractal
fractalPrice (float): Price of the current fractal (high for bearish, low for bullish)
isFractalHigh (bool): True if current fractal is a HIGH fractal, false for LOW
prevFractalBar (int): Bar index of the previous fractal
prevFractalWasHigh (bool): True if previous fractal was a HIGH fractal
Returns: [rangeHigh, rangeLow] tuple representing sweep range boundaries
릴리즈 노트
v5Added:
scale_for_subchart(primary_line, secondary_line, lookback, percentile, chart_level, offset_value, offset_is_percent)
Scales and offsets a series for subchart plotting using existing f_scale_percentile
Parameters:
primary_line (float): Reference series for scaling
secondary_line (float): Series to be scaled
lookback (int): Lookback period for percentile
percentile (simple float): Percentile value (e.g., 8 for 8th/92nd)
chart_level (float): Base chart level offset
offset_value (float): Additional offset from chart level
offset_is_percent (bool): If true, offset_value is % of primary range
Returns: Scaled and offset series ready for plotting
check_pivot_crossings(pivot_bars, pivot_prices, pivot_strengths, current_bar, current_price, is_high, max_age, max_touches)
Checks if price crosses through correlation/pivot lines and counts touches
Parameters:
pivot_bars (array<int>): Array of pivot bar indices
pivot_prices (array<float>): Array of pivot prices
pivot_strengths (array<float>): Array of pivot strengths/scores
current_bar (int): Current bar index being checked
current_price (float): Current price level
is_high (bool): True if checking high pivots, false for lows
max_age (int): Maximum age of pivots to check
max_touches (int): Maximum touches before pivot expires
Returns: [bullish_score, bearish_score, touch_count, touched_pivots_string, crossed_price]
create_tooltip(title, title_icon, section_titles, section_icons, param_names, param_values, param_icons, use_dividers)
Universal tooltip builder that formats structured data into tooltip text
Parameters:
title (string): Main tooltip title
title_icon (string): Unicode icon for the main title
section_titles (array<string>): Array of section titles
section_icons (array<string>): Array of section unicode icons
param_names (array<string>): Array of parameter names (use "|" to separate sections)
param_values (array<float>): Array of parameter values (parallel to param_names)
param_icons (array<string>): Array of parameter icons (parallel to param_names)
use_dividers (bool): Whether to add dividers between sections
Returns: Formatted tooltip string
create_tooltip_str(title, title_icon, section_titles, section_icons, param_names, param_values, param_icons, use_dividers)
Alternative version that accepts string values instead of floats
Parameters:
title (string): Main tooltip title
title_icon (string): Unicode icon for the main title
section_titles (array<string>): Array of section titles
section_icons (array<string>): Array of section unicode icons
param_names (array<string>): Array of parameter names (use "|" to separate sections)
param_values (array<string>): Array of parameter values as strings
param_icons (array<string>): Array of parameter icons
use_dividers (bool): Whether to add dividers between sections
Returns: Formatted tooltip string
릴리즈 노트
v6Added:
getNormalizedCoefficient(sourceValue, lookbackPeriod, percentileMargin, smoothingLength, useZScore, zScoreClamp)
Parameters:
sourceValue (float)
lookbackPeriod (int)
percentileMargin (simple float)
smoothingLength (simple int)
useZScore (bool)
zScoreClamp (float)
getNormalizedCoefficientDynamic(sourceValue, lookbackSource, percentileMargin, smoothingLength)
Parameters:
sourceValue (float)
lookbackSource (float)
percentileMargin (simple float)
smoothingLength (simple int)
릴리즈 노트
v7Updated:
getNormalizedCoefficient(sourceValue, lookbackPeriod, percentileMargin, smoothingLength, useZScore, zScoreClamp, oneRange)
Parameters:
sourceValue (float)
lookbackPeriod (int)
percentileMargin (simple float)
smoothingLength (simple int)
useZScore (bool)
zScoreClamp (float)
oneRange (bool)
릴리즈 노트
v8릴리즈 노트
v9, added band/level/line touch detection function, see code for details.릴리즈 노트
v10Added:
touch(value, level, toleranceAbs, tolerancePerc, useSimpleTouch, useBodyCross, useWickTouch, checkCrossing, minDistFromPrev, useATR, atrPeriod, atrMultiplier, atrNormPeriod)
Parameters:
value (float): - Primary value to check (can be close, high, low, etc.)
level (float): - Level to check against (EMA, band, any threshold)
toleranceAbs (float): - Absolute tolerance value (optional, default = 0)
tolerancePerc (float): - Percentage tolerance (as decimal, optional, default = 0)
useSimpleTouch (bool): - Enable simple distance-based touch detection (default=true)
useBodyCross (bool): - Enable candle body crossing detection (default=true)
useWickTouch (bool): - Enable candle wick touch detection (default=true)
checkCrossing (bool): - Consider values crossing the level as touching (default=true)
minDistFromPrev (float): - Minimum distance from previous touch in bars (optional, default = 0)
useATR (bool): - Use ATR to scale tolerance (default=false)
atrPeriod (simple int): - ATR period if useATR is true (default=14)
atrMultiplier (float): - Multiplier for ATR-based tolerance (default=1.0)
atrNormPeriod (int): - Period for ATR normalization (default=20)
Returns: -1 for touch from above, 1 for touch from below, 0 for no touch
릴리즈 노트
v11Updated:
touch(level, toleranceAbs, tolerancePerc, useATR, atrPeriod, atrMultiplier, atrNormPeriod, enableBodyDetection, enableWickDetection, enableHistoricalDetection)
Parameters:
level (float): - Level to check against (EMA, band, any threshold)
toleranceAbs (float): - Absolute tolerance value (optional, default = 0)
tolerancePerc (float): - Percentage tolerance (as decimal, optional, default = 0)
useATR (bool): - Use ATR to scale tolerance (default=false)
atrPeriod (simple int): - ATR period if useATR is true (default=14)
atrMultiplier (float): - Multiplier for ATR-based tolerance (default=1.0)
atrNormPeriod (int): - Period for ATR normalization (default=20)
enableBodyDetection (bool): - Enable all body-related detections (default=true)
enableWickDetection (bool): - Enable all wick-related detections (default=true)
enableHistoricalDetection (bool): - Enable detection using previous bar data (default=true)
Returns: 0 for body cross, -1 for touch from above, 1 for touch from below, na for no touch
릴리즈 노트
v12릴리즈 노트
v13Added:
calculateSlopeScore(dema_momentums, lookback_bars, percentile_period, percentile_margin, tanh_strength)
Calculate percentile-based slope score with optional tanh transformation
Parameters:
dema_momentums (float): Series of DEMA momentum values
lookback_bars (int): Number of bars to look back for slope calculation
percentile_period (int): Period for percentile calculation
percentile_margin (simple float): Margin for percentile boundaries (e.g., 5 for 5th and 95th percentiles)
tanh_strength (float): Strength of tanh transformation (0 for linear, >0 for curved response)
Returns: Score between -1 and 1 based on percentile position with optional tanh emphasis
릴리즈 노트
v14릴리즈 노트
v15Added:
cov(x, y, length)
Calculates covariance between two series
Parameters:
x (float): First data series
y (float): Second data series
length (simple int): Lookback period
Returns: Covariance value
릴리즈 노트
v16Added:
f_dynamic_sma(src, dynamic_len)
Dynamic SMA (series period)
Parameters:
src (float): The input series
dynamic_len (float): Series-type window length for SMA (must be >=1)
Returns: SMA with dynamic window length
f_dynamic_stdev(src, dynamic_len)
Dynamic Standard Deviation (series period)
Parameters:
src (float): The input series
dynamic_len (float): Series-type window length for StdDev (must be >=2)
Returns: Stdev with dynamic window length
릴리즈 노트
v17Added:
f_dynamic_rma(src, dynamic_len)
Dynamic RMA (Wilder) with series length
Parameters:
src (float): Input series
dynamic_len (float): Series-type period (>=1). If <1, coerced to 1.
Returns: RMA with variable length, stable and stateful
f_dynamic_sma_fast(src, dynamic_len)
Dynamic SMA (stateful, O(1) update) with series window
Note: exact rolling SMA with variable window requires O(N) sum; this version approximates SMA by adaptive EMA with alpha=2/(L+1) when L varies smoothly.
For exact SMA, keep your f_dynamic_sma above.
Parameters:
src (float): Input series
dynamic_len (float): Series-type window length (>=1)
Returns: Adaptive-EMA SMA approximation for speed-critical paths
릴리즈 노트
v18Added:
cov_dynamic(x, y, dynamic_length)
Dynamic Covariance with series length support
Parameters:
x (float): First data series
y (float): Second data series
dynamic_length (int): Lookback period (can be series)
Returns: Covariance value with dynamic window
릴리즈 노트
v19Added:
trimFractalArray(arr, maxSize)
Trims a FractalData array to maximum size by removing oldest elements
Parameters:
arr (array<FractalData>): Array of FractalData to trim
maxSize (int): Maximum allowed size
Returns: void (modifies array in place)
trimCorrelationArray(arr, maxSize)
Trims a CorrelationLine array to maximum size
Parameters:
arr (array<CorrelationLine>): Array of CorrelationLine to trim
maxSize (int): Maximum allowed size
Returns: void (modifies array in place)
newFractal(bar, price, momentum, marker)
Creates a new FractalData instance
Parameters:
bar (int): Bar index
price (float): Fractal price
momentum (float): DEMA momentum value
marker (string): Divergence marker type
Returns: New FractalData instance
newCorrelationLine(bar, price, lineType)
Creates a new CorrelationLine instance
Parameters:
bar (int): Bar index
price (float): Line price
lineType (string): Type of line
Returns: New CorrelationLine instance
getMaxDistance(arr)
Gets maximum value from an array of floats (for swept distances)
Parameters:
arr (array<float>): Array of float values
Returns: Maximum value or 0.0 if empty
getMarkerType(peak, peak1, peak2, ltfPeak, ltfPeak1, ltfPeak2, entry, colorChanged, colorChanged1, earlyReversal, earlyReversal1, colorChangedCurrent, markerPrefix)
Checks marker conditions for divergence detection (parameterized)
Parameters:
peak (bool): Main peak condition
peak1 (bool): Peak condition 1 bar ago
peak2 (bool): Peak condition 2 bars ago
ltfPeak (bool): LTF peak condition
ltfPeak1 (bool): LTF peak 1 bar ago
ltfPeak2 (bool): LTF peak 2 bars ago
entry (bool): Entry signal condition
colorChanged (bool): Color changed condition
colorChanged1 (bool): Color changed 1 bar ago
earlyReversal (bool): Early reversal condition
earlyReversal1 (bool): Early reversal 1 bar ago
colorChangedCurrent (bool): Color changed on current bar
markerPrefix (string): Prefix for marker type ("bearish" or "bullish")
Returns: Marker type string
createLiquiditySweepTooltip(title, icon, barIdx, fractalID, fractalPrice, labelText, sweptCount, sweptIDsList, maxDistance, hasDivergence, divergenceType, currMom)
Creates liquidity sweep tooltip data
Parameters:
title (string): Tooltip title
icon (string): Title icon
barIdx (int): Current bar index
fractalID (int): Fractal ID
fractalPrice (float): Fractal price
labelText (string): Label text (liquidity power)
sweptCount (int): Number of fractals swept
sweptIDsList (string): String of swept IDs
maxDistance (float): Maximum sweep distance
hasDivergence (bool): Whether divergence exists
divergenceType (string): Type of divergence
currMom (float): Current momentum
Returns: Formatted tooltip string
FractalData
Fractal data structure consolidating all fractal-related arrays
Fields:
bar (series int): Bar index where fractal occurred
price (series float): Price level of the fractal
liquidated (series bool): Whether this fractal's liquidity has been swept
sweptStrength (series float): Strength/distance of the liquidity sweep
momentum (series float): DEMA momentum value at the fractal
marker (series string): Divergence marker type ("none", "bearishPeak", "bullishPeak", etc.)
CorrelationLine
Correlation line data structure
Fields:
bar (series int): Bar index where line was created
price (series float): Price level of the line
lineType (series string): Type of correlation line ("osc_bull", "osc_bear", "extreme_bull", "extreme_bear")
touchCount (series int): Number of times price has touched this line
active (series bool): Whether the line is still active for touch detection
PrevFractalState
Previous fractal tracking for divergence detection
Fields:
price (series float): Price at the fractal
demamom (series float): DEMA momentum value at the fractal
bar (series int): Bar index of the fractal
릴리즈 노트
v20 covariance function fix that may have flipped signs릴리즈 노트
v21릴리즈 노트
v22릴리즈 노트
v23릴리즈 노트
v24Updated:
f_scale_percentile(primary_line, secondary_line, lookback, percentile, chart_level, bi)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
lookback (int): Lookback bars for percentile calculation
percentile (simple float): Percentile value (e.g., 8 for 8th/92nd)
chart_level (float): Base chart level offset
bi (int): Bar index (optional, default bar_index)
Returns: Scaled version of secondary_line
릴리즈 노트
v25릴리즈 노트
v26Updated:
f_scale_percentile(primary_line, secondary_line, lookback, percentile, chart_level)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
lookback (int): Lookback bars for percentile calculation
percentile (simple float)
chart_level (float)
Returns: Scaled version of secondary_line
릴리즈 노트
v27Added:
f_prices_to_returns(prices)
Convert prices array to returns array
Parameters:
prices (array<float>): Array of price values
Returns: Array of returns (percentage changes)
f_pearson_tail(x, y, length)
Pearson correlation on the TAIL of arrays (newest data)
Parameters:
x (array<float>): First array
y (array<float>): Second array
length (int): Number of elements from tail to use
Returns: Correlation coefficient [-1, 1]
f_pearson(x, y, length)
Pearson correlation on arrays (from beginning)
Parameters:
x (array<float>): First array
y (array<float>): Second array
length (int): Number of elements to use
Returns: Correlation coefficient [-1, 1]
f_spearman(x, y, length)
Spearman rank correlation (robust to outliers)
Parameters:
x (array<float>): First array
y (array<float>): Second array
length (int): Number of elements to use
Returns: Rank correlation coefficient [-1, 1]
f_kendall(x, y, length, sampling_step)
Kendall Tau correlation (concordant pairs, most robust)
Parameters:
x (array<float>): First array
y (array<float>): Second array
length (int): Number of elements to use
sampling_step (int): Step for sampling (1 = full precision, higher = faster)
Returns: Kendall Tau coefficient [-1, 1]
f_discretize(data, bins)
Discretize continuous data into bins (for entropy calculations)
Parameters:
data (array<float>): Array of continuous values
bins (int): Number of bins
Returns: Array of bin indices
f_tanh(x)
Hyperbolic tangent (tanh) for normalization
Parameters:
x (float): Input value
Returns: tanh(x) in range [-1, 1]
릴리즈 노트
v28Added:
f_calc_delta(h, l, c, v)
Parameters:
h (float)
l (float)
c (float)
v (float)
f_calc_buy_sell(h, l, c, v)
Parameters:
h (float)
l (float)
c (float)
v (float)
f_atr_dynamic(len)
Parameters:
len (int)
f_sigmoid_norm(x, steepness)
Parameters:
x (float)
steepness (float)
f_apply_weight(p, w)
Parameters:
p (float)
w (float)
f_ema_stateful(src, len)
Parameters:
src (float)
len (int)
Updated:
f_scale_percentile(primary_line, secondary_line, lookback, percentile, chart_level)
Scales secondary line to match primary line using percentile ranges
Parameters:
primary_line (float): Reference series for target scale
secondary_line (float): Series to be scaled
lookback (int): Lookback bars for percentile calculation
percentile (simple float): Percentile value (e.g., 5 for 5th and 95th percentiles)
chart_level (float): Base chart level offset
Returns: Scaled version of secondary_line
릴리즈 노트
v29Added:
f_ema_custom(src, len)
Parameters:
src (float)
len (int)
f_get_lower_tf(tf)
Parameters:
tf (string)
릴리즈 노트
v30Added:
KalmanState
Fields:
price (series float)
velocity (series float)
P_price (series float)
P_vel (series float)
P_cross (series float)
R_ewma (series float)
bars_run (series int)
릴리즈 노트
v31Added:
f_noop(x)
Parameters:
x (float)
릴리즈 노트
v32Added:
f_kalman_update(state, measurement, Q_price_scaled, Q_vel_scaled, R_scaled)
Parameters:
state (KalmanState)
measurement (float)
Q_price_scaled (float)
Q_vel_scaled (float)
R_scaled (float)
릴리즈 노트
v33Added:
f_kalman_update_te(state, measurement, Q_price_scaled, Q_vel_scaled, R_scaled, te_unit, te_q_gain, te_r_gain, te_scale_min, te_scale_max)
Parameters:
state (KalmanState)
measurement (float)
Q_price_scaled (float)
Q_vel_scaled (float)
R_scaled (float)
te_unit (float)
te_q_gain (float)
te_r_gain (float)
te_scale_min (float)
te_scale_max (float)
f_te_enhanced_kalman_update(state, measurement, Q_price_base, Q_vel_base, R_base, te_norm, te_q_sensitivity, te_r_sensitivity, te_scale_min, te_scale_max)
Parameters:
state (KalmanState)
measurement (float)
Q_price_base (float)
Q_vel_base (float)
R_base (float)
te_norm (float)
te_q_sensitivity (float)
te_r_sensitivity (float)
te_scale_min (float)
te_scale_max (float)
f_symbol_activity_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Parameters:
s_timeClose_1m (float)
s_inAnySess_1m (bool)
fresh_secs (float)
f_is_trading_now(sym, fresh_secs)
Parameters:
sym (string)
fresh_secs (float)
f_is_active_symbol(tradingNow)
Parameters:
tradingNow (bool)
f_status_icon(sym, fresh_secs)
Parameters:
sym (string)
fresh_secs (float)
f_symbol_status_icon(tradingNow, exchangeClosed, sessionOpenButStale)
Parameters:
tradingNow (bool)
exchangeClosed (bool)
sessionOpenButStale (bool)
f_status_icon_from_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Parameters:
s_timeClose_1m (float)
s_inAnySess_1m (bool)
fresh_secs (float)
Removed:
f_discretize(data, bins)
Discretize continuous data into bins (for entropy calculations)
릴리즈 노트
v34Added:
f_getOrFloat(arr, index, defval)
Parameters:
arr (array<float>)
index (int)
defval (float)
f_getOrInt(arr, index, defval)
Parameters:
arr (array<int>)
index (int)
defval (int)
f_getOrBool(arr, index, defval)
Parameters:
arr (array<bool>)
index (int)
defval (bool)
f_getOrString(arr, index, defval)
Parameters:
arr (array<string>)
index (int)
defval (string)
f_zscore(sourceValue, lookbackPeriod, smoothingLength)
Parameters:
sourceValue (float)
lookbackPeriod (int)
smoothingLength (simple int)
getNormalizedCoefficientNoClamp(sourceValue, lookbackPeriod, percentileMargin, smoothingLength, useZScore, oneRange)
Parameters:
sourceValue (float)
lookbackPeriod (int)
percentileMargin (simple float)
smoothingLength (simple int)
useZScore (bool)
oneRange (bool)
Updated:
touch(level, toleranceAbs, tolerancePerc, useATR, atrPeriod, atrMultiplier, atrNormPeriod, enableBodyDetection, enableWickDetection, enableHistoricalDetection, ltf_delta)
Parameters:
level (float): - Level to check against (EMA, band, any threshold)
toleranceAbs (float): - Absolute tolerance value (optional, default = 0)
tolerancePerc (float): - Percentage tolerance (as decimal, optional, default = 0)
useATR (bool): - Use ATR to scale tolerance (default=false)
atrPeriod (simple int): - ATR period if useATR is true (default=14)
atrMultiplier (float): - Multiplier for ATR-based tolerance (default=1.0)
atrNormPeriod (int): - Period for ATR normalization (default=20)
enableBodyDetection (bool): - Enable all body-related detections (default=true)
enableWickDetection (bool): - Enable all wick-related detections (default=true)
enableHistoricalDetection (bool): - Enable detection using previous bar data (default=true)
ltf_delta (float)
Returns: 0 for body cross, -1 for touch from above, 1 for touch from below, na for no touch
릴리즈 노트
v35Added:
f_clamp(x, lo, hi)
Parameters:
x (float)
lo (float)
hi (float)
f_tf_ms(tf)
Parameters:
tf (string)
f_sess_part(sess, want_start)
Parameters:
sess (string)
want_start (bool)
f_hhmm_to_h(hhmm)
Parameters:
hhmm (string)
f_hhmm_to_m(hhmm)
Parameters:
hhmm (string)
f_session_tz(session_tz_sel)
Parameters:
session_tz_sel (string)
f_find_key(keys, key)
Parameters:
keys (array<int>)
key (int)
f_lower_bound(a, x)
Parameters:
a (array<int>)
x (int)
f_upper_bound(a, x)
Parameters:
a (array<int>)
x (int)
f_find_key_sorted(keys, key)
Parameters:
keys (array<int>)
key (int)
f_map_add4(m1, m2, m3, m4, k, d1, d2, d3, d4)
Parameters:
m1 (map<int, float>)
m2 (map<int, float>)
m3 (map<int, float>)
m4 (map<int, float>)
k (int)
d1 (float)
d2 (float)
d3 (float)
d4 (float)
f_get_by_key(keys, vals, key)
Parameters:
keys (array<int>)
vals (array<float>)
key (int)
f_add_to_map(keys, vals, key, delta)
Parameters:
keys (array<int>)
vals (array<float>)
key (int)
delta (float)
f_add_to_map2(keys, vals1, vals2, key, d1, d2)
Parameters:
keys (array<int>)
vals1 (array<float>)
vals2 (array<float>)
key (int)
d1 (float)
d2 (float)
f_add_to_map3(keys, vals1, vals2, vals3, key, d1, d2, d3)
Parameters:
keys (array<int>)
vals1 (array<float>)
vals2 (array<float>)
vals3 (array<float>)
key (int)
d1 (float)
d2 (float)
d3 (float)
f_add_to_map4(keys, v1, v2, v3, v4, key, d1, d2, d3, d4)
Parameters:
keys (array<int>)
v1 (array<float>)
v2 (array<float>)
v3 (array<float>)
v4 (array<float>)
key (int)
d1 (float)
d2 (float)
d3 (float)
d4 (float)
f_add_to_map2_sorted(keys, vals1, vals2, key, d1, d2)
Parameters:
keys (array<int>)
vals1 (array<float>)
vals2 (array<float>)
key (int)
d1 (float)
d2 (float)
f_merge_row_vols_dual(in_rows, in_vols, out_keys, out_vol, out_tpo)
Parameters:
in_rows (array<int>)
in_vols (array<float>)
out_keys (array<int>)
out_vol (array<float>)
out_tpo (array<float>)
f_prune_zero(keys, vals1, vals2)
Parameters:
keys (array<int>)
vals1 (array<float>)
vals2 (array<float>)
f_prune_zero3(keys, vals1, vals2, vals3)
Parameters:
keys (array<int>)
vals1 (array<float>)
vals2 (array<float>)
vals3 (array<float>)
f_prune_zero4(keys, v1, v2, v3, v4)
Parameters:
keys (array<int>)
v1 (array<float>)
v2 (array<float>)
v3 (array<float>)
v4 (array<float>)
f_min_max_key(keys)
Parameters:
keys (array<int>)
f_total(vals)
Parameters:
vals (array<float>)
릴리즈 노트
v36Added:
is_replay()
릴리즈 노트
v37릴리즈 노트
v38Added:
f_push_limited(arr, val, max_size)
Parameters:
arr (array<float>)
val (float)
max_size (int)
f_symbol_base(ticker_id)
Parameters:
ticker_id (string)
f_array_mean_stdev_tail(arr, len)
Parameters:
arr (array<float>)
len (int)
f_norm_cdf(x)
Parameters:
x (float)
f_kama(src, len, fast_len, slow_len)
Parameters:
src (float)
len (int)
fast_len (int)
slow_len (int)
f_zscore_standard(src, len)
Parameters:
src (float)
len (int)
f_corr_weighted_zscore(src_base, src_ext, len, corr_power)
Parameters:
src_base (float)
src_ext (float)
len (int)
corr_power (float)
f_cld(corr_osc, price, z_score, slope_thresh, cld_enable, cld_min_bars, cld_max_bars, cld_price_consist, cld_z_min)
Parameters:
corr_osc (float)
price (float)
z_score (float)
slope_thresh (float)
cld_enable (bool)
cld_min_bars (int)
cld_max_bars (int)
cld_price_consist (float)
cld_z_min (float)
릴리즈 노트
v39Added:
f_tail(arr, len)
Parameters:
arr (array<float>)
len (int)
f_kalman(src, gain)
Parameters:
src (float)
gain (float)
f_kalman_control(meas, control, reactivity)
Parameters:
meas (float)
control (float)
reactivity (float)
릴리즈 노트
v40Added:
f_winsorize(val, p2, p98)
Parameters:
val (float)
p2 (float)
p98 (float)
f_iqr_normalize(val, p25, p75)
Parameters:
val (float)
p25 (float)
p75 (float)
f_sgd_update_gated(current_param, gradient, learning_rate, param_min, param_max, coupling_damping, gate_thresh)
Parameters:
current_param (float)
gradient (float)
learning_rate (float)
param_min (float)
param_max (float)
coupling_damping (float)
gate_thresh (float)
f_kalman_robust(measurement, state, P, Q, R, innov_std, clip_sigma)
Parameters:
measurement (float)
state (float)
P (float)
Q (float)
R (float)
innov_std (float)
clip_sigma (float)
f_mr_vol_adjusted(mr_raw, atr_current, atr_baseline)
Parameters:
mr_raw (float)
atr_current (float)
atr_baseline (float)
f_ddivf_update(innov, prev_sigma, innov_hist, k)
Parameters:
innov (float)
prev_sigma (float)
innov_hist (array<float>)
k (int)
f_estimate_adaptive_Q(innov_hist, window, current_K, min_Q, max_Q)
Parameters:
innov_hist (array<float>)
window (int)
current_K (float)
min_Q (float)
max_Q (float)
f_update_percentile_cache(te_osc, mr_osc, vec_osc, corr_osc, ltf_corr, pred_slope, window)
Parameters:
te_osc (float)
mr_osc (float)
vec_osc (float)
corr_osc (float)
ltf_corr (float)
pred_slope (float)
window (int)
릴리즈 노트
v41Added:
f_basis_median_mad(src, basis_len)
Parameters:
src (float)
basis_len (int)
f_basis_vwma(src, vol, basis_len)
Parameters:
src (float)
vol (float)
basis_len (int)
2 tiny helper functions update.
릴리즈 노트
v42Added:
f_calc_survival_bands(basis, dev, shift_z, prob_pct, mr_shift)
Parameters:
basis (float)
dev (float)
shift_z (float)
prob_pct (float)
mr_shift (float)
릴리즈 노트
v43Added:
f_detect_squeeze(band_up, band_dn, price, damping, z_len)
Detects squeeze/bottleneck breakout conditions based on band width dynamics
Parameters:
band_up (float): Upper band price level
band_dn (float): Lower band price level
price (float): Current price for direction detection
damping (float): Correlation damping factor (0-1) for directional confirmation
z_len (int): Lookback length for band width percentile calculation
Returns: [squeeze_bull, squeeze_bear, final_squeeze_signal, bw_pct] Bullish squeeze, bearish squeeze, any squeeze signal, band width percentile
f_detect_confluence(basis, fv, dev, tol_mult, min_lines)
Detects confluence zones where multiple price levels cluster together
Parameters:
basis (float): Baseline MA price level
fv (float): Fair value (cyclic FV) price level
dev (float): Standard deviation for band multiples
tol_mult (float): ATR tolerance multiplier for clustering
min_lines (int): Minimum number of lines required to form a confluence cluster
Returns: bool Always returns true (draws confluence lines as side effect)
f_update_cusum(cusum_pos, cusum_neg, innovation, threshold, innov_abs_dev)
Updates CUSUM (Cumulative Sum) control chart for detecting persistent deviations
Parameters:
cusum_pos (float): Current positive CUSUM value
cusum_neg (float): Current negative CUSUM value
innovation (float): Current innovation/residual value
threshold (float): Threshold multiplier for CUSUM reset
innov_abs_dev (float): Absolute deviation of innovation for scaling
Returns: [new_cusum_pos, new_cusum_neg, cusum_triggered] Updated CUSUM values and trigger signal
f_detect_bounce_at_level(price, velocity, pressure, coupling, hist_price, price_momentum, bounce_thresh, lookback)
Detects bounce at a level (e.g., MA) after price was stretched away
Parameters:
price (float): Current price level (z-score or normalized position)
velocity (float): Trend velocity/momentum
pressure (float): External pressure (e.g., basket vector)
coupling (float): Coupling strength (e.g., correlation damping)
hist_price (float): Historical price level at lookback
price_momentum (float): Price momentum for resumption check
bounce_thresh (float): Threshold for "near level" detection
lookback (int): Lookback period for "was stretched" check
Returns: bool True if bounce condition detected
릴리즈 노트
v44릴리즈 노트
v45Added:
f_draw_tpsl(ep, tp1, tp2, sl, entry_bar, line_len, tp_col, sl_col, ep_col)
Parameters:
ep (float)
tp1 (float)
tp2 (float)
sl (float)
entry_bar (int)
line_len (int)
tp_col (color)
sl_col (color)
ep_col (color)
f_remove_tpsl(drawings)
Parameters:
drawings (TPSLDrawings)
TPSLDrawings
Fields:
ep_line (series line)
tp1_line (series line)
tp2_line (series line)
sl_line (series line)
릴리즈 노트
v46Added:
f_norm_system(enable_norm, te_val, mr_val, vec_val, corr_val, te_p25, te_p75, mr_p25, mr_p75, vec_p25, vec_p75, corr_p25, corr_p75, ltf_p20, ltf_p50, coupling_strong, coupling_weak, ltf_decouple_default, ltf_recouple_default, ltf_en, mr_vol_look)
5-layer regime-switched normalization system for adaptive thresholds
Parameters:
enable_norm (bool): Whether normalization is enabled
te_val (float): TE oscillator value
mr_val (float): Mean reversion oscillator value
vec_val (float): Vector oscillator value
corr_val (float): Correlation oscillator value
te_p25 (float): TE 25th percentile
te_p75 (float): TE 75th percentile
mr_p25 (float): MR 25th percentile
mr_p75 (float): MR 75th percentile
vec_p25 (float): Vector 25th percentile
vec_p75 (float): Vector 75th percentile
corr_p25 (float): Correlation 25th percentile
corr_p75 (float): Correlation 75th percentile
ltf_p20 (float): LTF 20th percentile
ltf_p50 (float): LTF 50th percentile
coupling_strong (float): Strong coupling threshold
coupling_weak (float): Weak coupling threshold
ltf_decouple_default (float): Default LTF decouple threshold
ltf_recouple_default (float): Default LTF recouple threshold
ltf_en (bool): Whether LTF is enabled
mr_vol_look (int): MR volatility lookback period
Returns: [coupling_regime, te_norm, mr_norm, vec_norm, corr_norm, te_effective, ltf_decouple_adaptive, ltf_recouple_adaptive, mr_vol_adj]
릴리즈 노트
v47Added:
f_tanh_norm(raw_z, y_offset, steepness, amplitude)
Tanh normalization for oscillator visual rendering
Parameters:
raw_z (float): Raw z-score or oscillator value
y_offset (float): Vertical offset (e.g., 0 for MR, -6 for TE/VEC/CORR/LTF)
steepness (float): Tanh steepness (0.5 for MR, 1.5 for TE, 0.75 for VEC/CORR/LTF)
amplitude (float): Visual amplitude (typically 3.0)
Returns: Visually scaled oscillator value: offset + tanh(raw_z × steepness) × amplitude
OscMeta
Oscillator metadata for unified rendering with configurable clipping
Fields:
id (series string): Short identifier ("MR", "TE", "VEC", "CORR", "LTF")
full_name (series string): Full name for tooltip header
explanation (series string): Tooltip body text explaining the oscillator
y_offset (series float): Vertical offset for plot positioning (e.g., -6.0 for VEC/CORR, 0.0 for MR/TE)
plot_scale (series float): Scale multiplier for plot output (e.g., 3.0 for tanh range)
z_clip_lo (series float): Lower bound for hard clipping (e.g., -3.0)
z_clip_hi (series float): Upper bound for hard clipping (e.g., 3.0)
clip_method (series string): Clipping method: "tanh" | "sigmoid" | "clamp" | "none"
clip_steepness (series float): Steepness parameter (0.75 for tanh, 10.0 for sigmoid, na for clamp)
clip_raw_value (series bool): If true, clip raw z-score before kNN/MC; if false, clip only visual output
should_display (series bool): Whether to display this oscillator (input toggle)
bull_color (series color): Color for positive values
bear_color (series color): Color for negative values
Updated:
f_tanh(x)
Hyperbolic tangent for soft symmetric clipping to [-1, 1]
Parameters:
x (float): Input value
Returns: tanh(x) bounded to [-1, 1]
f_sigmoid_norm(x, steepness)
Sigmoid normalization to [0, 1] with configurable steepness
Parameters:
x (float): Input value
steepness (float): Steepness parameter (default 2.0)
Returns: Sigmoid-normalized value in [0, 1]
f_iqr_normalize(val, p25, p75)
IQR normalization using 25th and 75th percentiles
Parameters:
val (float): Value to normalize
p25 (float): 25th percentile
p75 (float): 75th percentile
Returns: IQR-normalized value
릴리즈 노트
v48Added:
f_layout_subpanes(panes, panetop, panebottom, gappct)
Layout subpanes: compute Y ranges with gap support
Parameters:
panes (array<SubPane>): array<SubPane> to layout
panetop (float): Top Y coordinate of entire oscillator area
panebottom (float): Bottom Y coordinate of entire oscillator area
gappct (float): Gap between subpanes as percentage of total range (e.g., 0.10 = 10%)
f_update_visibility(panes, oscs)
Update subpane visibility: true if ANY child osc should_display
Parameters:
panes (array<SubPane>): array<SubPane> to update
oscs (array<OscMeta>): array<OscMeta> children
f_manage_subpane_lines(panes)
Manage subpane hlines: create/destroy based on visibility
Parameters:
panes (array<SubPane>): array<SubPane> to manage
f_process_oscs(panes, oscs, states, rawvalues)
Process oscillators: compute visualvalue and rawclipped for all oscs
Parameters:
panes (array<SubPane>): array<SubPane> parent containers
oscs (array<OscMeta>): array<OscMeta> oscillator configs (read-only)
states (array<OscState>): array<OscState> oscillator states (written)
rawvalues (array<float>): array<float> raw z-score values (same order as oscs)
f_manage_labels(oscs, states, labeloffset)
Manage oscillator labels: render end-of-chart value labels
Parameters:
oscs (array<OscMeta>): array<OscMeta> oscillator configs (read-only)
states (array<OscState>): array<OscState> oscillator states (written)
labeloffset (int): Horizontal offset for labels (e.g., 3)
f_register_osc(oscs, states, id, fullname, explanation, subpaneidx, zcliplo, zcliphi, clipmethod, clipsteepness, cliprawvalue, enabled, shoulddisplay, bullcol, bearcol)
Register oscillator: push OscMeta + blank OscState in one call
Parameters:
oscs (array<OscMeta>): array<OscMeta> to append to
states (array<OscState>): array<OscState> to append to
id (string)
fullname (string)
explanation (string)
subpaneidx (int)
zcliplo (float)
zcliphi (float)
clipmethod (string)
clipsteepness (float)
cliprawvalue (bool)
enabled (bool)
shoulddisplay (bool)
bullcol (color)
bearcol (color)
SubPane
SubPane layout container - owns Y-coordinates and hlines for a group of oscillators
Fields:
index (series int): Layout order (0=top, 1=middle, 2=bottom)
id (series string): Debug identifier ("MAIN", "CORR")
yoffset (series float): Auto-computed center Y coordinate
plotscale (series float): Auto-computed half-height (amplitude)
ytop (series float): Auto-computed top boundary
ybottom (series float): Auto-computed bottom boundary
visible (series bool): True if ANY child oscillator shoulddisplay
hlinetop (series line): Managed top boundary line
hlinebottom (series line): Managed bottom boundary line
hlinezero (series line): Managed center line
bordercolor (series color): Color for top/bottom lines
zerocolor (series color): Color for center line
OscState
Oscillator runtime state - MUTABLE per-bar state
Fields:
visualvalue (series float): OUTPUT: plot-ready Y coordinate in parent subpane
rawclipped (series float): OUTPUT: clipped raw value for kNN/MC
rawvalue (series float): INPUT: unprocessed raw value (diagnostic)
lbl (series label): Managed end-of-chart label reference
tooltiptext (series string): Full tooltip (static header + live value)
Updated:
OscMeta
Oscillator metadata - IMMUTABLE config after barstate.isfirst
Fields:
id (series string): Short identifier ("MR", "TE", "VEC", "CORR", "LTF")
full_name (series string): Full name for tooltip header
explanation (series string): Tooltip body text (static part, built once)
subpaneidx (series int): Index into array<SubPane> for parent layout
z_clip_lo (series float): Lower bound for raw clipping (e.g., -3.0)
z_clip_hi (series float): Upper bound for raw clipping (e.g., 3.0)
clip_method (series string): Clipping method: "tanh" | "sigmoid" | "clamp" | "none"
clip_steepness (series float): Steepness parameter (0.5 MR, 1.5 TE, 0.75 others)
clip_raw_value (series bool): If true, clip raw z-score for kNN/MC; if false, clip only visual
enabled (series bool): Computation runs (input toggle)
should_display (series bool): Visual plot visible (enabled AND visual toggle)
bull_color (series color): Color for positive values
bear_color (series color): Color for negative values
릴리즈 노트
v49Added:
f_percentile_rank_fisher(raw, window)
Stable percentile-rank normalization with Fisher transform
description Converts raw values to time-invariant normalized features using ordinal ranking.
Eliminates temporal drift from rolling z-scores by using percentile position,
then applies Fisher/logit transform to produce Gaussian-like distribution.
Parameters:
raw (float): Raw input value to normalize
window (int): Lookback window for percentile calculation (e.g., 200)
Returns: Normalized value in approximate range [-2.65, +2.65] with Gaussian shape
note Output is time-invariant: percentile 85 two weeks ago = percentile 85 now
note Ideal for kNN distance calculations where temporal consistency is critical
릴리즈 노트
v50Added:
f_subpane_new(index, id, yoffset, plotscale, ytop, ybottom, visible, hlinetop, hlinebottom, hlinezero, bordercolor, zerocolor)
Parameters:
index (int): Layout order (0=top, 1=middle, 2=bottom)
id (string): Debug identifier ("MAIN", "CORR")
yoffset (float): Auto-computed center Y coordinate
plotscale (float): Auto-computed half-height (amplitude)
ytop (float): Auto-computed top boundary
ybottom (float): Auto-computed bottom boundary
visible (bool): True if ANY child oscillator shoulddisplay
hlinetop (line): Managed top boundary line
hlinebottom (line): Managed bottom boundary line
hlinezero (line): Managed center line
bordercolor (color): Color for top/bottom lines
zerocolor (color): Color for center line
릴리즈 노트
v51Added:
f_apply_softclip(rawz, method, steep, zlo, zhi)
Private: apply softclip to [-1, +1]
Parameters:
rawz (float): Raw z-score value
method (string): "tanh" | "sigmoid" | "clamp" | "none"
steep (float): Steepness parameter
zlo (float): Lower clip bound
zhi (float): Upper clip bound
Returns: Clipped value in [-1, +1]
f_manage_osc_values(panes, oscs, states, rawvalues)
Main per-bar manager: compute visualvalue and rawclipped for all oscs
Parameters:
panes (array<SubPane>): array<SubPane> parent containers
oscs (array<OscMeta>): array<OscMeta> oscillators
states (array<OscState>): array<OscState> oscillator states (written)
rawvalues (array<float>): array<float> raw z-score values (same order as oscs)
Updated:
f_manage_subpane_lines(panes)
Parameters:
panes (array<SubPane>)
릴리즈 노트
v52Added:
f_subpane_ctor(index, id, yoffset, plotscale, ytop, ybottom, visible, hlinetop, hlinebottom, hlinezero, bordercolor, zerocolor)
Parameters:
index (int)
id (string)
yoffset (float)
plotscale (float)
ytop (float)
ybottom (float)
visible (bool)
hlinetop (line)
hlinebottom (line)
hlinezero (line)
bordercolor (color)
zerocolor (color)
f_update_osc_ob_os_lines(panes, oscs, states, ob_values, os_values, ob_color, os_color)
Update overbought/oversold boundary lines for oscillators using line.new()
Parameters:
panes (array<SubPane>): array<SubPane> parent containers
oscs (array<OscMeta>): array<OscMeta> oscillator configs
states (array<OscState>): array<OscState> oscillator states (written)
ob_values (array<float>): array<float> raw overbought values per oscillator (na = skip)
os_values (array<float>): array<float> raw oversold values per oscillator (na = skip)
ob_color (color): Color for overbought line
os_color (color): Color for oversold line
Updated:
f_subpane_new(index, id, yoffset, plotscale, ytop, ybottom, visible, hlinetop, hlinebottom, hlinezero, bordercolor, zerocolor)
Factory method to create SubPane instances
Parameters:
index (int): Layout order (0=top, 1=middle, 2=bottom)
id (string): Debug identifier ("MAIN", "CORR")
yoffset (float): Auto-computed center Y coordinate
plotscale (float): Auto-computed half-height (amplitude)
ytop (float): Auto-computed top boundary
ybottom (float): Auto-computed bottom boundary
visible (bool): True if ANY child oscillator shoulddisplay
hlinetop (line): Managed top boundary line
hlinebottom (line): Managed bottom boundary line
hlinezero (line): Managed center line
bordercolor (color): Color for top/bottom lines
zerocolor (color): Color for center line
OscState
Oscillator runtime state - MUTABLE per-bar state
Fields:
visualvalue (series float): OUTPUT: plot-ready Y coordinate in parent subpane
rawclipped (series float): OUTPUT: clipped raw value for kNN/MC
rawvalue (series float): INPUT: unprocessed raw value (diagnostic)
lbl (series label): Managed end-of-chart label reference
tooltiptext (series string): Full tooltip (static header + live value)
ob_line (series line): Managed overbought boundary line reference
os_line (series line): Managed oversold boundary line reference
릴리즈 노트
v53Added:
f_hurst_rs(log_ret_buf)
Parameters:
log_ret_buf (array<float>): Pre-filled array of log-returns
Returns: float H ∈ [0.1, 0.9] (0.5 = random walk, <0.5 = anti-persistent)
f_phi_divergence_score(phi_latch, phi_orth, div_len, accel_len)
Parameters:
phi_latch (float): PhiLatch oscillator value (series float)
phi_orth (float): PhiTotalOrth oscillator value (series float)
div_len (int): Lookback for divergence slope (default 5)
accel_len (simple int): Smoothing for acceleration signal (default 3)
Returns: [phi_div_score, phi_diverg_start, phi_spread, phi_accel]
phi_div_score float [0..1] — composite divergence intensity
phi_diverg_start bool — first bar of new divergence onset
phi_spread float — current |PhiLatch - PhiOrth|
phi_accel float — d(phi_spread)/dt smoothed
f_squeeze_state(innov_upper, innov_lower, z3_up, z3_dn, hurst_exp, ltf_at_extreme, burst_pct_high, bwv_len, bwz_len, bwv_sq_thresh, bwv_ex_thresh, arm_thresh, cooldown_bars, prev_armed, prev_arm_bar, prev_cooldown_bar, prev_low_counter, phi_div_score, phi_onset, mahal_dist, mahal_arm_thresh)
Parameters:
innov_upper (float): / innov_lower Current bar Innovation Band prices
innov_lower (float)
z3_up (float): / z3_dn Current bar Z3 Survival Band prices
z3_dn (float)
hurst_exp (float): H from f_hurst_rs
ltf_at_extreme (bool): bool: LTF osc at extreme (reactive confirm #1)
burst_pct_high (bool): bool: burst_pct > 0.80 (reactive confirm #2)
bwv_len (int): Lookback for velocity (default 3)
bwz_len (int): History length for BW z-score (default 100)
bwv_sq_thresh (float): Squeeze velocity threshold (default 0.03)
bwv_ex_thresh (float): Expansion velocity threshold (default 0.02)
arm_thresh (float): Squeeze_score to arm (default 0.55)
cooldown_bars (int): Bars between fires (default 8)
prev_armed (bool): / prev_arm_bar / prev_cooldown_bar / prev_low_counter
Previous state vars from caller
prev_arm_bar (int)
prev_cooldown_bar (int)
prev_low_counter (int)
phi_div_score (float): [0..1] from f_phi_divergence_score
phi_onset (bool): bool from f_phi_divergence_score
mahal_dist (float): Mahalanobis distance from BandsLib.f_mahalanobis_4x4
mahal_arm_thresh (float): Threshold for mahal_armed gate (default 1.5)
Returns: [SqzState, new_armed, new_arm_bar, new_cooldown_bar, new_low_counter]
SqzState
Fields:
score (series float)
innov_bwv (series float)
z3_bwv (series float)
innov_bwz (series float)
z3_bwz (series float)
hurst (series float)
armed (series bool)
active (series bool)
sq_expanding (series bool)
phi_div_score (series float)
phi_onset (series bool)
mahal_dist (series float)
mahal_armed (series bool)
릴리즈 노트
v54Added:
f_kalman_matrix_update(X, P, Z, F, H, Q, R)
Matrix-based Kalman Filter Update
Parameters:
X (matrix<float>): Current state vector (Nx1 matrix)
P (matrix<float>): Current covariance matrix (NxN matrix)
Z (matrix<float>): Measurement vector (Mx1 matrix)
F (matrix<float>): State transition matrix (NxN matrix)
H (matrix<float>): Measurement mapping matrix (MxN matrix)
Q (matrix<float>): Process noise covariance matrix (NxN matrix)
R (matrix<float>): Measurement noise covariance matrix (MxM matrix)
Returns: [X_new, P_new] Updated state and covariance matrices
릴리즈 노트
v55Updated:
SubPane
SubPane layout container - owns Y-coordinates and hlines for a group of oscillators
Fields:
index (series int): Layout order (0=top, 1=middle, 2=bottom)
id (series string): Debug identifier ("MAIN", "CORR")
yoffset (series float): Visual center Y coordinate (for plot mapping ONLY, does NOT affect logic)
plotscale (series float): Visual half-height amplitude (for plot mapping ONLY, does NOT affect logic)
ytop (series float): Auto-computed top boundary
ybottom (series float): Auto-computed bottom boundary
visible (series bool): True if ANY child oscillator should display
hlinetop (series line): Managed top boundary line
hlinebottom (series line): Managed bottom boundary line
hlinezero (series line): Managed center line
bordercolor (series color): Color for top/bottom lines
zerocolor (series color): Color for center line
릴리즈 노트
v56Added:
f_reversal_osc(s, v, p, q, tau)
Reversal Oscillator - Unified formula for mean-reversion signals
Parameters:
s (float): Normalized extreme oscillator (z-score, recentered RSI, etc.) in [-1, 1]
v (float): Velocity of s (e.g., EMA(Δs, 3-5))
p (float): Edge sensitivity curvature (1.0-1.5, higher = sharper response at extremes)
q (float): Mean-reversion damping speed (0.5-1.0, higher = faster decay to center)
tau (float): Velocity scale (σ_v over last 20 bars, typical)
Returns: Reversal signal x: bull extreme → x > 0 signals reversal down, bear extreme → x < 0 signals reversal up
description Combines 4 approaches: (1) -sign(s) inverts so bull extreme → positive signal, (2) |s|^p amplifies edges, (3) (1-|s|^q) nullifies center, (4) sigm(-v/τ) adds confidence only when impulse is already against the extreme
릴리즈 노트
v57Added:
f_savgol_21_3(src)
Savitzky-Golay filter (21-bar window, 3rd order polynomial) - CAUSAL version
Parameters:
src (float): Source series to smooth
Returns: Smoothed value using causal SavGol-21-3 coefficients
description Applies a 21-bar Savitzky-Golay filter with 3rd order polynomial fit.
Coefficients computed via least squares at k=0 (current bar). Sum = 1.0 for unity gain.
Returns unfiltered value for first 20 bars (warmup period).
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.