OPEN-SOURCE SCRIPT
已更新 CQ_(I)_Multi-Chart Widget Phases + Pivots + Fibonacci V2

================================================================================
CQ_(I)_MULTI-CHART WIDGET PHASES + PIVOTS + FIBONACCI V2
USER MANUAL
================================================================================
ATTRIBUTION
--------------------------------------------------------------------------------
This script reuses the public "Multi-Chart Widget" mini-chart rendering engine
originally published by LuxAlgo (symbol/timeframe fetching, mini candle/line/
area/volume-candle drawing, and panel layout). That portion is licensed under
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
(CC BY-NC-SA 4.0): creativecommons.org/licenses/by-nc-sa/4.0/
The Zigzag / Fibonacci Retracement / Trend Pivots overlay, the arrowhead
markers, the average-leg statistics, and all related settings were added on
top of that base and are original to this script.
Because the underlying LuxAlgo code is CC BY-NC-SA 4.0, this script (and any
derivative of it) must remain non-commercial, must credit LuxAlgo, and must be
shared under the same license if redistributed.
--------------------------------------------------------------------------------
1. WHAT THIS SCRIPT DOES
--------------------------------------------------------------------------------
This is an overlay indicator that draws up to THREE independent "mini charts"
floating to the right of the main chart, each one pulling its own symbol and
timeframe through request.security(). On top of each mini chart, the script
optionally overlays:
- A Zigzag showing the last confirmed swing leg(s)
- A Fibonacci retracement drawn from the most recent zigzag leg
- Trend Pivot markers (Higher High / Lower High / Higher Low / Lower Low)
with arrowheads and/or text labels
- A compact info panel per mini chart (symbol, price, timeframe, RSI,
Volatility, R-Squared)
- Average bullish/bearish leg-size statistics
Each mini chart, and each overlay feature on it, is independently
configurable, and each mini chart can track a completely different
symbol/timeframe than the main chart and than the other two mini charts.
--------------------------------------------------------------------------------
2. MINI CHART(S) GENERIC SETTINGS
--------------------------------------------------------------------------------
Mini Charts Separator
Draws a vertical divider line (and horizontal dividers, when more than
one mini chart is shown) separating the mini-chart area from the main
chart and separating stacked mini charts from each other.
Number Of Bars
How many bars each mini chart renders. Range 1-73 (TradingView line/box
object limits cap how wide these can practically get). This is also the
window used to decide which Trend Pivots are still "recent enough" to
display (see section 6).
Horizontal Offset
How far to the right of the current bar the mini charts begin. Range
10-360. Increase this if the mini charts overlap your latest price
action.
--------------------------------------------------------------------------------
3. TOP / MIDDLE / BOTTOM MINI CHART SETTINGS
--------------------------------------------------------------------------------
Each of the three mini charts (Top, Middle, Bottom) has an identical set of
options:
Mini Chart Top/Middle/Bottom (on/off)
Enables or disables that mini chart entirely.
Symbol
The instrument to display. Leave blank to use the main chart's symbol.
Timeframe
Chart, 5 Minutes, 15 Minutes, 1 Hour, 4 Hours, 1 Day, 1 Week, 1 Month.
If you pick a timeframe lower than your chart's own timeframe, the
script automatically falls back to the chart's timeframe (you cannot
request a resolution finer than what your chart is currently on).
Chart Type
Candles, Volume candles, Line, Area, Columns, High-low, Heikin Ashi.
"Volume candles" scales candle body width by relative volume.
Chart Size
A relative vertical size multiplier (1-5) used when stacking multiple
mini charts in the available vertical space.
Technical Indicator
Moving Average or None. When set to Moving Average, the moving average
configured in section 4 is plotted on that specific mini chart.
--------------------------------------------------------------------------------
4. MOVING AVERAGE SETTINGS
--------------------------------------------------------------------------------
Applies to any mini chart with its "Technical Indicator" set to Moving
Average.
Type SMA, EMA, HMA, RMA, WMA, or VWMA
Source Price source used for the calculation
Length Lookback length
Color Line color of the moving average overlay
--------------------------------------------------------------------------------
5. MINI CHART(S) PANEL SETTINGS
--------------------------------------------------------------------------------
Mini Chart(s) Panel (on/off)
Master switch for the small text panel drawn to the right of each mini
chart (symbol, last price, timeframe, chart type).
Relative Strength Index (on/off), Source, Length
Adds an RSI reading to the panel text, classified as Overbought /
Bullish / Neutral / Bearish / Oversold.
Volatility (on/off), Length
Adds a volatility reading to the panel text (ratio of the EMA of price
change to the EMA of absolute price change).
R-Squared (on/off), Length
Adds an R² reading (correlation strength between price and time) to the
panel text.
--------------------------------------------------------------------------------
6. ZIGZAG / FIBONACCI / TREND PIVOTS (PER MINI CHART, OWN TIMEFRAME)
--------------------------------------------------------------------------------
Everything in this group is calculated independently, per mini chart, using
that mini chart's own symbol and timeframe.
Enable Phases Overlay
Master switch for the entire zigzag/Fibonacci/trend-pivot overlay. Turn
this off to run the widget as a plain LuxAlgo-style mini-chart display
with no extra markup.
--- Zigzag ---
Zigzag Last Leg (on/off)
Detects swing highs/lows using a highest/lowest-bars pivot method and
draws the last N confirmed legs as connecting lines. The most recent
(still-forming) leg is drawn dashed and with a thicker line width; older
legs are drawn as thin solid lines. Small circle markers cap the
endpoints of the most recent leg.
Zigzag Period
Lookback length used to detect swing highs and lows. Smaller = more
sensitive/frequent swings; larger = fewer, larger swings.
Legs To Show
How many of the most recent confirmed legs to draw (1-8).
Leg Line Width
Line width of the most recent (dashed) leg.
Up / Down colors
Color used for legs ending in a swing high vs. a swing low.
--- Fibonacci Retracement ---
Fibonacci Retracement (on/off)
Draws a Fibonacci retracement grid anchored to the start and end price
of the single most recent confirmed zigzag leg.
25% / 40% / 50% / 60% / 75% / 90%
Individually toggle which intermediate retracement levels are drawn.
The 0% and 100% levels (the leg's own start/end prices) are always
drawn and use a thicker line.
Fib Label Size
Tiny, Small, or Normal text size for the level labels.
Fib Label Layout
Two Lines (default) shows each label as "level%" stacked above "price".
Single Line shows them side by side as "level% price" instead.
Bullish Read / Bearish Read colors
These two colors are used for the Fibonacci grid, but note the color
logic is intentionally inverted from the leg's own color: if the most
recent leg itself is drawn in the "Up" color (a teal-style color by
default), the Fibonacci grid is drawn in the Bullish Read color
(an orange-style color by default), and vice versa. This is a deliberate
contrast choice so the Fibonacci grid never visually blends into the
zigzag leg it's measuring.
--- Trend Pivots (HH/LH/HL/LL) ---
Trend Pivots (on/off)
Detects and labels the most recent Higher High (HH), Lower High (LH),
Higher Low (HL), and Lower Low (LL) pivots using ta.pivothigh /
ta.pivotlow.
Trend Pivot Period
Lookback/lookahead length used for pivot confirmation. Note that a
pivot only confirms this many bars after it actually occurred, so very
recent pivots may not appear until enough bars have printed.
Show Arrowheads (on/off)
Draws a small triangular arrowhead marker pinned exactly on each pivot's
bar/price: a down-pointing arrowhead on highs (HH/LH) and an up-pointing
arrowhead on lows (HL/LL). Independent of whether text labels are shown.
Label Content
Controls what text (if any) is shown alongside the arrowhead at each
pivot:
Labels -> "HH" / "LH" / "HL" / "LL" text
Tendency Arrows -> a single directional arrow (up-right for HH/HL,
down-right for LH/LL) used as a quick bullish/
bearish tendency cue
Both -> the text label and the tendency arrow together
None -> no text label at all (arrowheads only, if
enabled)
HH / LH / HL / LL colors
Independent color for each of the four pivot types, applied to both the
arrowhead and the text label for that pivot type.
Only the single most recent pivot of each type (HH, LH, HL, LL) is ever
shown, and only if it falls within the mini chart's own visible bar window
(see "Number Of Bars" in section 2) -- older pivots that have scrolled out
of that window are automatically hidden rather than pinned to the edge.
--- Averages ---
Show Avg Leg % in Panel (on/off)
Adds a compact "Avg ▲: x.xx% ▼: x.xx%" line above each mini chart's
panel, showing the rolling average size (in percent) of recent bullish
vs. bearish zigzag legs.
Averaging Length
How many recent bullish legs / bearish legs (tracked separately) are
averaged for the stat above.
--------------------------------------------------------------------------------
7. HOW TO READ THE OVERLAY
--------------------------------------------------------------------------------
- The dashed, thicker zigzag line is always the CURRENT / most recent leg.
Thin solid lines behind it are earlier, already-confirmed legs.
- The Fibonacci grid is always measured from that same most-recent leg only
(0% = the leg's starting price, 100% = the leg's ending price).
- Trend Pivot arrowheads/labels mark swing extremes independently of the
zigzag -- they use their own period setting and their own pivot-detection
logic (ta.pivothigh/ta.pivotlow), so they will not always line up exactly
with the zigzag's own swing points.
- All drawing only happens once per bar close, on the last confirmed bar
(barstate.islast), to keep the script light -- nothing is redrawn
intra-bar on every tick.
--------------------------------------------------------------------------------
8. LIMITATIONS & TROUBLESHOOTING
--------------------------------------------------------------------------------
"There isn't enough data available" warning
Appears when your chart doesn't yet have enough bars loaded to satisfy
Number Of Bars plus the internal warm-up length needed for the Moving
Average / Zigzag / Trend Pivot calculations. Scroll back to load more
history, or reduce Number Of Bars.
Market status warning
If the main chart's own symbol has an inactive/closed market and its
exchange doesn't match all enabled mini-chart symbols, the widget shows
an explanatory label instead of the mini charts. Use an active primary
symbol, or make sure mini-chart symbols share its exchange and type.
Object limits
The script is declared with max_lines_count = 500 and
max_labels_count = 200. With all three mini charts enabled, a high
Number Of Bars, multiple zigzag legs, all six Fibonacci sub-levels, and
all four trend pivots with both arrowheads and text labels turned on,
you are pushing close to those ceilings across three mini charts at
once. If elements start disappearing unexpectedly, reduce Number Of
Bars, Legs To Show, or disable some Fibonacci sub-levels.
Higher-timeframe context
Each mini chart's zigzag/Fibonacci/trend-pivot calculations run on that
mini chart's own timeframe via request.security(), not on the main
chart's timeframe, so swing structure shown on the mini charts can look
different from swing structure on your main chart even for the same
symbol.
================================================================================
CQ_(I)_MULTI-CHART WIDGET PHASES + PIVOTS + FIBONACCI V2
USER MANUAL
================================================================================
ATTRIBUTION
--------------------------------------------------------------------------------
This script reuses the public "Multi-Chart Widget" mini-chart rendering engine
originally published by LuxAlgo (symbol/timeframe fetching, mini candle/line/
area/volume-candle drawing, and panel layout). That portion is licensed under
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
(CC BY-NC-SA 4.0): creativecommons.org/licenses/by-nc-sa/4.0/
The Zigzag / Fibonacci Retracement / Trend Pivots overlay, the arrowhead
markers, the average-leg statistics, and all related settings were added on
top of that base and are original to this script.
Because the underlying LuxAlgo code is CC BY-NC-SA 4.0, this script (and any
derivative of it) must remain non-commercial, must credit LuxAlgo, and must be
shared under the same license if redistributed.
--------------------------------------------------------------------------------
1. WHAT THIS SCRIPT DOES
--------------------------------------------------------------------------------
This is an overlay indicator that draws up to THREE independent "mini charts"
floating to the right of the main chart, each one pulling its own symbol and
timeframe through request.security(). On top of each mini chart, the script
optionally overlays:
- A Zigzag showing the last confirmed swing leg(s)
- A Fibonacci retracement drawn from the most recent zigzag leg
- Trend Pivot markers (Higher High / Lower High / Higher Low / Lower Low)
with arrowheads and/or text labels
- A compact info panel per mini chart (symbol, price, timeframe, RSI,
Volatility, R-Squared)
- Average bullish/bearish leg-size statistics
Each mini chart, and each overlay feature on it, is independently
configurable, and each mini chart can track a completely different
symbol/timeframe than the main chart and than the other two mini charts.
--------------------------------------------------------------------------------
2. MINI CHART(S) GENERIC SETTINGS
--------------------------------------------------------------------------------
Mini Charts Separator
Draws a vertical divider line (and horizontal dividers, when more than
one mini chart is shown) separating the mini-chart area from the main
chart and separating stacked mini charts from each other.
Number Of Bars
How many bars each mini chart renders. Range 1-73 (TradingView line/box
object limits cap how wide these can practically get). This is also the
window used to decide which Trend Pivots are still "recent enough" to
display (see section 6).
Horizontal Offset
How far to the right of the current bar the mini charts begin. Range
10-360. Increase this if the mini charts overlap your latest price
action.
--------------------------------------------------------------------------------
3. TOP / MIDDLE / BOTTOM MINI CHART SETTINGS
--------------------------------------------------------------------------------
Each of the three mini charts (Top, Middle, Bottom) has an identical set of
options:
Mini Chart Top/Middle/Bottom (on/off)
Enables or disables that mini chart entirely.
Symbol
The instrument to display. Leave blank to use the main chart's symbol.
Timeframe
Chart, 5 Minutes, 15 Minutes, 1 Hour, 4 Hours, 1 Day, 1 Week, 1 Month.
If you pick a timeframe lower than your chart's own timeframe, the
script automatically falls back to the chart's timeframe (you cannot
request a resolution finer than what your chart is currently on).
Chart Type
Candles, Volume candles, Line, Area, Columns, High-low, Heikin Ashi.
"Volume candles" scales candle body width by relative volume.
Chart Size
A relative vertical size multiplier (1-5) used when stacking multiple
mini charts in the available vertical space.
Technical Indicator
Moving Average or None. When set to Moving Average, the moving average
configured in section 4 is plotted on that specific mini chart.
--------------------------------------------------------------------------------
4. MOVING AVERAGE SETTINGS
--------------------------------------------------------------------------------
Applies to any mini chart with its "Technical Indicator" set to Moving
Average.
Type SMA, EMA, HMA, RMA, WMA, or VWMA
Source Price source used for the calculation
Length Lookback length
Color Line color of the moving average overlay
--------------------------------------------------------------------------------
5. MINI CHART(S) PANEL SETTINGS
--------------------------------------------------------------------------------
Mini Chart(s) Panel (on/off)
Master switch for the small text panel drawn to the right of each mini
chart (symbol, last price, timeframe, chart type).
Relative Strength Index (on/off), Source, Length
Adds an RSI reading to the panel text, classified as Overbought /
Bullish / Neutral / Bearish / Oversold.
Volatility (on/off), Length
Adds a volatility reading to the panel text (ratio of the EMA of price
change to the EMA of absolute price change).
R-Squared (on/off), Length
Adds an R² reading (correlation strength between price and time) to the
panel text.
--------------------------------------------------------------------------------
6. ZIGZAG / FIBONACCI / TREND PIVOTS (PER MINI CHART, OWN TIMEFRAME)
--------------------------------------------------------------------------------
Everything in this group is calculated independently, per mini chart, using
that mini chart's own symbol and timeframe.
Enable Phases Overlay
Master switch for the entire zigzag/Fibonacci/trend-pivot overlay. Turn
this off to run the widget as a plain LuxAlgo-style mini-chart display
with no extra markup.
--- Zigzag ---
Zigzag Last Leg (on/off)
Detects swing highs/lows using a highest/lowest-bars pivot method and
draws the last N confirmed legs as connecting lines. The most recent
(still-forming) leg is drawn dashed and with a thicker line width; older
legs are drawn as thin solid lines. Small circle markers cap the
endpoints of the most recent leg.
Zigzag Period
Lookback length used to detect swing highs and lows. Smaller = more
sensitive/frequent swings; larger = fewer, larger swings.
Legs To Show
How many of the most recent confirmed legs to draw (1-8).
Leg Line Width
Line width of the most recent (dashed) leg.
Up / Down colors
Color used for legs ending in a swing high vs. a swing low.
--- Fibonacci Retracement ---
Fibonacci Retracement (on/off)
Draws a Fibonacci retracement grid anchored to the start and end price
of the single most recent confirmed zigzag leg.
25% / 40% / 50% / 60% / 75% / 90%
Individually toggle which intermediate retracement levels are drawn.
The 0% and 100% levels (the leg's own start/end prices) are always
drawn and use a thicker line.
Fib Label Size
Tiny, Small, or Normal text size for the level labels.
Fib Label Layout
Two Lines (default) shows each label as "level%" stacked above "price".
Single Line shows them side by side as "level% price" instead.
Bullish Read / Bearish Read colors
These two colors are used for the Fibonacci grid, but note the color
logic is intentionally inverted from the leg's own color: if the most
recent leg itself is drawn in the "Up" color (a teal-style color by
default), the Fibonacci grid is drawn in the Bullish Read color
(an orange-style color by default), and vice versa. This is a deliberate
contrast choice so the Fibonacci grid never visually blends into the
zigzag leg it's measuring.
--- Trend Pivots (HH/LH/HL/LL) ---
Trend Pivots (on/off)
Detects and labels the most recent Higher High (HH), Lower High (LH),
Higher Low (HL), and Lower Low (LL) pivots using ta.pivothigh /
ta.pivotlow.
Trend Pivot Period
Lookback/lookahead length used for pivot confirmation. Note that a
pivot only confirms this many bars after it actually occurred, so very
recent pivots may not appear until enough bars have printed.
Show Arrowheads (on/off)
Draws a small triangular arrowhead marker pinned exactly on each pivot's
bar/price: a down-pointing arrowhead on highs (HH/LH) and an up-pointing
arrowhead on lows (HL/LL). Independent of whether text labels are shown.
Label Content
Controls what text (if any) is shown alongside the arrowhead at each
pivot:
Labels -> "HH" / "LH" / "HL" / "LL" text
Tendency Arrows -> a single directional arrow (up-right for HH/HL,
down-right for LH/LL) used as a quick bullish/
bearish tendency cue
Both -> the text label and the tendency arrow together
None -> no text label at all (arrowheads only, if
enabled)
HH / LH / HL / LL colors
Independent color for each of the four pivot types, applied to both the
arrowhead and the text label for that pivot type.
Only the single most recent pivot of each type (HH, LH, HL, LL) is ever
shown, and only if it falls within the mini chart's own visible bar window
(see "Number Of Bars" in section 2) -- older pivots that have scrolled out
of that window are automatically hidden rather than pinned to the edge.
--- Averages ---
Show Avg Leg % in Panel (on/off)
Adds a compact "Avg ▲: x.xx% ▼: x.xx%" line above each mini chart's
panel, showing the rolling average size (in percent) of recent bullish
vs. bearish zigzag legs.
Averaging Length
How many recent bullish legs / bearish legs (tracked separately) are
averaged for the stat above.
--------------------------------------------------------------------------------
7. HOW TO READ THE OVERLAY
--------------------------------------------------------------------------------
- The dashed, thicker zigzag line is always the CURRENT / most recent leg.
Thin solid lines behind it are earlier, already-confirmed legs.
- The Fibonacci grid is always measured from that same most-recent leg only
(0% = the leg's starting price, 100% = the leg's ending price).
- Trend Pivot arrowheads/labels mark swing extremes independently of the
zigzag -- they use their own period setting and their own pivot-detection
logic (ta.pivothigh/ta.pivotlow), so they will not always line up exactly
with the zigzag's own swing points.
- All drawing only happens once per bar close, on the last confirmed bar
(barstate.islast), to keep the script light -- nothing is redrawn
intra-bar on every tick.
--------------------------------------------------------------------------------
8. LIMITATIONS & TROUBLESHOOTING
--------------------------------------------------------------------------------
"There isn't enough data available" warning
Appears when your chart doesn't yet have enough bars loaded to satisfy
Number Of Bars plus the internal warm-up length needed for the Moving
Average / Zigzag / Trend Pivot calculations. Scroll back to load more
history, or reduce Number Of Bars.
Market status warning
If the main chart's own symbol has an inactive/closed market and its
exchange doesn't match all enabled mini-chart symbols, the widget shows
an explanatory label instead of the mini charts. Use an active primary
symbol, or make sure mini-chart symbols share its exchange and type.
Object limits
The script is declared with max_lines_count = 500 and
max_labels_count = 200. With all three mini charts enabled, a high
Number Of Bars, multiple zigzag legs, all six Fibonacci sub-levels, and
all four trend pivots with both arrowheads and text labels turned on,
you are pushing close to those ceilings across three mini charts at
once. If elements start disappearing unexpectedly, reduce Number Of
Bars, Legs To Show, or disable some Fibonacci sub-levels.
Higher-timeframe context
Each mini chart's zigzag/Fibonacci/trend-pivot calculations run on that
mini chart's own timeframe via request.security(), not on the main
chart's timeframe, so swing structure shown on the mini charts can look
different from swing structure on your main chart even for the same
symbol.
================================================================================
發行說明
Pivot markers shown correctly now.發行說明
Fixed fibonacci retracement direction detection.發行說明
Added the option to select the number of shown zigzag legs individually per mini chart開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。