BAH Pine UI Helpers

835
Generic presentation and utility library. It contains no trading logic: no thresholds, no scores, no weights, no qualification rules and no market decisions. It maps already-computed integer display codes to text and colours, formats a timeframe token, and provides textbook helpers (median of a sorted array, banker's rounding, nearest-first ordering, band distance) plus drawing-object cleanup and table-row rendering.

Authorship: BAH. The author permits this library to be imported by the author's own protected / invite-only BAH scripts.

Library "bah_pine_ui_helpers"

poiTypeLabel(code)
  POI type code -> display name.
  Parameters:
    code (int): already-computed code
  Returns: the display value

permissionLabel(code)
  permission code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

lifecycleLabel(code)
  lifecycle code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

tierLabel(code)
  strength tier code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

directionLabel(code)
  direction code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

trendStateLabel(code)
  trend-state code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

regimeLabel(code)
  regime code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

momentumAccelLabel(code)
  momentum-acceleration code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

breakoutLabel(code)
  breakout code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

pullbackLabel(code)
  pullback code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

sessionLabel(code)
  session code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

volatilityLabel(code)
  volatility code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

alignmentLabel(code)
  alignment code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

terminalReasonLabel(code)
  terminal-reason code -> display text.
  Parameters:
    code (int): already-computed code
  Returns: the display value

permissionColor(code)
  permission code -> display colour.
  Parameters:
    code (int): already-computed code
  Returns: the display value

timeframeLabel(p)
  raw timeframe token -> M1/M5/M15/H1/H4/D1/W1 vocabulary.
  Parameters:
    p (string): already-computed code
  Returns: the display value

clearLabels(a)
  delete every label in an array and empty it.
  Parameters:
    a (array<label>)
  Returns: see description

clearLines(a)
  delete every line in an array and empty it.
  Parameters:
    a (array<line>)
  Returns: see description

clearBoxes(a)
  delete every box in an array and empty it.
  Parameters:
    a (array<box>)
  Returns: see description

renderRow(t, r, k, v)
  render one key/value row of a two-column table.
  Parameters:
    t (table)
    r (int)
    k (string)
    v (string)
  Returns: see description

nearestFirst(d, key, taken, n)
  indices of the n smallest distances, ties broken by key.
  Parameters:
    d (array<float>)
    key (array<int>)
    taken (array<bool>)
    n (int)
  Returns: see description

bankersRound(x)
  round half to even (banker's rounding).
  Parameters:
    x (float)
  Returns: see description

medianOfSorted(sorted)
  median of an already-sorted float array.
  Parameters:
    sorted (array<float>)
  Returns: see description

bandDistance(price, top, bottom)
  distance from a price to a band, zero when inside it.
  Parameters:
    price (float)
    top (float)
    bottom (float)
  Returns: the distance

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.