PINE LIBRARY
מעודכן

TAUtilityLib

96
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
הערות שחרור
v2

Added:
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
הערות שחרור
v3

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)
    chart_level (float)
  Returns: Scaled version of secondary_line, with chart vertical offset
הערות שחרור
v4

Added:
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
הערות שחרור
v5

Added:
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

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.