PINE LIBRARY
Updated Mirpapa_Lib_SwingHighLow

Library "Mirpapa_Lib_SwingHighLow"
스윙하이/로우 감지 및 관리 라이브러리
_SwingHigh(_price2, _price1, _price)
3개 캔들로 스윙하이 감지 (좌우 1개씩)
Parameters:
_price2 (float): 2번째 이전 가격 (좌측 캔들)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price3, _price2, _price1, _price)
4개 캔들로 스윙하이 감지 (좌측 2개, 우측 1개)
Parameters:
_price3 (float): 3번째 이전 가격 (좌측 첫번째)
_price2 (float): 2번째 이전 가격 (좌측 두번째)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price4, _price3, _price2, _price1, _price)
5개 캔들로 스윙하이 감지 (좌우 2개씩)
Parameters:
_price4 (float): 4번째 이전 가격 (좌측 첫번째)
_price3 (float): 3번째 이전 가격 (좌측 두번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price5, _price4, _price3, _price2, _price1, _price)
6개 캔들로 스윙하이 감지 (좌측 3개, 우측 2개)
Parameters:
_price5 (float): 5번째 이전 가격 (좌측 첫번째)
_price4 (float): 4번째 이전 가격 (좌측 두번째)
_price3 (float): 3번째 이전 가격 (좌측 세번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingLow(_price2, _price1, _price)
3개 캔들로 스윙로우 감지 (좌우 1개씩)
Parameters:
_price2 (float): 2번째 이전 가격 (좌측 캔들)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price3, _price2, _price1, _price)
4개 캔들로 스윙로우 감지 (좌측 2개, 우측 1개)
Parameters:
_price3 (float): 3번째 이전 가격 (좌측 첫번째)
_price2 (float): 2번째 이전 가격 (좌측 두번째)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price4, _price3, _price2, _price1, _price)
5개 캔들로 스윙로우 감지 (좌우 2개씩)
Parameters:
_price4 (float): 4번째 이전 가격 (좌측 첫번째)
_price3 (float): 3번째 이전 가격 (좌측 두번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price5, _price4, _price3, _price2, _price1, _price)
6개 캔들로 스윙로우 감지 (좌측 3개, 우측 2개)
Parameters:
_price5 (float): 5번째 이전 가격 (좌측 첫번째)
_price4 (float): 4번째 이전 가격 (좌측 두번째)
_price3 (float): 3번째 이전 가격 (좌측 세번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingCheck(_isType, _price2, _price1, _price)
스윙 타입에 따른 감지 (통합 함수)
Parameters:
_isType (bool): 스윙 타입 (true: 스윙하이, false: 스윙로우)
_price2 (float): 2번째 이전 가격
_price1 (float): 1번째 이전 가격
_price (float): 현재 가격
Returns: bool 스윙 감지 여부
_CreateSwingBox(priceHigh, priceLow, barIndex, state, swingType)
스윙 박스 생성
Parameters:
priceHigh (float): 박스 상단 가격
priceLow (float): 박스 하단 가격
barIndex (int): 생성 bar_index
state (string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY")
swingType (string): 스윙 타입 ("HIGH", "LOW")
Returns: box 생성된 박스 객체
_ExtendSwingBox(boxObj)
박스 우측 확장
Parameters:
boxObj (box): 박스 객체
Returns: void
_TerminateSwingBox(boxObj)
박스 종료 처리 (색상 변경)
Parameters:
boxObj (box): 박스 객체
Returns: void
_AddSwingHigh(swingArray, priceHigh, priceLow, barIndex, state)
스윙하이 배열 추가
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
priceHigh (float): 고가
priceLow (float): 저가 (close)
barIndex (int): 생성 bar_index
state (string): 상태
Returns: bool 추가 성공 여부
_AddSwingLow(swingArray, priceHigh, priceLow, barIndex, state)
스윙로우 배열 추가
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
priceHigh (float): 고가 (close)
priceLow (float): 저가
barIndex (int): 생성 bar_index
state (string): 상태
Returns: bool 추가 성공 여부
_RemoveSwingHighByBarIndex(swingArray, targetBarIndex)
bar_index로 스윙하이 배열 요소 제거
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
targetBarIndex (int): 제거할 bar_index
Returns: bool 제거 성공 여부
_RemoveSwingLowByBarIndex(swingArray, targetBarIndex)
bar_index로 스윙로우 배열 요소 제거
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
targetBarIndex (int): 제거할 bar_index
Returns: bool 제거 성공 여부
_ExtendSwingHighBoxes(swingArray)
활성 스윙하이 박스들 확장
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
Returns: void
_ExtendSwingLowBoxes(swingArray)
활성 스윙로우 박스들 확장
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
Returns: void
_CheckSwingHighBreakout(swingArray, currentHigh, hideBreakoutBox)
스윙하이 돌파 체크 및 종료 처리
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
currentHigh (float): 현재 고가
hideBreakoutBox (bool): 돌파박스 감추기 옵션
Returns: void
_CheckSwingLowBreakout(swingArray, currentLow, hideBreakoutBox)
스윙로우 돌파 체크 및 종료 처리
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
currentLow (float): 현재 저가
hideBreakoutBox (bool): 돌파박스 감추기 옵션
Returns: void
_CleanupTerminatedSwings(swingHighArray, swingLowArray, maxKeepCount)
종료된 스윙들 정리 (메모리 절약)
Parameters:
swingHighArray (array<SwingHigh>): 스윙하이 배열
swingLowArray (array<SwingLow>): 스윙로우 배열
maxKeepCount (int): 유지할 최대 개수
Returns: void
SwingHigh
스윙하이 정보를 저장하는 타입
Fields:
_priceHigh (series float): 스윙하이 가격 (high)
_priceLow (series float): 스윙로우 가격 (close)
_barIndexStart (series int): 생성시 bar_index
_box (series box): 시각적 박스 객체
_state (series string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY", "TERMINATED")
SwingLow
스윙로우 정보를 저장하는 타입
Fields:
_priceHigh (series float): 스윙하이 가격 (close)
_priceLow (series float): 스윙로우 가격 (low)
_barIndexStart (series int): 생성시 bar_index
_box (series box): 시각적 박스 객체
_state (series string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY", "TERMINATED")
스윙하이/로우 감지 및 관리 라이브러리
_SwingHigh(_price2, _price1, _price)
3개 캔들로 스윙하이 감지 (좌우 1개씩)
Parameters:
_price2 (float): 2번째 이전 가격 (좌측 캔들)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price3, _price2, _price1, _price)
4개 캔들로 스윙하이 감지 (좌측 2개, 우측 1개)
Parameters:
_price3 (float): 3번째 이전 가격 (좌측 첫번째)
_price2 (float): 2번째 이전 가격 (좌측 두번째)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price4, _price3, _price2, _price1, _price)
5개 캔들로 스윙하이 감지 (좌우 2개씩)
Parameters:
_price4 (float): 4번째 이전 가격 (좌측 첫번째)
_price3 (float): 3번째 이전 가격 (좌측 두번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingHigh(_price5, _price4, _price3, _price2, _price1, _price)
6개 캔들로 스윙하이 감지 (좌측 3개, 우측 2개)
Parameters:
_price5 (float): 5번째 이전 가격 (좌측 첫번째)
_price4 (float): 4번째 이전 가격 (좌측 두번째)
_price3 (float): 3번째 이전 가격 (좌측 세번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙하이 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙하이 여부 (true: 스윙하이, false: 아님)
_SwingLow(_price2, _price1, _price)
3개 캔들로 스윙로우 감지 (좌우 1개씩)
Parameters:
_price2 (float): 2번째 이전 가격 (좌측 캔들)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price3, _price2, _price1, _price)
4개 캔들로 스윙로우 감지 (좌측 2개, 우측 1개)
Parameters:
_price3 (float): 3번째 이전 가격 (좌측 첫번째)
_price2 (float): 2번째 이전 가격 (좌측 두번째)
_price1 (float): 1번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price (float): 현재 가격 (우측 캔들)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price4, _price3, _price2, _price1, _price)
5개 캔들로 스윙로우 감지 (좌우 2개씩)
Parameters:
_price4 (float): 4번째 이전 가격 (좌측 첫번째)
_price3 (float): 3번째 이전 가격 (좌측 두번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingLow(_price5, _price4, _price3, _price2, _price1, _price)
6개 캔들로 스윙로우 감지 (좌측 3개, 우측 2개)
Parameters:
_price5 (float): 5번째 이전 가격 (좌측 첫번째)
_price4 (float): 4번째 이전 가격 (좌측 두번째)
_price3 (float): 3번째 이전 가격 (좌측 세번째)
_price2 (float): 2번째 이전 가격 (중심 캔들, 스윙로우 후보)
_price1 (float): 1번째 이전 가격 (우측 첫번째)
_price (float): 현재 가격 (우측 두번째)
Returns: bool 스윙로우 여부 (true: 스윙로우, false: 아님)
_SwingCheck(_isType, _price2, _price1, _price)
스윙 타입에 따른 감지 (통합 함수)
Parameters:
_isType (bool): 스윙 타입 (true: 스윙하이, false: 스윙로우)
_price2 (float): 2번째 이전 가격
_price1 (float): 1번째 이전 가격
_price (float): 현재 가격
Returns: bool 스윙 감지 여부
_CreateSwingBox(priceHigh, priceLow, barIndex, state, swingType)
스윙 박스 생성
Parameters:
priceHigh (float): 박스 상단 가격
priceLow (float): 박스 하단 가격
barIndex (int): 생성 bar_index
state (string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY")
swingType (string): 스윙 타입 ("HIGH", "LOW")
Returns: box 생성된 박스 객체
_ExtendSwingBox(boxObj)
박스 우측 확장
Parameters:
boxObj (box): 박스 객체
Returns: void
_TerminateSwingBox(boxObj)
박스 종료 처리 (색상 변경)
Parameters:
boxObj (box): 박스 객체
Returns: void
_AddSwingHigh(swingArray, priceHigh, priceLow, barIndex, state)
스윙하이 배열 추가
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
priceHigh (float): 고가
priceLow (float): 저가 (close)
barIndex (int): 생성 bar_index
state (string): 상태
Returns: bool 추가 성공 여부
_AddSwingLow(swingArray, priceHigh, priceLow, barIndex, state)
스윙로우 배열 추가
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
priceHigh (float): 고가 (close)
priceLow (float): 저가
barIndex (int): 생성 bar_index
state (string): 상태
Returns: bool 추가 성공 여부
_RemoveSwingHighByBarIndex(swingArray, targetBarIndex)
bar_index로 스윙하이 배열 요소 제거
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
targetBarIndex (int): 제거할 bar_index
Returns: bool 제거 성공 여부
_RemoveSwingLowByBarIndex(swingArray, targetBarIndex)
bar_index로 스윙로우 배열 요소 제거
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
targetBarIndex (int): 제거할 bar_index
Returns: bool 제거 성공 여부
_ExtendSwingHighBoxes(swingArray)
활성 스윙하이 박스들 확장
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
Returns: void
_ExtendSwingLowBoxes(swingArray)
활성 스윙로우 박스들 확장
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
Returns: void
_CheckSwingHighBreakout(swingArray, currentHigh, hideBreakoutBox)
스윙하이 돌파 체크 및 종료 처리
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
currentHigh (float): 현재 고가
hideBreakoutBox (bool): 돌파박스 감추기 옵션
Returns: void
_CheckSwingLowBreakout(swingArray, currentLow, hideBreakoutBox)
스윙로우 돌파 체크 및 종료 처리
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
currentLow (float): 현재 저가
hideBreakoutBox (bool): 돌파박스 감추기 옵션
Returns: void
_CleanupTerminatedSwings(swingHighArray, swingLowArray, maxKeepCount)
종료된 스윙들 정리 (메모리 절약)
Parameters:
swingHighArray (array<SwingHigh>): 스윙하이 배열
swingLowArray (array<SwingLow>): 스윙로우 배열
maxKeepCount (int): 유지할 최대 개수
Returns: void
SwingHigh
스윙하이 정보를 저장하는 타입
Fields:
_priceHigh (series float): 스윙하이 가격 (high)
_priceLow (series float): 스윙로우 가격 (close)
_barIndexStart (series int): 생성시 bar_index
_box (series box): 시각적 박스 객체
_state (series string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY", "TERMINATED")
SwingLow
스윙로우 정보를 저장하는 타입
Fields:
_priceHigh (series float): 스윙하이 가격 (close)
_priceLow (series float): 스윙로우 가격 (low)
_barIndexStart (series int): 생성시 bar_index
_box (series box): 시각적 박스 객체
_state (series string): 스윙 상태 ("BASIC", "SWEEP", "ENTRY", "TERMINATED")
Release Notes
v2업데이트됨
_AddSwingHigh(swingArray, priceHigh, priceLow, barIndex, state, _isDisplay)
스윙하이 배열 추가
Parameters:
swingArray (array<SwingHigh>): 스윙하이 배열
priceHigh (float): 고가
priceLow (float): 저가 (close)
barIndex (int): 생성 bar_index
state (string): 상태
_isDisplay (bool): 박스 표시 여부
Returns: bool 추가 성공 여부
_AddSwingLow(swingArray, priceHigh, priceLow, barIndex, state, _isDisplay)
스윙로우 배열 추가
Parameters:
swingArray (array<SwingLow>): 스윙로우 배열
priceHigh (float): 고가 (close)
priceLow (float): 저가
barIndex (int): 생성 bar_index
state (string): 상태
_isDisplay (bool): 박스 표시 여부
Returns: bool 추가 성공 여부
Release Notes
v3더해짐
_CreateSwingHigh(priceHigh, priceLow, barIndex, state, boxObj)
스윙하이 객체 생성
Parameters:
priceHigh (float): 고가
priceLow (float): 저가 (close)
barIndex (int): 생성 bar_index
state (string): 상태
boxObj (box): 박스 객체 (na 가능)
Returns: SwingHigh 생성된 스윙하이 객체
_CreateSwingLow(priceHigh, priceLow, barIndex, state, boxObj)
스윙로우 객체 생성
Parameters:
priceHigh (float): 고가 (close)
priceLow (float): 저가
barIndex (int): 생성 bar_index
state (string): 상태
boxObj (box): 박스 객체 (na 가능)
Returns: SwingLow 생성된 스윙로우 객체
없어짐
_AddSwingHigh(swingArray, priceHigh, priceLow, barIndex, state, _isDisplay)
스윙하이 배열 추가
_AddSwingLow(swingArray, priceHigh, priceLow, barIndex, state, _isDisplay)
스윙로우 배열 추가
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
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.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
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.