PINE LIBRARY
mZigzag

Library "mZigzag"
Matrix implementation of zigzag to allow further possibilities.
Main advantage of this library over previous zigzag methods is that you can attach any number of indicator/oscillator information to zigzag
calculate(length, ohlc, indicatorHigh, indicatorLow, numberOfPivots, supertrendLength)
calculates zigzag and related information
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
supertrendLength (simple int): is number of pivot history to calculate supertrend
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
supertrendDir is direction of zigzag based supertrend
supertrend is supertrend value of zigzag based supertrend
newZG is true if a new pivot is added to array
doubleZG is true if last calculation returned two new pivots (Happens on extreme price change)
calculateplain(length, ohlc, indicatorHigh, indicatorLow, numberOfPivots, offset)
calculates zigzag and related information uses shift/unshift rather than pop and push. Also does not calculate divergence and ratios.
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
offset (simple int)
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionArray Matrix containing direction of price and indicator values at pivots
barArray Array containing pivot bars
newZG is true if a new pivot is added to array
doubleZG is true if last calculation returned two new pivots (Happens on extreme price change)
draw(valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, newZG, doubleZG, indicatorLabels, lineColor, lineWidth, lineStyle, showLabel, showIndicators)
draws zigzag and related information based on preprocessed values
Parameters:
valueMatrix (matrix<float>): is matrix containing values of price and indicators
directionMatrix (matrix<int>): is matrix containing direction of price and indicators
ratioMatrix (matrix<float>): is matrix containing retracement ratios of price and indicators
divergenceMatrix (matrix<int>)
doubleDivergenceMatrix (matrix<int>)
barArray (array<int>): is array of pivot bars
newZG (bool): is bool which tells whether new zigzag pivot is formed or not
doubleZG (bool): is bool which teels us if the bar has both high and low zigzag
indicatorLabels (array<string>)
lineColor (color): zigzag line color. set to blue by default
lineWidth (int): zigzag line width. set to 1 by default
lineStyle (string): zigzag line style. set to line.style_solid by default
showLabel (bool): Show pivot label
showIndicators (bool): Include indicators in labels. If set to false, indicators are shown as tooltips
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
zigzaglines array of zigzag lines
zigzaglabels array of zigzag labels
draw(length, ohlc, indicatorLabels, indicatorHigh, indicatorLow, numberOfPivots, lineColor, lineWidth, lineStyle, showLabel, showIndicators)
draws zigzag and related information
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorLabels (array<string>): Array of name of indicators passed
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
lineColor (color): zigzag line color. set to blue by default
lineWidth (int): zigzag line width. set to 1 by default
lineStyle (string): zigzag line style. set to line.style_solid by default
showLabel (bool): Show pivot label
showIndicators (bool): Include indicators in labels. If set to false, indicators are shown as tooltips
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
zigzaglines array of zigzag lines
zigzaglabels array of zigzag labels
Matrix implementation of zigzag to allow further possibilities.
Main advantage of this library over previous zigzag methods is that you can attach any number of indicator/oscillator information to zigzag
calculate(length, ohlc, indicatorHigh, indicatorLow, numberOfPivots, supertrendLength)
calculates zigzag and related information
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
supertrendLength (simple int): is number of pivot history to calculate supertrend
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
supertrendDir is direction of zigzag based supertrend
supertrend is supertrend value of zigzag based supertrend
newZG is true if a new pivot is added to array
doubleZG is true if last calculation returned two new pivots (Happens on extreme price change)
calculateplain(length, ohlc, indicatorHigh, indicatorLow, numberOfPivots, offset)
calculates zigzag and related information uses shift/unshift rather than pop and push. Also does not calculate divergence and ratios.
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
offset (simple int)
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionArray Matrix containing direction of price and indicator values at pivots
barArray Array containing pivot bars
newZG is true if a new pivot is added to array
doubleZG is true if last calculation returned two new pivots (Happens on extreme price change)
draw(valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, newZG, doubleZG, indicatorLabels, lineColor, lineWidth, lineStyle, showLabel, showIndicators)
draws zigzag and related information based on preprocessed values
Parameters:
valueMatrix (matrix<float>): is matrix containing values of price and indicators
directionMatrix (matrix<int>): is matrix containing direction of price and indicators
ratioMatrix (matrix<float>): is matrix containing retracement ratios of price and indicators
divergenceMatrix (matrix<int>)
doubleDivergenceMatrix (matrix<int>)
barArray (array<int>): is array of pivot bars
newZG (bool): is bool which tells whether new zigzag pivot is formed or not
doubleZG (bool): is bool which teels us if the bar has both high and low zigzag
indicatorLabels (array<string>)
lineColor (color): zigzag line color. set to blue by default
lineWidth (int): zigzag line width. set to 1 by default
lineStyle (string): zigzag line style. set to line.style_solid by default
showLabel (bool): Show pivot label
showIndicators (bool): Include indicators in labels. If set to false, indicators are shown as tooltips
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
zigzaglines array of zigzag lines
zigzaglabels array of zigzag labels
draw(length, ohlc, indicatorLabels, indicatorHigh, indicatorLow, numberOfPivots, lineColor, lineWidth, lineStyle, showLabel, showIndicators)
draws zigzag and related information
Parameters:
length (simple int): is zigzag length
ohlc (array<float>): array of OHLC values to be used for zigzag calculation
indicatorLabels (array<string>): Array of name of indicators passed
indicatorHigh (array<float>): Array of indicator values calculated based on high price of OHLC
indicatorLow (array<float>): Array of indicators values calculated based on low price of OHLC
numberOfPivots (simple int): Number of pivots to be returned
lineColor (color): zigzag line color. set to blue by default
lineWidth (int): zigzag line width. set to 1 by default
lineStyle (string): zigzag line style. set to line.style_solid by default
showLabel (bool): Show pivot label
showIndicators (bool): Include indicators in labels. If set to false, indicators are shown as tooltips
Returns: valueMatrix Matrix containing zigzag pivots for price and indicators
directionMatrix Matrix containing direction of price and indicator values at pivots
ratioMatrix Matrix containing ratios of price and indicator values at pivots
divergenceMatrix matrix containing divergence details for each indicators
doubleDivergenceMatrix matrix containing double divergence details for each indicators
barArray Array containing pivot bars
zigzaglines array of zigzag lines
zigzaglabels array of zigzag labels
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.