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
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
Eric Thies
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
Eric Thies
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。