PINE LIBRARY
Cập nhật TrendPivots

Library "TrendPivots"
This library provides functions to search for bullish and bearish divergences between pivots and indicators. Functions search for higher highs and lower lows, automating lines, labels and signals for technical analysis and strategies.
method maxBeforeLast(id)
Method function to get the maximum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint
method minBeforeLast(id)
Method function to get the minimum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint
method pivotLine(id, a, b, color)
Sets the coordinates of a given line using two pivotPoint variables.
Namespace types: series line
Parameters:
id (line): (line) Existing line
a (pivotPoint): (pivotPoint) First pivotPoint.
b (pivotPoint): (pivotPoint) Second pivotPoint.
color (color): (color) The desired color. Default is red.
Returns: void
bearishDivergence(pivotArray)
Look for bearish divergence in a pivotPoint array cointaining pivot highs.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: bool True if bearish divergence was found.
bullishDivergence(pivotArray)
Look for bullish divergence in a pivotPoint array cointaining pivot lows.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: bool True if bullish divergence was found.
uptrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects higher highs, higher lows and bearish divergence in an uptrend. Creates a line when bearish divergence is found, and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to higher highs and for each pivot low. Default = true.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [pH_point, pL_point, lowerLow, lowerHigh, bullish_divergence]
downtrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects lower lows, lower highs, and bullish divergence in a downtrend. Creates a line when bullish divergence is found, and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to lower lows, and for each pivot low.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [pH_point, pL_point, lowerLow, lowerHigh, bullish_divergence]
pivotPoint
The coordinates of a pivot point and corresponding indicator value.
Fields:
x (series int): (int) Time.
y (series float): (float) Price.
indicator (series float): (float) Indicator value.
This library provides functions to search for bullish and bearish divergences between pivots and indicators. Functions search for higher highs and lower lows, automating lines, labels and signals for technical analysis and strategies.
method maxBeforeLast(id)
Method function to get the maximum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint
method minBeforeLast(id)
Method function to get the minimum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint
method pivotLine(id, a, b, color)
Sets the coordinates of a given line using two pivotPoint variables.
Namespace types: series line
Parameters:
id (line): (line) Existing line
a (pivotPoint): (pivotPoint) First pivotPoint.
b (pivotPoint): (pivotPoint) Second pivotPoint.
color (color): (color) The desired color. Default is red.
Returns: void
bearishDivergence(pivotArray)
Look for bearish divergence in a pivotPoint array cointaining pivot highs.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: bool True if bearish divergence was found.
bullishDivergence(pivotArray)
Look for bullish divergence in a pivotPoint array cointaining pivot lows.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: bool True if bullish divergence was found.
uptrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects higher highs, higher lows and bearish divergence in an uptrend. Creates a line when bearish divergence is found, and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to higher highs and for each pivot low. Default = true.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [pH_point, pL_point, lowerLow, lowerHigh, bullish_divergence]
downtrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects lower lows, lower highs, and bullish divergence in a downtrend. Creates a line when bullish divergence is found, and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to lower lows, and for each pivot low.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [pH_point, pL_point, lowerLow, lowerHigh, bullish_divergence]
pivotPoint
The coordinates of a pivot point and corresponding indicator value.
Fields:
x (series int): (int) Time.
y (series float): (float) Price.
indicator (series float): (float) Indicator value.
Phát hành các Ghi chú
v2Updated:
uptrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects higher highs, higher lows and bearish divergence in an uptrend. Creates a line when bearish divergence is found, and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to higher highs and for each pivot low. Default = true.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [pH_point, pL_point, higherHigh, higherLow, bearish_divergence]
Phát hành các Ghi chú
v3Adds more information to functions;
Changes in uptrendPivot() and downtrendPivot() function:
- Returned pivotPoints changed from series to var to retain values;
- Traces lines every higher high pivot (red = bearish divergence in uptrendPivot());
- Traces lines every lower low pivot (green = bullish divergence in downtrendPivot()).
- Adds indicator values in labels.
Updated:
method maxBeforeLast(id)
Method function to get the maximum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint The last higher high pivot coordinates and indicator before current.
method minBeforeLast(id)
Method function to get the minimum price before the last, stored in an array pivotPoint.
Namespace types: pivotPoint[]
Parameters:
id (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: pivotPoint The last lower low pivot coordinates and indicator before current.
bearishDivergence(pivotArray)
Look for bearish divergence in a pivotPoint array cointaining pivot highs.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: series bool True if bearish divergence was found.
bullishDivergence(pivotArray)
Look for bullish divergence in a pivotPoint array cointaining pivot lows.
Parameters:
pivotArray (pivotPoint[]): (array pivotPoint) The pivotPoint array to inspect.
Returns: series bool True if bullish divergence was found.
uptrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects higher highs, higher lows and bearish divergence in an uptrend. Creates a line linking two pivot highs (red when bearish divergence, otherwise green), and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to higher highs and for each pivot low. Default = true.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [var pivotPoint pH_point, var pivotPoint pL_point, series bool higherHigh, series bool higherLow, series bool bearish_divergence] -> The most recent higher high pivot, the most recent pivot low, true when higher high, true when higher low, true when bearish divergence.
downtrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects lower lows, lower highs, and bullish divergence in a downtrend. Creates a line linking two pivot lows (green when bullish divergence, otherwise red), and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to lower lows, and for each pivot low.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [var pivotPoint pH_point, var pivotPoint pL_point, series bool lowerLow, series bool lowerHigh, series bool bullish_divergence] -> The most recent lower low pivot, the most recent pivot high, true if lower low, true if lower high, true when bullish divergence.
Phát hành các Ghi chú
v4Updated:
downtrendPivot(leftBars, rightBars, indicator, reset, plotLabel, plotLine)
Detects lower lows, lower highs, and bullish divergence in a downtrend. Creates a line linking two pivot lows (green when bullish divergence, otherwise red), and labels.
Parameters:
leftBars (int): (int)
rightBars (int): (int)
indicator (float): (float) RSI, MACD or other value.
reset (bool): (bool) A bool variable to reinitiates the pivot computation, such as time changes, crossovers, or another.
plotLabel (bool): (bool) If true (default), plots labels to lower lows, and for each pivot low.
plotLine (bool): (bool) If true (default), plots a line linking the lower lows with divergence. Default = true.
Returns: [var pivotPoint pL_point, var pivotPoint pH_point, series bool lowerLow, series bool lowerHigh, series bool bullish_divergence] -> The most recent lower low pivot, the most recent pivot high, true if lower low, true if lower high, true when bullish divergence.
Phát hành các Ghi chú
v5Bug fix on pivotHigh labels in downtrendPivot() function.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.