ml_forecast Probabilistic forecasting toolkit

224
The “emit P(event), don’t assert yes/no” pillar: an analytical volatility cone, an empirical session-open reach-probability counter, a robust (Theil-Sen) trendline, a pretrained logistic hazard head with its survival curve, total-variation distance for scoring a predicted distribution, and empirical-Bayes trust shrinkage.

Design: Pine has no RNG, so the cone is ANALYTICAL (z·σ·√h) — deterministic and non-repainting, not a random Monte-Carlo. The hazard head is a FORWARD PASS over weights you train OFFLINE (logistic regression on your labeled events) and pass frozen — the library does the inference, not the training. Stateful pieces (reach counters) keep their state HOST-side; this library owns the math.

Concept credit: volatility cones, empirical reach/touch probability, Theil-Sen robust regression, discrete-time survival hazards, total-variation distance, and empirical-Bayes shrinkage are standard statistical techniques — original, dependency-free Pine v6 packaging. Educational; not financial advice.

Library "ml_forecast"

volCone(price, sigmaPerBar, horizon, z)
  Parameters:
    price (float)
    sigmaPerBar (float)
    horizon (simple int)
    z (simple float)

reachRecord(hits, maxExcursionPct, stepPct)
  Parameters:
    hits (array<float>)
    maxExcursionPct (float)
    stepPct (simple float)

reachProb(hits, k, sessions)
  Parameters:
    hits (array<float>)
    k (int)
    sessions (float)

theilSen(src, len)
  Parameters:
    src (float)
    len (simple int)

logisticHazard(features, weights, bias)
  Parameters:
    features (array<float>)
    weights (array<float>)
    bias (simple float)

survivalProb(p0, h, k)
  Parameters:
    p0 (float)
    h (float)
    k (simple int)

survLen(p0, h, kmax)
  Parameters:
    p0 (float)
    h (float)
    kmax (simple int)

tvd(p, q)
  Parameters:
    p (array<float>)
    q (array<float>)

trustWeight(trustCx, trustCc)
  Parameters:
    trustCx (float)
    trustCc (float)

trustShrink(forecast, realized, trust)
  Parameters:
    forecast (float)
    realized (float)
    trust (float)

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.