PINE LIBRARY
업데이트됨

Isotropic Coordinate System (ICS)

1 088
Library "ICS"
Isotropic Coordinate System (ICS): a dimensionless price-time space
for scale-invariant chart geometry.
Vertical axis: y = ln(price) / sigma, where sigma is the Yang-Zhang (2000)
minimum-variance, drift-independent, gap-consistent OHLC volatility estimator.
Horizontal axis: two scalings via the XScale enum.
legacy : x = bars / lookback. Linear window fraction. Backward compatible.
isotropic : x = sqrt(bars / lookback), with y additionally divided by
sqrt(lookback). Diffusion-consistent (sqrt-time scaling), so that
tan(theta) equals the z-score of the move and 45 degrees
corresponds to a move of exactly one standard deviation
of the n-bar log-return distribution. Assumes approximately
iid returns within the sigma window (the standard assumption
behind sqrt-time scaling; see Danielsson & Zigrand, 2006, for
its known limits under vol clustering and jumps).
Every output (angle, length, area, centroid) is a pure dimensionless number,
comparable across symbols, currencies, and timeframes.
Reference: Yang, D. & Zhang, Q. (2000), "Drift-Independent Volatility
Estimation Based on High, Low, Open, and Close Prices",
The Journal of Business, 73(3), 477-492.

yangZhangSigma(length)
  Yang-Zhang volatility estimator. Minimum-variance, unbiased,
drift-independent, and consistent with opening gaps
(Yang & Zhang, 2000). Uses the unbiased sample variance
(biased = false) for both the overnight and open-to-close
components, matching the estimator's unbiasedness claim.
  Parameters:
    length (simple int): (simple int) Rolling window length. Must be >= 2.
  Returns: (series float) Per-bar sigma, floored at 1e-10.

toX(bars, lookback, mode)
  Dimensionless horizontal coordinate.
  Parameters:
    bars (int): (series int) Signed bar distance from the anchor.
    lookback (int): (series int) Window length acting as the horizontal unit.
    mode (series XScale): (series XScale) Scaling mode.
  Returns: (series float) Signed dimensionless x.

