PINE LIBRARY
已更新 KTUtils

Library "KTUtils"
Utility functions for technical analysis indicators, trend detection, and volatility confirmation.
MGz(close, length)
MGz
description Moving average smoother used for signal processing
Parameters:
close (float): float Price input (typically close)
length (int): int Length of smoothing period
Returns: float Smoothed value
atrConf(length)
atrConf
description Calculates Average True Range (ATR) for volatility confirmation
Parameters:
length (simple int): int Length for ATR calculation
Returns: float ATR value
f(input)
f
description Simple Moving Average with fixed length
Parameters:
input (float): float Input value
Returns: float Smoothed average
bcwSMA(s, l, m)
bcwSMA
description Custom smoothing function with weight multiplier
Parameters:
s (float): float Signal value
l (int): int Length of smoothing
m (int): int Weighting multiplier
Returns: float Smoothed output
MGxx(close, length)
MGxx
description Custom Weighted Moving Average (WMA) variant
Parameters:
close (float): float Price input
length (int): int Period length
Returns: float MGxx smoothed output
_PerChange(lengthTime)
_PerChange
description Measures percentage price change over a period and range deviation
Parameters:
lengthTime (int): int Period for change measurement
Returns: tuple<float,float,float> Measured change, high deviation, low deviation
dirmov(len)
dirmov
description Calculates directional movement components
Parameters:
len (simple int): int Lookback period
Returns: tuple<float,float> Plus and Minus DI values
adx(dilen, adxlen)
adx
description Calculates Average Directional Index (ADX)
Parameters:
dilen (simple int): int Length for DI calculation
adxlen (simple int): int Length for ADX smoothing
Returns: float ADX value
trChopAnalysis()
trChopAnalysis
description Identifies chop and trend phases based on True Range Bollinger Bands
Returns: tuple<float,bool,bool> TR SMA, chop state, trending state
wtiAnalysis(haclose, close, filterValue)
wtiAnalysis
description Wave Trend Indicator (WTI) with signal crossover logic
Parameters:
haclose (float): float Heikin-Ashi close
close (float): float Standard close
filterValue (simple int): int Smoothing length
Returns: tuple<float,float,bool,bool> WTI lines and direction states
basicTrend(hahigh, halow, close, open, filterValue)
basicTrend
description Determines trend direction based on HA high/low and close
Parameters:
hahigh (float): float Heikin-Ashi high
halow (float): float Heikin-Ashi low
close (float): float Standard close
open (float): float Standard open
filterValue (simple int): int Smoothing period
Returns: tuple<bool,bool> Uptrend, downtrend flags
metrics(close, filterValue)
metrics
description Common market metrics
Parameters:
close (float): float Price input
filterValue (int): int RSI smoothing length
Returns: tuple<float,float,float,float> VWMA, SMA10, RSI, smoothed RSI
piff(close, trend_change)
piff
description Price-Informed Forward Forecasting (PIFF) model for trend strength
Parameters:
close (float): float Price input
trend_change (float): float Change in trend
Returns: tuple<float,float,bool,bool,bool,bool> Percent change, flags for trend direction
getMACD()
getMACD
description Returns MACD, signal line, and histogram
Returns: tuple<float,float,float> MACD line, Signal line, Histogram
getStoch()
getStoch
description Returns K and D lines of Stochastic Oscillator
Returns: tuple<float,float> K and D lines
getKDJ()
getKDJ
description KDJ momentum oscillator
Returns: tuple<float,float,float,float> K, D, J, Average
getBBRatio()
getBBRatio
description Bollinger Band Ratio (BBR) and signal flags
Returns: tuple<float,float,float,float,bool,bool> Basis, Upper, Lower, BBR, BBR Up, BBR Down
getSupertrend()
getSupertrend
description Supertrend values and direction flags
Returns: tuple<float,int,bool,bool> Supertrend, Direction, Up, Down
Utility functions for technical analysis indicators, trend detection, and volatility confirmation.
MGz(close, length)
MGz
description Moving average smoother used for signal processing
Parameters:
close (float): float Price input (typically close)
length (int): int Length of smoothing period
Returns: float Smoothed value
atrConf(length)
atrConf
description Calculates Average True Range (ATR) for volatility confirmation
Parameters:
length (simple int): int Length for ATR calculation
Returns: float ATR value
f(input)
f
description Simple Moving Average with fixed length
Parameters:
input (float): float Input value
Returns: float Smoothed average
bcwSMA(s, l, m)
bcwSMA
description Custom smoothing function with weight multiplier
Parameters:
s (float): float Signal value
l (int): int Length of smoothing
m (int): int Weighting multiplier
Returns: float Smoothed output
MGxx(close, length)
MGxx
description Custom Weighted Moving Average (WMA) variant
Parameters:
close (float): float Price input
length (int): int Period length
Returns: float MGxx smoothed output
_PerChange(lengthTime)
_PerChange
description Measures percentage price change over a period and range deviation
Parameters:
lengthTime (int): int Period for change measurement
Returns: tuple<float,float,float> Measured change, high deviation, low deviation
dirmov(len)
dirmov
description Calculates directional movement components
Parameters:
len (simple int): int Lookback period
Returns: tuple<float,float> Plus and Minus DI values
adx(dilen, adxlen)
adx
description Calculates Average Directional Index (ADX)
Parameters:
dilen (simple int): int Length for DI calculation
adxlen (simple int): int Length for ADX smoothing
Returns: float ADX value
trChopAnalysis()
trChopAnalysis
description Identifies chop and trend phases based on True Range Bollinger Bands
Returns: tuple<float,bool,bool> TR SMA, chop state, trending state
wtiAnalysis(haclose, close, filterValue)
wtiAnalysis
description Wave Trend Indicator (WTI) with signal crossover logic
Parameters:
haclose (float): float Heikin-Ashi close
close (float): float Standard close
filterValue (simple int): int Smoothing length
Returns: tuple<float,float,bool,bool> WTI lines and direction states
basicTrend(hahigh, halow, close, open, filterValue)
basicTrend
description Determines trend direction based on HA high/low and close
Parameters:
hahigh (float): float Heikin-Ashi high
halow (float): float Heikin-Ashi low
close (float): float Standard close
open (float): float Standard open
filterValue (simple int): int Smoothing period
Returns: tuple<bool,bool> Uptrend, downtrend flags
metrics(close, filterValue)
metrics
description Common market metrics
Parameters:
close (float): float Price input
filterValue (int): int RSI smoothing length
Returns: tuple<float,float,float,float> VWMA, SMA10, RSI, smoothed RSI
piff(close, trend_change)
piff
description Price-Informed Forward Forecasting (PIFF) model for trend strength
Parameters:
close (float): float Price input
trend_change (float): float Change in trend
Returns: tuple<float,float,bool,bool,bool,bool> Percent change, flags for trend direction
getMACD()
getMACD
description Returns MACD, signal line, and histogram
Returns: tuple<float,float,float> MACD line, Signal line, Histogram
getStoch()
getStoch
description Returns K and D lines of Stochastic Oscillator
Returns: tuple<float,float> K and D lines
getKDJ()
getKDJ
description KDJ momentum oscillator
Returns: tuple<float,float,float,float> K, D, J, Average
getBBRatio()
getBBRatio
description Bollinger Band Ratio (BBR) and signal flags
Returns: tuple<float,float,float,float,bool,bool> Basis, Upper, Lower, BBR, BBR Up, BBR Down
getSupertrend()
getSupertrend
description Supertrend values and direction flags
Returns: tuple<float,int,bool,bool> Supertrend, Direction, Up, Down
發行說明
v2Added:
getPivots(filterValue)
getPivots
description Calculates pivot highs and lows for swing detection
Parameters:
filterValue (int): int Lookback/lookahead length for pivot detection
Returns: tuple<float,float> Pivot high, Pivot low (na when no pivot detected)
emaEma(source, length)
emaEma
description Double EMA smoothing (EMA of EMA)
Parameters:
source (float): float Input source
length (simple int): int EMA length
Returns: float Double-smoothed EMA value
getSMI(lengthK, lengthD, lengthEMA)
getSMI
description Stochastic Momentum Index with signal line
Parameters:
lengthK (int): int %K length for highest/lowest calculation
lengthD (simple int): int %D length for EMA smoothing
lengthEMA (simple int): int Signal line EMA length
Returns: tuple<float,float,bool,bool> SMI value, SMI signal line, bullish flag, bearish flag
發行說明
v3Added:
getHighLowPoints(pointLength)
getHighLowPoints
description Detects highest high and lowest low points over a specified lookback period
Parameters:
pointLength (int): int Lookback period for high/low detection
Returns: tuple<Point,Point> Lowest point, Highest point (may be na if not detected on current bar)
drawHighLowPoints(pointLength, showLabels, showLines, lowColor, highColor, transparency)
drawHighLowPoints
description Draws labels and lines for highest high and lowest low points with automatic cleanup
Parameters:
pointLength (int): int Lookback period for high/low detection
showLabels (bool): bool Display price labels on points
showLines (bool): bool Display horizontal lines extending from points
lowColor (color): color Color for low point markers (default: green)
highColor (color): color Color for high point markers (default: maroon)
transparency (int): int Transparency level 0-100 (default: 50)
Returns: tuple<label,line,label,line> Low label, Low line, High label, High line
Point
Point data structure for chart coordinates
Fields:
index (series int): The bar index (x coordinate) where the point is located
price (series float): The price level (y coordinate) where the point is located
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
Eric Thies
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
Eric Thies
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。