OPEN-SOURCE SCRIPT

SW_WickSize

256
═════════════════════════════════════════════════════════════
// 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%)
// ════════════════════════════════════════════════════════════

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.