PINE LIBRARY
Обновлено

Mirpapa_Lib_Box

30
Library "Mirpapa_Lib_Box"

GetHTFrevised(_tf, _case)
  GetHTFrevised
description Retrieve a specific bar value from a Higher Time Frame (HTF) series.
  Parameters:
    _tf (string): string The target HTF string (examples: "60", "1D").
    _case (string): string Case string determining which OHLC value to request.
return float Returns the requested HTF value or na if _case does not match.

GetHTFrevised(_tf)
  Parameters:
    _tf (string)

GetHTFoffsetToLTFoffset(_offset, _chartTf, _htfTf)
  GetHTFoffsetToLTFoffset
description Adjust an HTF offset to an LTF offset by calculating the ratio of timeframes.
  Parameters:
    _offset (int): int The HTF bar offset (0 means current HTF bar).
    _chartTf (string): string The current chart's timeframe (e.g., "5", "15", "1D").
    _htfTf (string): string The High Time Frame string (e.g., "60", "1D").
return int The corresponding LTF bar index. Returns 0 if the result is negative.

GetHtfFromLabel(_label)
  GetHtfFromLabel
description Convert a Korean HTF label into a Pine Script timeframe string.
  Parameters:
    _label (string): string The Korean label (e.g., "5분", "1시간").
return string Returns the corresponding Pine Script timeframe (e.g., "5", "60").

IsChartTFcomparisonHTF(_chartTf, _htfTf)
  IsChartTFcomparisonHTF
description Determine whether a given HTF is greater than or equal to the current chart timeframe.
  Parameters:
    _chartTf (string): string Current chart timeframe (e.g., "5", "15", "1D").
    _htfTf (string): string HTF timeframe (e.g., "60", "1D").
return bool True if HTF ≥ chartTF, false otherwise.

IsCondition(_boxType, _isBull, _pricePrev, _priceNow)
  IsCondition
description FOB, FVG 조건 체크.\
_boxType: "fob"(Fair Order Block) 또는 "fvg"(Fair Value Gap).\
_isBull: true(상승 패턴), false(하락 패턴).\
상승 시 현재 가격이 이전 가격보다 높으면 true, 하락 시 이전 가격이 현재 가격보다 높으면 true 반환.
  Parameters:
    _boxType (string): 박스 타입 ("fob", "fvg")
    _isBull (bool): 상승(true) 또는 하락(false)
    _pricePrev (float): 이전 가격
    _priceNow (float): 현재 가격
  Returns: bool 조건 만족 여부

IsCondition(_boxType, _high2, _high1, _high0, _low2, _low1, _low0)
  IsCondition
description Sweep 조건 체크 (Swing High/Low 동시 발생).\
_boxType: "sweep" 또는 "breachBoth".\
조건: high2 < high1 > high0 (Swing High) AND low2 > low1 < low0 (Swing Low).\
중간 캔들이 양쪽보다 높고 낮은 지점을 동시에 형성할 때 true 반환.
  Parameters:
    _boxType (string): 박스 타입 ("sweep", "breachBoth")
    _high2 (float)
    _high1 (float)
    _high0 (float)
    _low2 (float)
    _low1 (float)
    _low0 (float)
  Returns: bool 조건 만족 여부

IsCondition(_boxType, _isBull, _open1, _close1, _high1, _low1, _open0, _close0, _low2, _low3, _high2, _high3)
  IsCondition
description RB (Rejection Block) 조건 체크.\
_boxType: "rb" (Rejection Block).\
상승 RB: candle1=음봉, candle0=양봉, low3>low1 AND low2>low1, close1*1.001>open0, open1<close0.\
하락 RB: candle1=양봉, candle0=음봉, high3<high1 AND high2<high1, close1*0.999<open0, open1>close0.\
이전 캔들의 거부 후 현재 캔들이 반대 방향으로 전환될 때 true 반환.
  Parameters:
    _boxType (string): 박스 타입 ("rb")
    _isBull (bool): 상승(true) 또는 하락(false)
    _open1 (float)
    _close1 (float)
    _high1 (float)
    _low1 (float)
    _open0 (float)
    _close0 (float)
    _low2 (float)
    _low3 (float)
    _high2 (float)
    _high3 (float)
  Returns: bool 조건 만족 여부

IsCondition(_boxType, _isBull, _open2, _close1, _open1, _close0)
  IsCondition
description SOB (Strong Order Block) 조건 체크.\
_boxType: "sob" (Strong Order Block).\
상승 SOB: 양봉2 => 음봉1 => 양봉0, open2 > close1 AND open1 < close0.\
하락 SOB: 음봉2 => 양봉1 => 음봉0, open2 < close1 AND open1 > close0.\
3개 캔들 패턴으로 강한 주문 블록 형성 시 true 반환.
  Parameters:
    _boxType (string): 박스 타입 ("sob")
    _isBull (bool): 상승(true) 또는 하락(false)
    _open2 (float): 2개 이전 캔들 open
    _close1 (float): 1개 이전 캔들 close
    _open1 (float): 1개 이전 캔들 open
    _close0 (float): 현재 캔들 close
  Returns: bool 조건 만족 여부

