PINE LIBRARY

Mirpapa_Lib_HTF

35
Library "Mirpapa_Lib_HTF"
High Time Frame Handler Library:
Provides utilities for working with High Time Frame (HTF) and chart (LTF) conversions and data retrieval.

IsChartTFcomparisonHTF(_chartTf, _htfTf)
  IsChartTFcomparisonHTF
description
Determine whether the given High Time Frame (HTF) is greater than or equal to the current chart timeframe.
  Parameters:
    _chartTf (string): The current chart’s timeframe string (examples: "5", "15", "1D").
    _htfTf (string): The High Time Frame string to compare (examples: "60", "1D").
return
Returns true if HTF minutes ≥ chart minutes, false otherwise or na if conversion fails.

GetHTFrevised(_tf)
  GetHTFrevised
description
Retrieve a specific bar value from a Higher Time Frame (HTF) series.
Supports current and historical OHLC values, based on a case identifier.
  Parameters:
    _tf (string): The target HTF string (examples: "60", "1D").

GetHTFrevised(_tf, _case)
  Parameters:
    _tf (string)
    _case (string)

GetHTFfromLabel(_label)
  GetHTFfromLabel
description
Convert a Korean HTF label into a Pine Script-recognizable timeframe string.
Examples:
"5분" → "5"
"1시간" → "60"
"일봉" → "1D"
"주봉" → "1W"
"월봉" → "1M"
"연봉" → "12M"
  Parameters:
    _label (string): The Korean HTF label string (examples: "5분", "1시간", "일봉").
return
Returns the Pine Script timeframe string corresponding to the label, or "1W" if no match is found.

GetHTFoffsetToLTFoffset(_offset, _chartTf, _htfTf)
  GetHTFoffsetToLTFoffset
description
Adjust an HTF bar index and offset so that it aligns with the current chart’s bar index.
Useful for retrieving historical HTF data on an LTF chart.
  Parameters:
    _offset (int): The HTF bar offset (0 means current HTF bar, 1 means one bar ago, etc.).
    _chartTf (string): The current chart’s timeframe string (examples: "5", "15", "1D").
    _htfTf (string): The High Time Frame string to align (examples: "60", "1D").
return
Returns the corresponding LTF bar index after applying HTF offset. If result is negative, returns 0.

UpdateHTFCache(_cache, _tf)
  UpdateHTFCache
description HTF 데이터 캐싱 (성능 최적화).\
HTF의 OHLC 데이터를 캐싱하여 매 틱마다 request.security 호출 방지.\
_cache: 기존 캐시 (없으면 na, 첫 호출 시).\
_tf: 캐싱할 시간대 (예: "60", "1D").\
새 bar 또는 bar_index 변경 시에만 업데이트, 그 외에는 기존 캐시 반환.\
  Parameters:
    _cache (HTFCache): 기존 캐시 데이터 (없으면 na)
    _tf (string): 시간대
  Returns: HTFCache 업데이트된 캐시 데이터

GetTimeframeSettings(_currentTF, _midTF1m, _highTF1m, _midTF5m, _highTF5m, _midTF15m, _highTF15m, _midTF30m, _highTF30m, _midTF60m, _highTF60m, _midTF240m, _highTF240m, _midTF1D, _highTF1D, _midTF1W, _highTF1W, _midTF1M, _highTF1M)
  GetTimeframeSettings
description 현재 차트 시간대에 맞는 중위/상위 시간대 자동 선택.\
_currentTF: 현재 차트 시간대 (timeframe.period).\
1분~1월 차트별로 적절한 중위/상위 시간대 매핑.\
예: 5분 차트 → 중위 15분, 상위 60분.\
반환: [중위 시간대(string), 상위 시간대(string)].\
  Parameters:
    _currentTF (string): 현재 차트 시간대
    _midTF1m (string)
    _highTF1m (string)
    _midTF5m (string)
    _highTF5m (string)
    _midTF15m (string)
    _highTF15m (string)
    _midTF30m (string)
    _highTF30m (string)
    _midTF60m (string)
    _highTF60m (string)
    _midTF240m (string)
    _highTF240m (string)
    _midTF1D (string)
    _highTF1D (string)
    _midTF1W (string)
    _highTF1W (string)
    _midTF1M (string)
    _highTF1M (string)
  Returns: [string, string] [중위 시간대, 상위 시간대]

HTFCache
  Fields:
    _timeframe (series string)
    _lastBarIndex (series int)
    _isNewBar (series bool)
    _barIndex (series int)
    _open (series float)
    _high (series float)
    _low (series float)
    _close (series float)
    _open1 (series float)
    _close1 (series float)
    _high1 (series float)
    _low1 (series float)
    _open2 (series float)
    _close2 (series float)
    _high2 (series float)
    _low2 (series float)
    _high3 (series float)
    _low3 (series float)
    _time1 (series int)
    _time2 (series int)

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.