ml_levels Level-quality gates & structure classifiers

251
The small shared decisions that separate a REAL level event from noise: sweep-vs-break, displacement-confirmed impulse, retest-holds, volume validation, and nearest-level proximity. One vocabulary so “swept”, “broke”, “retested and held” and “validated pivot” mean the same thing across every SMC / order-block / support-resistance script.

Design: pure classifications over the bar geometry / volume you pass — no drawing, no persistent object state (level DETECTION and its box/line lifecycle stay host-side; this library judges the events). Nothing repaints: every read is a function of closed-bar values. Pair each event with a forward test before trusting it.

Concept credit: liquidity sweeps / stop-hunts, break-of-structure, order-block displacement and flip-then-retest are public Smart-Money-Concepts / price-action ideas — this is an original, dependency-free Pine v6 packaging of them. Educational; not financial advice.

Library "ml_levels"

sweepOrBreak(h, l, c, level, side)
  Parameters:
    h (float)
    l (float)
    c (float)
    level (float)
    side (int)

isSweep(h, l, c, level, side)
  Parameters:
    h (float)
    l (float)
    c (float)
    level (float)
    side (int)

isBreak(h, l, c, level, side)
  Parameters:
    h (float)
    l (float)
    c (float)
    level (float)
    side (int)

displacement(o, c, atr, mult)
  Parameters:
    o (float)
    c (float)
    atr (float)
    mult (simple float)

volValidated(v, smaLen, k)
  Parameters:
    v (float)
    smaLen (simple int)
    k (simple float)

retestHolds(h, l, c, level, role, tol)
  Parameters:
    h (float)
    l (float)
    c (float)
    level (float)
    role (int)
    tol (float)

nearestLevel(levels, price)
  Parameters:
    levels (array<float>)
    price (float)

nearestDist(levels, price)
  Parameters:
    levels (array<float>)
    price (float)

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.