OPEN-SOURCE SCRIPT
SW_WickSize

═════════════════════════════════════════════════════════════
// SW_UPPER/LOWER WICKSIZE — USER GUIDE
// ═════════════════════════════════════════════════════════════
//
// WHAT IT DOES
// Draws ONE box per bar, colored to match that bar's own candle color
// (green candle -> green box, red candle -> red box). Each box crosses
// a zero baseline: the part above zero is the rolling average of that
// color's upper wick, the part below is the rolling average of that
// color's lower wick.
//
// A bar where close == open (neither green nor red) draws no box.
//
// WICK DEFINITIONS
// Green upper wick = high - close Green lower wick = open - low
// Red upper wick = high - open Red lower wick = close - low
//
// AVERAGING
// Both colors' wick values are computed on every bar (0 on bars that
// don't match that color), then smoothed with a simple moving average
// over the last `x` bars. This means the average reflects both how
// large the wicks are AND how often that color occurs in the lookback
// window — fewer bars of a color in the window pulls its average down
// even if the bars that did occur had large wicks.
//
// BOX SIZE — REAL PRICE UNITS, NOT A PERCENTAGE
// Box height is the actual averaged wick length on the same price
// scale as the candles above, not a percentage or fraction of the bar.
//
// HOW THE BOX IS DRAWN (plotcandle, not box.new)
// The box is drawn using plotcandle() — Pine's native candle-shape
// plot — rather than box.new(). plotcandle(open, high, low, close)
// normally draws OHLC; here open=high=top value and close=low=bottom
// value, which collapses the "wick" to nothing and makes the "body"
// span exactly [bottom, top], giving a solid rectangle crossing zero.
// Using plotcandle guarantees the box aligns exactly under its own
// candle at every zoom level, since it shares the same native
// rendering pipeline as real candles (manual box.new() coordinates,
// whether time-based or index-based, cannot achieve this reliably).
//
// PLOTCANDLE STYLE-TAB NOTE
// plotcandle always exposes Body/Wick/Border as separate color pairs
// in the Style tab — this is a fixed platform behavior. We only use the
// Body color setting. Wick and Border color settings can be ignored.
//
// DOJI MARKER
// A yellow diamond is drawn exactly on the zero line whenever a
// candle's body is small relative to its full high-low range (default
// 5%). This is a visual flag only — it never affects bar
// classification or the wick averages. Drawn last so it renders above
// both the boxes and the zero line.
//
// LAYERING
// Draw order is: plotcandle (boxes) -> hline (zero line) -> plotshape
// (doji marker). Pine renders later plot-family calls on top of
// earlier ones, so the zero line sits above the boxes, and the doji
// diamond sits above everything.
//
// INPUTS
// x — lookback length for the averages (default 5)
// showGreenBox/showRedBox — per-color visibility toggle
// greenColor/redColor — box colors
// scaleHeadroomPts — additive invisible scale padding: adds a fixed
// number of points above the tallest recent bar
// to push the zero line further down in the
// pane. 0 = off.
// dojiBodyPct — doji threshold, as % of that bar's high-low
// range (default 5%)
// ════════════════════════════════════════════════════════════
// SW_UPPER/LOWER WICKSIZE — USER GUIDE
// ═════════════════════════════════════════════════════════════
//
// WHAT IT DOES
// Draws ONE box per bar, colored to match that bar's own candle color
// (green candle -> green box, red candle -> red box). Each box crosses
// a zero baseline: the part above zero is the rolling average of that
// color's upper wick, the part below is the rolling average of that
// color's lower wick.
//
// A bar where close == open (neither green nor red) draws no box.
//
// WICK DEFINITIONS
// Green upper wick = high - close Green lower wick = open - low
// Red upper wick = high - open Red lower wick = close - low
//
// AVERAGING
// Both colors' wick values are computed on every bar (0 on bars that
// don't match that color), then smoothed with a simple moving average
// over the last `x` bars. This means the average reflects both how
// large the wicks are AND how often that color occurs in the lookback
// window — fewer bars of a color in the window pulls its average down
// even if the bars that did occur had large wicks.
//
// BOX SIZE — REAL PRICE UNITS, NOT A PERCENTAGE
// Box height is the actual averaged wick length on the same price
// scale as the candles above, not a percentage or fraction of the bar.
//
// HOW THE BOX IS DRAWN (plotcandle, not box.new)
// The box is drawn using plotcandle() — Pine's native candle-shape
// plot — rather than box.new(). plotcandle(open, high, low, close)
// normally draws OHLC; here open=high=top value and close=low=bottom
// value, which collapses the "wick" to nothing and makes the "body"
// span exactly [bottom, top], giving a solid rectangle crossing zero.
// Using plotcandle guarantees the box aligns exactly under its own
// candle at every zoom level, since it shares the same native
// rendering pipeline as real candles (manual box.new() coordinates,
// whether time-based or index-based, cannot achieve this reliably).
//
// PLOTCANDLE STYLE-TAB NOTE
// plotcandle always exposes Body/Wick/Border as separate color pairs
// in the Style tab — this is a fixed platform behavior. We only use the
// Body color setting. Wick and Border color settings can be ignored.
//
// DOJI MARKER
// A yellow diamond is drawn exactly on the zero line whenever a
// candle's body is small relative to its full high-low range (default
// 5%). This is a visual flag only — it never affects bar
// classification or the wick averages. Drawn last so it renders above
// both the boxes and the zero line.
//
// LAYERING
// Draw order is: plotcandle (boxes) -> hline (zero line) -> plotshape
// (doji marker). Pine renders later plot-family calls on top of
// earlier ones, so the zero line sits above the boxes, and the doji
// diamond sits above everything.
//
// INPUTS
// x — lookback length for the averages (default 5)
// showGreenBox/showRedBox — per-color visibility toggle
// greenColor/redColor — box colors
// scaleHeadroomPts — additive invisible scale padding: adds a fixed
// number of points above the tallest recent bar
// to push the zero line further down in the
// pane. 0 = off.
// dojiBodyPct — doji threshold, as % of that bar's high-low
// range (default 5%)
// ════════════════════════════════════════════════════════════
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。