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
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。