CreateBox(_boxType, _boxState, _breachModeStart, _breachModeEnd, _isBull, _leftTime, _rightTime, _top, _bottom, _useLine, _colorBG, _colorBD, _colorText, _customText)
  CreateBox
description 박스 생성 (값 전달 방식 - 모든 좌표 직접 지정).\
호출자가 모든 좌표와 시간을 계산하여 전달.\
HTF/LTF 구분 불필요, tf/cache 계산 없음.\
  Parameters:
    _boxType (string): 박스 타입 ("sob", "fob", "rb", "custom" 등)
    _boxState (string): 박스 상태 ("pending", "start", "extension")
    _breachModeStart (string): 시작 돌파 처리 방식
    _breachModeEnd (string): 종료 돌파 처리 방식
    _isBull (bool): 상승(true) 또는 하락(false)
    _leftTime (int): 박스 시작 시간
    _rightTime (int): 박스 종료 시간
    _top (float): 박스 상단 가격
    _bottom (float): 박스 하단 가격
    _useLine (bool): 중간선 표시 여부
    _colorBG (color): 박스 배경색
    _colorBD (color): 박스 테두리색
    _colorText (color): 텍스트 색상
    _customText (string): 커스텀 텍스트
  Returns: [bool, BoxData] 성공 여부와 박스 데이터

CreateBox(_boxType, _boxState, _tf, _isBull, _useLine, _colorBG, _colorBD, _colorText, _cache)
  CreateBox (자동 계산 방식)
description 박스 생성 (tf/cache 기반 자동 좌표 계산).\
라이브러리가 boxType에 따라 좌표를 자동 계산.\
  Parameters:
    _boxType (string): 박스 타입
    _boxState (string): 박스 상태 ("pending", "start", "extension")
    _tf (string): 시간대
    _isBull (bool): 상승(true) 또는 하락(false)
    _useLine (bool): 중간선 표시 여부
    _colorBG (color): 박스 배경색
    _colorBD (color): 박스 테두리색
    _colorText (color): 텍스트 색상
    _cache (HTFCache): HTF 캐시 데이터
  Returns: [bool, BoxData] 성공 여부와 박스 데이터

ProcessBoxDatas(_openBoxes, _closedBoxes, _useMidLine, _closeCount, _baseColor, _pendingTransparency, _startTransparency, _endTransparency, _currentBarIndex, _currentLow, _currentHigh, _currentClose, _currentTime)
  ProcessBoxDatas
description 박스 확장 및 상태별 돌파 처리.\
열린 박스들을 현재 bar까지 확장하고, 상태별 돌파 조건 체크.\
PENDING: 시작 조건 체크 → START 전환\
START: 종료 조건 체크 → END 전환\
EXTENSION: 무한 확장\
종료된 박스는 _closedBoxes로 이동하고 _colorClose 색상 적용.\
  Parameters:
    _openBoxes (array<BoxData>): 열린 박스 배열
    _closedBoxes (array<BoxData>): 닫힌 박스 배열
    _useMidLine (bool): 중간선 표시 여부
    _closeCount (int): 돌파 카운트 (이 횟수만큼 돌파 시 종료)
    _baseColor (color): 기본 색상
    _pendingTransparency (int): 대기 상태 불투명도
    _startTransparency (int): 시작 상태 불투명도
    _endTransparency (int): 종료 상태 불투명도
    _currentBarIndex (int): 현재 bar_index
    _currentLow (float): 현재 low
    _currentHigh (float): 현재 high
    _currentClose (float): 현재 close
    _currentTime (int): 현재 time
  Returns: bool 항상 true

BoxType
  BoxType
  Fields:
    FOB (series string)
    FVG (series string)
    IFVG (series string)
    SOB (series string)
    RB (series string)
    BB (series string)
    MB (series string)
    SWEEP (series string)
    CUSTOM (series string)

BreachMode
  BreachMode
  Fields:
    BOTH_HIGH_LOW (series string)
    BOTH_CLOSE (series string)
    DIRECTIONAL_HIGH_LOW (series string)
    DIRECTIONAL_CLOSE (series string)
    NEAR_HIGH (series string)
    NEAR_CLOSE (series string)
    NEAR_LOW (series string)
    FAR_HIGH (series string)
    FAR_CLOSE (series string)
    FAR_LOW (series string)

BoxState
  BoxState
  Fields:
    PENDING (series string)
    START (series string)
    END (series string)
    EXTENSION (series string)

BoxData
  BoxData
  Fields:
    _type (series string): 박스 타입
    _breachModeStart (series string): 시작 돌파 처리 방식
    _breachModeEnd (series string): 종료 돌파 처리 방식
    _boxState (series string): 박스 상태
    _isBull (series bool): 상승(true) 또는 하락(false) 방향
    _box (series box)
    _line (series line)
    _boxTop (series float)
    _boxBot (series float)
    _boxMid (series float)
    _topBreached (series bool)
    _bottomBreached (series bool)
    _breakCount (series int)

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)
Информация о релизе
v2

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.