PINE LIBRARY

lib_kernel

Library "lib_kernel"
Library "lib_kernel"

This is a tool / library for developers, that contains several common and adapted kernel functions as well as a kernel regression function and enum to easily select and embed a list into the settings dialog.

How to Choose and Modify Kernels in Practice
  • Compact Support Kernels (e.g., Epanechnikov, Triangular): Use for localized smoothing and emphasizing nearby data.
  • Oscillatory Kernels (e.g., Wave, Cosine): Ideal for detecting periodic patterns or mean-reverting behavior.
  • Smooth Tapering Kernels (e.g., Gaussian, Logistic): Use for smoothing long-term trends or identifying global price behavior.


kernel_Epanechnikov(u)
  Parameters:
    u (float)

kernel_Epanechnikov_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel_Triangular(u)
  Parameters:
    u (float)

kernel_Triangular_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel_Rectangular(u)
  Parameters:
    u (float)

kernel_Uniform(u)
  Parameters:
    u (float)

kernel_Uniform_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel_Logistic(u)
  Parameters:
    u (float)

kernel_Logistic_alt(u)
  Parameters:
    u (float)

kernel_Logistic_alt2(u, sigmoid_steepness)
  Parameters:
    u (float)
    sigmoid_steepness (float)

kernel_Gaussian(u)
  Parameters:
    u (float)

kernel_Gaussian_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel_Silverman(u)
  Parameters:
    u (float)

kernel_Quartic(u)
  Parameters:
    u (float)

kernel_Quartic_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel_Biweight(u)
  Parameters:
    u (float)

kernel_Triweight(u)
  Parameters:
    u (float)

kernel_Sinc(u)
  Parameters:
    u (float)

kernel_Wave(u)
  Parameters:
    u (float)

kernel_Wave_alt(u)
  Parameters:
    u (float)

kernel_Cosine(u)
  Parameters:
    u (float)

kernel_Cosine_alt(u, sensitivity)
  Parameters:
    u (float)
    sensitivity (float)

kernel(u, select, alt_modificator)
  wrapper for all standard kernel functions, see enum Kernel comments and function descriptions for usage szenarios and parameters
  Parameters:
    u (float)
    select (series Kernel)
    alt_modificator (float)

kernel_regression(src, bandwidth, kernel, exponential_distance, alt_modificator)
  wrapper for kernel regression with all standard kernel functions, see enum Kernel comments for usage szenarios. performance optimized version using fixed bandwidth and target
  Parameters:
    src (float): input data series
    bandwidth (simple int): sample window of nearest neighbours for the kernel to process
    kernel (simple Kernel): type of Kernel to use for processing, see Kernel enum or respective functions for more details
    exponential_distance (simple bool): if true this puts more emphasis on local / more recent values
    alt_modificator (float): see kernel functions for parameter descriptions. Mostly used to pronounce emphasis on local values or introduce a decay/dampening to the kernel output
MATHstatisticstoolkit

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.

Disclaimer