toY(price, sigma, lookback, mode)
  Dimensionless vertical coordinate.
  Parameters:
    price (float): (series float) Price. Must be > 0.
    sigma (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (int): (series int) Window length (used by isotropic mode only).
    mode (series XScale): (series XScale) Scaling mode.
  Returns: (series float) Dimensionless y, or na when inputs are invalid.

moveZScore(dLogPrice, sigma, bars)
  Z-score of a log-price move over n bars: dLog / (sigma * sqrt(n)).
In isotropic mode this equals tan(theta) of the same move.
  Parameters:
    dLogPrice (float): (series float) ln(target) - ln(anchor).
    sigma (float): (series float) Per-bar Yang-Zhang sigma. Must be > 1e-10.
    bars (int): (series int) Number of bars in the move. Must be > 0.
  Returns: (series float) The z-score, or na when inputs are invalid.

triangle(td, anchorPrice, anchorBar, targetPrice, targetBar, sig, lookback, mode)
  Right triangle between an anchor and a target, computed entirely
in ICS space. Writes results in place into `td` and returns it.
On invalid inputs every field is set to na, so world X never
receives contaminated numbers.
  Parameters:
    td (TriangleData): (TriangleData) Output object, updated in place.
    anchorPrice (float): (series float) Anchor price (world A). Must be > 0.
    anchorBar (int): (series int) Anchor bar_index.
    targetPrice (float): (series float) Target price (world A). Must be > 0.
    targetBar (int): (series int) Target bar_index. Must differ from anchorBar.
    sig (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (int): (series int) Horizontal unit window.
    mode (series XScale): (series XScale) Scaling mode.
  Returns: (TriangleData) The same `td`, for chaining.

pinTriangle(td, anchorPrice, anchorBar, extremePrice, bodyPrice, curBar, sig, lookback, mode)
  Pin (wick) triangle with three vertices in ICS space:
A = anchor, B = candle extreme, C = candle body edge.
Side BC is the wick. theta = signed angle at A between AB and AC.
Since xB = xC, the shoelace area reduces exactly to
0.5 * |yB - yC| * |dx|.
  Parameters:
    td (TriangleData): (TriangleData) Output object, updated in place.
    anchorPrice (float): (series float) Anchor price (hh or ll). Must be > 0.
    anchorBar (int): (series int) Anchor bar_index.
    extremePrice (float): (series float) Candle extreme (high or low). Must be > 0.
    bodyPrice (float): (series float) Candle body edge. Must be > 0.
    curBar (int): (series int) Current bar_index. Must differ from anchorBar.
    sig (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (int): (series int) Horizontal unit window.
    mode (series XScale): (series XScale) Scaling mode.
  Returns: (TriangleData) The same `td`, for chaining.

zeroTri(td)
  Resets a TriangleData to na. Use when the structure is inactive,
so inactive periods never enter moving averages or normalization
as fake zero values.
  Parameters:
    td (TriangleData): (TriangleData) Object to reset, updated in place.
  Returns: (TriangleData) The same `td`, for chaining.

TriangleData
  One triangle's measurements in ICS space. All fields dimensionless.
  Fields:
    theta (series float): Signed hypotenuse angle in degrees; in isotropic mode tan(theta) is the z-score of the move.
    dy (series float): Signed Euclidean magnitude of the hypotenuse.
    area (series float): Triangle area (>= 0).
    centroidY (series float): Vertical centroid of the triangle.

FrozenAnchors
  Anchors frozen at a reference bar, plus activity state.
  Fields:
    hh (series float): Highest high at the freeze bar (world-A price units).
    ll (series float): Lowest low at the freeze bar (world-A price units).
    mid (series float): Geometric mean sqrt(hh * ll) at the freeze bar.
    bar_x (series int): bar_index of the freeze bar.
    time_x (series int): time of the freeze bar.
    is_active (series bool): Whether the frozen structure is currently active.
릴리즈 노트
v2

Updated:
toX(bars, lookback)
  Dimensionless horizontal coordinate, sqrt-time scaled.
  Parameters:
    bars (int): (series int) Signed bar distance from the anchor.
    lookback (simple int): (simple int) Window length acting as the horizontal unit.
  Returns: (series float) Signed dimensionless x.

toY(price, sigma, lookback)
  Dimensionless vertical coordinate.
  Parameters:
    price (float): (series float) Price. Must be > 0.
    sigma (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (simple int): (simple int) Window length (vertical sqrt normalizer).
  Returns: (series float) Dimensionless y, or na when inputs are invalid.

moveZScore(dLogPrice, sigma, bars)
  Z-score of a log-price move over n bars: dLog / (sigma * sqrt(n)).
This equals tan(theta) of the same move in ICS space.
  Parameters:
    dLogPrice (float): (series float) ln(target) - ln(anchor).
    sigma (float): (series float) Per-bar Yang-Zhang sigma. Must be > 1e-10.
    bars (int): (series int) Number of bars in the move. Must be > 0.
  Returns: (series float) The z-score, or na when inputs are invalid.

triangle(td, anchorPrice, anchorBar, targetPrice, targetBar, sig, lookback)
  Right triangle between an anchor and a target, computed entirely
in ICS space. Writes results in place into `td` and returns it.
On invalid inputs every field is set to na, so world X never
receives contaminated numbers.
  Parameters:
    td (TriangleData): (TriangleData) Output object, updated in place.
    anchorPrice (float): (series float) Anchor price (world A). Must be > 0.
    anchorBar (int): (series int) Anchor bar_index.
    targetPrice (float): (series float) Target price (world A). Must be > 0.
    targetBar (int): (series int) Target bar_index. Must differ from anchorBar.
    sig (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (simple int): (simple int) Horizontal unit window.
  Returns: (TriangleData) The same `td`, for chaining.

pinTriangle(td, anchorPrice, anchorBar, extremePrice, bodyPrice, curBar, sig, lookback)
  Pin (wick) triangle with three vertices in ICS space:
A = anchor, B = candle extreme, C = candle body edge.
Side BC is the wick. theta = signed angle at A between AB and AC.
Since xB = xC, the shoelace area reduces exactly to
0.5 * |yB - yC| * |dx|.
  Parameters:
    td (TriangleData): (TriangleData) Output object, updated in place.
    anchorPrice (float): (series float) Anchor price (hh or ll). Must be > 0.
    anchorBar (int): (series int) Anchor bar_index.
    extremePrice (float): (series float) Candle extreme (high or low). Must be > 0.
    bodyPrice (float): (series float) Candle body edge. Must be > 0.
    curBar (int): (series int) Current bar_index. Must differ from anchorBar.
    sig (float): (series float) Yang-Zhang sigma. Must be > 1e-10.
    lookback (simple int): (simple int) Horizontal unit window.
  Returns: (TriangleData) The same `td`, for chaining.

TriangleData
  One triangle's measurements in ICS space. All fields dimensionless.
  Fields:
    theta (series float): Signed hypotenuse angle in degrees; tan(theta) is the z-score of the move.
    dy (series float): Signed Euclidean magnitude of the hypotenuse.
    area (series float): Triangle area (>= 0).
    centroidY (series float): Vertical centroid of the triangle.

면책사항

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