SharelineUI_LibraryLibrary "SharelineUI_Library"
get_text_size(opt)
Parameters:
opt (string)
status_color(val)
Parameters:
val (float)
trend_color(trend_cat)
Parameters:
trend_cat (string)
momentum_color(score, bullTh, bearTh)
Parameters:
score (float)
bullTh (float)
bearTh (float)
create_standard_hud(pos, cols, rows)
Parameters:
pos (string)
cols (int)
rows (int)
Display
Mirpapa_Lib_StructLibrary "Mirpapa_Lib_Struct"
ICT 구조 변화 감지 라이브러리 (BOS, CHoCH, MSS, Sweep)
initStructState()
StructState 초기화
checkBOS(_trend, _currentClose, _lastHHPrice, _lastLLPrice)
BOS 체크 (추세 지속) - 종가 기준
Parameters:
_trend (string) : 현재 추세
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkCHoCH(_trend, _currentClose, _lastHHPrice, _lastLLPrice)
CHoCH 체크 (추세 전환) - 종가 기준
Parameters:
_trend (string) : 현재 추세
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkSweep(_currentHigh, _currentLow, _currentClose, _lastHHPrice, _lastLLPrice)
Sweep 체크 (유동성 수집) 설명
Parameters:
_currentHigh (float) : 현재 고가
_currentLow (float) : 현재 저가
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkMSS(_hadCHoCH, _chochDir, _currentHigh, _currentLow, _chochPrice)
MSS 체크 (CHoCH + 리테스트 확인)
Parameters:
_hadCHoCH (bool) : CHoCH 발생 여부
_chochDir (string) : CHoCH 방향
_currentHigh (float) : 현재 고가
_currentLow (float) : 현재 저가
_chochPrice (float) : CHoCH 발생 가격
Returns:
drawStructLabel(_price, _time, _type, _dir, _lblColor)
구조 변화 라벨 그리기
Parameters:
_price (float) : 가격
_time (int) : 시간
_type (string) : 구조 타입
_dir (string) : 방향
_lblColor (color) : 라벨 색상
drawStructLine(_price, _startTime, _endTime, _lineColor, _lineWidth)
구조 변화 라인 그리기
Parameters:
_price (float) : 가격
_startTime (int) : 시작 시간
_endTime (int) : 끝 시간
_lineColor (color) : 라인 색상
_lineWidth (int) : 라인 두께
StructType
구조 타입 상수
Fields:
BOS (series string)
CHOCH (series string)
MSS (series string)
SWEEP (series string)
TrendDir
추세 방향 상수
Fields:
UP (series string)
DOWN (series string)
NONE (series string)
StructState
구조 변화 상태
Fields:
_trend (series string) : 현재 추세 방향
_lastHHPrice (series float) : 마지막 HH 가격
_lastHHTime (series int) : 마지막 HH 시간
_lastLLPrice (series float) : 마지막 LL 가격
_lastLLTime (series int) : 마지막 LL 시간
_peakHHPrice (series float) : 최고 HH 가격 (BOS 레벨용)
_peakHHTime (series int) : 최고 HH 시간
_peakLLPrice (series float) : 최저 LL 가격 (BOS 레벨용)
_peakLLTime (series int) : 최저 LL 시간
_bosLevelHH (series float) : BOS 체크용 HH 레벨 (확정된 최고 HH)
_bosLevelHHTime (series int) : BOS 체크용 HH 시간
_bosLevelLL (series float) : BOS 체크용 LL 레벨 (확정된 최저 LL)
_bosLevelLLTime (series int) : BOS 체크용 LL 시간
Mirpapa_Lib_UnicornLibrary "Mirpapa_Lib_Unicorn"
유니콘 패턴 라이브러리 (Unicorn Pattern Library)
유니콘 모델 전략 로직, 데이터 구조체 및 상태 관리를 구현합니다.
initUnicornData(_isBull, _createTime, _createBar, _timeframe)
UnicornData 초기화
@description 새로운 UnicornData 객체를 생성하고 초기화합니다.
Parameters:
_isBull (bool) : 방향 (True: 상승, False: 하락)
_createTime (int) : 생성 시간
_createBar (int) : 생성 Bar Index
_timeframe (string) : 시간대
calculateOverlap(_obTop, _obBot, _fvgTop, _fvgBot)
중첩 영역(Overlap Zone) 계산
@description OB와 FVG 사이의 겹치는 영역을 계산합니다.
Parameters:
_obTop (float) : OB 상단
_obBot (float) : OB 하단
_fvgTop (float) : FVG 상단
_fvgBot (float) : FVG 하단
Returns: 겹침 영역 상단, 하단, 겹침 여부
updateUnicornStatus(_data, _currentHigh, _currentLow, _time)
유니콘 상태 업데이트
@description 가격 움직임에 따라 유니콘 패턴의 상태를 업데이트합니다.
active: 진입 대기 (리테스트 대기) -> triggered: 진입 (TP/SL 대기) -> win/loss: 결과 확정
Parameters:
_data (UnicornData) : UnicornData 객체
_currentHigh (float) : 현재 고가
_currentLow (float) : 현재 저가
_time (int) : 현재 시간
Returns: UnicornData 업데이트된 객체
activateUnicorn(_data)
유니콘 활성화 (Active 전환)
@description Pending 상태인 유니콘 데이터를 Active 상태로 전환합니다. (보통 CHoCH 발생 시 호출)
Parameters:
_data (UnicornData) : UnicornData 객체
setTradeLevels(_data, _entry, _stop, _target)
트레이딩 레벨 설정
@description 진입가, 목표가, 손절가를 설정합니다.
Parameters:
_data (UnicornData) : UnicornData 객체
_entry (float) : 진입가
_stop (float) : 손절가
_target (float) : 목표가
UnicornData
유니콘 데이터 (UnicornData)
Fields:
_isBull (series bool) : // 상승/하락 방향 (True: Long, False: Short)
_status (series string) : // "pending", "active", "triggered", "win", "loss", "cancelled"
_createTime (series int) : // 생성 시간
_createBar (series int) : // 생성 bar_index
_obTop (series float) : // OB 상단
_obBot (series float) : // OB 하단
_obTime (series int) : // OB 캔들 시간
_obBox (series box) : // OB 박스 객체
_fvgTop (series float) : // FVG 상단
_fvgBot (series float) : // FVG 하단
_fvgTime (series int) : // FVG 시간
_fvgBox (series box) : // FVG 박스 객체
_zoneTop (series float) : // 겹침 영역 상단 (Unicorn Zone)
_zoneBot (series float) : // 겹침 영역 하단 (Unicorn Zone)
_zoneBox (series box) : // Unicorn Zone 박스 객체
_chochConfirmed (series bool) : // CHoCH 확정 여부
_chochTime (series int) : // CHoCH 발생 시간
_chochPrice (series float) : // CHoCH 돌파 가격
_entryPrice (series float) : // 진입가
_targetPrice (series float) : // 목표가 (다음 유동성 레벨)
_stopPrice (series float) : // 손절가 (Zone 반대편)
_result (series string) : // "none", "win", "loss"
_resultTime (series int) : // 결과 확정 시간
_resultPrice (series float) : // 결과 확정 가격
_profitPips (series float) : // 수익 pips (양수)
_lossPips (series float) : // 손실 pips (음수)
_profitPercent (series float) : // 수익 %
_lossPercent (series float) : // 손실 %
_rrRatio (series float) : // Risk:Reward 비율
_timeframe (series string) : // 시간대 (HTF/MTF/CTF)
_triggerTime (series int) : // 진입 트리거 시간 (리테스트)
_triggerPrice (series float) : // 진입 트리거 가격
_isRetested (series bool) : // 리테스트 여부
_retestCount (series int) : // 리테스트 횟수
_maxDrawdown (series float) : // 최대 손실폭 (진입 후)
_maxProfit (series float) : // 최대 수익폭 (진입 후)
Mirpapa_Lib_BoxLibrary "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, open1close0.\
이전 캔들의 거부 후 현재 캔들이 반대 방향으로 전환될 때 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: 성공 여부와 박스 데이터
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: 성공 여부와 박스 데이터
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) : 열린 박스 배열
_closedBoxes (array) : 닫힌 박스 배열
_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)
Mirpapa_Lib_StructsLibrary "Mirpapa_Lib_Structs"
ICT 구조 변화 감지 라이브러리 (BOS, CHoCH, MSS, Sweep)
initStructState()
StructState 초기화
checkBOS(_trend, _currentClose, _lastHHPrice, _lastLLPrice)
BOS 체크 (추세 지속) - 종가 기준
Parameters:
_trend (string) : 현재 추세
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkCHoCH(_trend, _currentClose, _lastHHPrice, _lastLLPrice)
CHoCH 체크 (추세 전환) - 종가 기준
Parameters:
_trend (string) : 현재 추세
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkSweep(_currentHigh, _currentLow, _currentClose, _lastHHPrice, _lastLLPrice)
Sweep 체크 (유동성 수집)
Parameters:
_currentHigh (float) : 현재 고가
_currentLow (float) : 현재 저가
_currentClose (float) : 현재 종가
_lastHHPrice (float) : 마지막 HH 가격
_lastLLPrice (float) : 마지막 LL 가격
Returns:
checkMSS(_hadCHoCH, _chochDir, _currentHigh, _currentLow, _chochPrice)
MSS 체크 (CHoCH + 리테스트 확인)
Parameters:
_hadCHoCH (bool) : CHoCH 발생 여부
_chochDir (string) : CHoCH 방향
_currentHigh (float) : 현재 고가
_currentLow (float) : 현재 저가
_chochPrice (float) : CHoCH 발생 가격
Returns:
drawStructLabel(_price, _time, _type, _dir, _lblColor)
구조 변화 라벨 그리기
Parameters:
_price (float) : 가격
_time (int) : 시간
_type (string) : 구조 타입
_dir (string) : 방향
_lblColor (color) : 라벨 색상
drawStructLine(_price, _startTime, _endTime, _lineColor, _lineWidth)
구조 변화 라인 그리기
Parameters:
_price (float) : 가격
_startTime (int) : 시작 시간
_endTime (int) : 끝 시간
_lineColor (color) : 라인 색상
_lineWidth (int) : 라인 두께
StructType
구조 타입 상수
Fields:
BOS (series string)
CHOCH (series string)
MSS (series string)
SWEEP (series string)
TrendDir
추세 방향 상수
Fields:
UP (series string)
DOWN (series string)
NONE (series string)
StructState
구조 변화 상태
Fields:
_trend (series string) : 현재 추세 방향
_lastHHPrice (series float) : 마지막 HH 가격
_lastHHTime (series int) : 마지막 HH 시간
_lastLLPrice (series float) : 마지막 LL 가격
_lastLLTime (series int) : 마지막 LL 시간
CEDEARDataLibrary "CEDEARData"
getUnderlying(cedearTicker)
Parameters:
cedearTicker (simple string)
getRatio(cedearTicker)
Parameters:
cedearTicker (simple string)
getCurrency(cedearTicker)
Parameters:
cedearTicker (simple string)
isValidCedear(cedearTicker)
Parameters:
cedearTicker (simple string)
Mirpapa_Lib_LineLibrary "Mirpapa_Lib_Line"
CreateLine(_breachMode, _isBull, _leftTime, _rightTime, _price, _lineColor, _lineWidth, _lineStyle, _text)
CreateLine
@description 라인 생성 (값 전달 방식 - 모든 좌표 직접 지정).\
호출자가 모든 좌표와 시간을 계산하여 전달.\
breachMode: "price"(고가/저가 돌파) 또는 "close"(종가 돌파).\
Parameters:
_breachMode (string) : 돌파 처리 방식: "price" 또는 "close"
_isBull (bool) : 상승(true) 또는 하락(false)
_leftTime (int) : 라인 시작 시간
_rightTime (int) : 라인 종료 시간
_price (float) : 라인 가격
_lineColor (color) : 라인 색상
_lineWidth (int) : 라인 두께
_lineStyle (string) : 라인 스타일 (line.style_solid, line.style_dashed 등)
_text (string) : 라인 텍스트
Returns: 성공 여부와 라인 데이터
ProcessLineDatas(_openLines, _closedLines, _closeCount, _colorClose, _currentBarIndex, _currentLow, _currentHigh, _currentTime)
ProcessLineDatas
@description 라인 확장 및 돌파 처리.\
열린 라인들을 현재 bar까지 확장하고, 돌파 조건 체크.\
_closeCount: 돌파 횟수 (이 횟수만큼 돌파 시 라인 종료).\
breachMode에 따라 돌파 체크 방식 다름 (price/close).\
종료된 라인은 _closedLines로 이동하고 _colorClose 색상 적용.\
barstate.islast와 barstate.isconfirmed에서 호출 권장.
Parameters:
_openLines (array) : 열린 라인 배열
_closedLines (array) : 닫힌 라인 배열
_closeCount (int) : 돌파 카운트 (이 횟수만큼 돌파 시 종료)
_colorClose (color) : 종료된 라인 색상
_currentBarIndex (int) : 현재 bar_index
_currentLow (float) : 현재 low
_currentHigh (float) : 현재 high
_currentTime (int) : 현재 time
Returns: bool 항상 true
BreachMode
BreachMode
Fields:
PRICE (series string)
CLOSE (series string)
LineData
LineData
Fields:
_breachMode (series string) : 돌파 처리 방식
_isBull (series bool) : 상승(true) 또는 하락(false) 방향
_line (series line) : 라인 객체
_price (series float) : 라인 가격
_text (series string) : 라인 텍스트
_breached (series bool) : 돌파 여부
_breakCount (series int) : 돌파 카운트
MirPapa_Lib_BoxLibrary "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, open1close0.\
이전 캔들의 거부 후 현재 캔들이 반대 방향으로 전환될 때 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, _tf, _isBull, _useLine, _colorBG, _colorBD, _colorText, _cache)
CreateBox
@description 박스 생성 (breachMode 자동 결정).\
_boxType: "fob", "rb", "custom" → directionalHighLow, 나머지 → both.\
_tf: 시간대 (timeframe.period 또는 HTF).\
_isBull: true(상승 박스), false(하락 박스).\
_cache: HTF 사용 시 필수, CurrentTF는 na.\
반환: .
Parameters:
_boxType (string) : 박스 타입
_tf (string) : 시간대
_isBull (bool) : 상승(true) 또는 하락(false)
_useLine (bool) : 중간선 표시 여부
_colorBG (color) : 박스 배경색
_colorBD (color) : 박스 테두리색
_colorText (color) : 텍스트 색상
_cache (HTFCache) : HTF 캐시 데이터
Returns: 성공 여부와 박스 데이터
CreateBox(_boxType, _tf, _isBull, _useLine, _colorBG, _colorBD, _colorText, _cache, _customText)
CreateBox
@description 박스 생성 (커스텀 텍스트 지원, breachMode 자동 결정).\
_boxType: "fob", "rb", "custom" → directionalHighLow, 나머지 → both.\
_customText: 박스에 표시할 텍스트 (비어있으면 "시간대 박스타입" 형식으로 자동 생성).\
_isBull: true(상승 박스), false(하락 박스).\
반환: .
Parameters:
_boxType (string) : 박스 타입
_tf (string) : 시간대
_isBull (bool) : 상승(true) 또는 하락(false)
_useLine (bool) : 중간선 표시 여부
_colorBG (color) : 박스 배경색
_colorBD (color) : 박스 테두리색
_colorText (color) : 텍스트 색상
_cache (HTFCache) : HTF 캐시 데이터
_customText (string) : 커스텀 텍스트
Returns: 성공 여부와 박스 데이터
CreateBox(_boxType, _breachMode, _tf, _isBull, _useLine, _colorBG, _colorBD, _colorText, _cache, _customText)
CreateBox
@description 박스 생성 (breachMode 명시적 지정).\
_breachMode: "both"(양쪽 모두 돌파), "directionalHighLow"(방향성 high/low 돌파), "directionalClose"(방향성 close 돌파).\
_isBull: true(상승 박스), false(하락 박스).\
_customText: 박스에 표시할 텍스트 (비어있으면 "시간대 박스타입" 형식으로 자동 생성).\
반환: .
Parameters:
_boxType (string) : 박스 타입 (fob, fvg, sweep, rb, custom 등)
_breachMode (string) : 돌파 처리 방식: "both" (양쪽 모두), "directionalHighLow" (방향성 high/low), "directionalClose" (방향성 close)
_tf (string) : 시간대
_isBull (bool) : 상승(true) 또는 하락(false) 방향
_useLine (bool) : 중간선 표시 여부
_colorBG (color) : 박스 배경색
_colorBD (color) : 박스 테두리색
_colorText (color) : 텍스트 색상
_cache (HTFCache) : HTF 캐시 데이터 (CurrentTF는 na)
_customText (string) : 커스텀 텍스트 (비어있으면 자동 생성)
Returns: 성공 여부와 박스 데이터
CreateCustomBox(_boxType, _breachMode, _isBull, _top, _bottom, _left, _right, _useLine, _colorBG, _colorBD, _colorText, _text)
CreateCustomBox
@description 완전히 유연한 커스텀 박스 생성.\
사용자가 박스 위치(top, bottom, left, right), breach mode, 모든 파라미터를 직접 지정.\
조건 체크는 사용자 스크립트에서 수행하고, 이 함수는 박스 생성만 담당.\
새로운 박스 타입 추가 시 라이브러리 수정 없이 사용 가능.
Parameters:
_boxType (string) : 박스 타입 (사용자 정의 문자열)
_breachMode (string) : 돌파 처리 방식: "both", "directionalHighLow", "directionalClose", "sobClose"
_isBull (bool) : 상승(true) 또는 하락(false) 방향
_top (float) : 박스 상단 가격
_bottom (float) : 박스 하단 가격
_left (int) : 박스 시작 시간 (xloc.bar_time 사용)
_right (int) : 박스 종료 시간 (xloc.bar_time 사용)
_useLine (bool) : 중간선 표시 여부
_colorBG (color) : 박스 배경색
_colorBD (color) : 박스 테두리색
_colorText (color) : 텍스트 색상
_text (string) : 박스에 표시할 텍스트
Returns: 성공 여부와 박스 데이터
ProcessBoxDatas(_openBoxes, _closedBoxes, _useMidLine, _closeCount, _colorClose, _currentBarIndex, _currentLow, _currentHigh, _currentTime)
ProcessBoxDatas
@description 박스 확장 및 돌파 처리.\
열린 박스들을 현재 bar까지 확장하고, 돌파 조건 체크.\
_closeCount: 돌파 횟수 (이 횟수만큼 돌파 시 박스 종료).\
breachMode에 따라 돌파 체크 방식 다름 (both/directionalHighLow/directionalClose).\
종료된 박스는 _closedBoxes로 이동하고 _colorClose 색상 적용.\
barstate.islast와 barstate.isconfirmed에서 호출 권장.
Parameters:
_openBoxes (array) : 열린 박스 배열
_closedBoxes (array) : 닫힌 박스 배열
_useMidLine (bool) : 중간선 표시 여부
_closeCount (int) : 돌파 카운트 (이 횟수만큼 돌파 시 종료)
_colorClose (color) : 종료된 박스 색상
_currentBarIndex (int) : 현재 bar_index
_currentLow (float) : 현재 low
_currentHigh (float) : 현재 high
_currentTime (int) : 현재 time
Returns: bool 항상 true
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분.\
반환: .\
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:
BoxData
BoxData
Fields:
_type (series string) : 박스 타입 (fob, fvg, sweep, rb, custom 등)
_breachMode (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)
_createdBar (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)
MTFToolkit-LibraryLibrary "MTFToolkit"
Multi-Timeframe Utilities Library: conversions, Fibonacci, TF sorting, MTF helpers, color gradients, demo table
timeframeToMinutes(tf)
Converts a timeframe string to minutes
Parameters:
tf (string) : Timeframe string (e.g., "1", "15", "1D", "1W", "1M")
Returns: Number of minutes as float
minutesToTimeframe(minutes)
Converts minutes to a timeframe string
Parameters:
minutes (float) : Number of minutes
Returns: Timeframe string
timeframeToSeconds(tf)
Converts a timeframe string to seconds
Parameters:
tf (string) : Timeframe string
Returns: Number of seconds
secondsToTimeframe(seconds)
Converts seconds to a timeframe string
Parameters:
seconds (float) : Number of seconds
Returns: Timeframe string
fiboGenerate(n)
Generates Fibonacci sequence up to n elements
Parameters:
n (int) : Number of elements
Returns: Array of Fibonacci numbers
fiboMapToTV(arrFibo)
Maps Fibonacci values to TradingView timeframe strings
Parameters:
arrFibo (array) : Array of Fibonacci numbers
Returns: Array of timeframe strings
arrayMergeUnique(arr1, arr2)
Merges two string arrays and keeps unique values
Parameters:
arr1 (array) : First array
arr2 (array) : Second array
Returns: Merged array with unique strings
arrayFilterMax(arr, maxMinutes)
Filters TF array by max minutes
Parameters:
arr (array) : Array of timeframe strings
maxMinutes (float) : Maximum allowed minutes
Returns: Filtered array
arraySortTF(tf_array, show_array, ascending)
Sorts TF array by minutes, optionally ascending
Parameters:
tf_array (array) : Array of timeframes
show_array (array) : Array of bool flags (for visibility)
ascending (bool)
masterTF(arr)
Returns the largest TF from array (master)
Parameters:
arr (array) : Array of TF strings
Returns: Master TF
slaveTF(arr)
Returns all TFs except master (slaves)
Parameters:
arr (array) : Array of TF strings
Returns: Array of slave TFs
isTFIncreasing(prevTF, nextTF)
Checks if next TF is larger than previous
Parameters:
prevTF (string) : Previous timeframe
nextTF (string) : Next timeframe
Returns: true if nextTF > prevTF
TFScore(values)
Computes simple average as score
Parameters:
values (array) : Array of float
Returns: Simple average (na if empty)
gradient_triangular(value, mid_point, min_color, mid_color, max_color)
Produces a triangular gradient between 3 colors
Parameters:
value (float) : Current value (0–100 or any scale)
mid_point (float) : Center point of gradient
min_color (color) : Color at low end
mid_color (color) : Color at midpoint
max_color (color) : Color at high end
Returns: A color value
TFColorGradient(tf_val, min_val, max_val)
Timeframe color gradient helper
Converts a timeframe (in minutes) into a color using a
red → yellow → green gradient.
Parameters:
tf_val (float) : Timeframe value in minutes
min_val (float) : Minimum expected minutes
max_val (float) : Maximum expected minutes
Returns: Color based on position between min_val and max_val
------------------------------------------------------------
TFColorGradientEx(tf_val, min_val, mid_val, max_val, low_color, mid_color, high_color)
Extended customizable timeframe gradient
Parameters:
tf_val (float) : Timeframe value in minutes
min_val (float) : Minimum minutes
mid_val (float) : Middle minutes
max_val (float) : Maximum minutes
low_color (color) : Color at min_val
mid_color (color) : Color at mid_val
high_color (color) : Color at max_val
Returns: Color determined by TF position
------------------------------------------------------------
demoTable(tf_arr, show_arr, dashboard_position, horizontal_table, show_header)
Creates a demo table for testing TF arrays
Parameters:
tf_arr (array) : Array of TF strings
show_arr (array) : Array of bools to show TFs
dashboard_position (string) : Position string
horizontal_table (bool) : true=horizontal, false=vertical
show_header (bool) : Show header row
Mirpapa_Lib_4waveLibrary "Mirpapa_Lib_4wave"
Library for MACD 4Wave Trading System - Type definitions and calculation functions
_macd_calc(_src, _fast, _slow, _signal)
Parameters:
_src (float)
_fast (simple int)
_slow (simple int)
_signal (simple int)
_normalize(_value, _current_max, _current_norm)
Parameters:
_value (float)
_current_max (float)
_current_norm (float)
calc_visual(_current, _prev_val, _color_up, _color_down, _transparency_up, _transparency_down)
Parameters:
_current (float)
_prev_val (float)
_color_up (color)
_color_down (color)
_transparency_up (int)
_transparency_down (int)
_detect_line_position(_line1, _line2)
Parameters:
_line1 (float)
_line2 (float)
_get_divergence_score(_div)
Parameters:
_div (_DivergenceCounter)
calculate_score_1_HighTrend(_htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_1_TRIX_Align(_trix_norm, _trix_norm_prev, _max_score)
Parameters:
_trix_norm (float)
_trix_norm_prev (float)
_max_score (int)
calculate_score_2_MidAlign(_htfMid_macd_norm, _htfMid_macd_norm_prev, _htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfMid_macd_norm (float)
_htfMid_macd_norm_prev (float)
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_3_LowAlign(_htfLow_macd_norm, _htfLow_macd_norm_prev, _htfMid_macd_norm, _htfMid_macd_norm_prev, _htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfLow_macd_norm (float)
_htfLow_macd_norm_prev (float)
_htfMid_macd_norm (float)
_htfMid_macd_norm_prev (float)
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_4_CurrentAlign(_current_macd_norm, _htfMid_macd_norm, _htfHigh_macd_norm, _max_score)
Parameters:
_current_macd_norm (float)
_htfMid_macd_norm (float)
_htfHigh_macd_norm (float)
_max_score (int)
calculate_score_4_CurrentHistogram(_hist, _hist_prev, _max_score)
Parameters:
_hist (float)
_hist_prev (float)
_max_score (int)
calculate_score_4_MACD_Cross(_current_norm, _htfLow_norm, _htfMid_norm, _htfHigh_norm, _max_score)
Parameters:
_current_norm (float)
_htfLow_norm (float)
_htfMid_norm (float)
_htfHigh_norm (float)
_max_score (int)
calculate_score_4_MACD_Extreme(_htfMid_norm, _htfMid_norm_prev, _htfLow_norm, _htfLow_norm_prev, _htfHigh_norm, _oversold_line, _overbought_line, _max_score)
Parameters:
_htfMid_norm (float)
_htfMid_norm_prev (float)
_htfLow_norm (float)
_htfLow_norm_prev (float)
_htfHigh_norm (float)
_oversold_line (float)
_overbought_line (float)
_max_score (int)
calculate_score_4_MACD_Convergence(_htfLow_norm, _htfMid_norm, _htfHigh_norm, _max_score)
Parameters:
_htfLow_norm (float)
_htfMid_norm (float)
_htfHigh_norm (float)
_max_score (int)
calculate_score_5_RSI_Divergence(_rsiDivBull, _rsiDivBear, _max_score)
Parameters:
_rsiDivBull (_DivergenceCounter)
_rsiDivBear (_DivergenceCounter)
_max_score (int)
calculate_score_5_MACD_Divergence(_macdDivBull, _macdDivBear, _max_score)
Parameters:
_macdDivBull (_DivergenceCounter)
_macdDivBear (_DivergenceCounter)
_max_score (int)
calculate_score_5_Bonus_Divergence(_rsiDivBull, _rsiDivBear, _macdDivBull, _macdDivBear, _trixDivBull, _trixDivBear, _max_score)
Parameters:
_rsiDivBull (_DivergenceCounter)
_rsiDivBear (_DivergenceCounter)
_macdDivBull (_DivergenceCounter)
_macdDivBear (_DivergenceCounter)
_trixDivBull (_DivergenceCounter)
_trixDivBear (_DivergenceCounter)
_max_score (int)
_calculate_total_score(_score_data)
Parameters:
_score_data (_Score)
_FilterSettings
Fields:
_need_macd (series bool)
_need_rsi (series bool)
_need_trix (series bool)
_show_indicator_visual (series bool)
_show_trade_visual (series bool)
_Macd
Fields:
_macd (series float)
_signal (series float)
_hist (series float)
_hist_prev (series float)
_max (series float)
_norm (series float)
_normPrev (series float)
_Rsi
Fields:
_value (series float)
_norm (series float)
_normPrev (series float)
_Trix
Fields:
_value (series float)
_max (series float)
_norm (series float)
_normPrev (series float)
_Divergence
Fields:
_bull (series bool)
_bear (series bool)
_DivergenceCounter
Fields:
_div1 (series int)
_div2 (series int)
_div3 (series int)
_Score
Fields:
_1_MACD_HighTrend (series float)
_1_TRIX_Align (series float)
_2_MACD_MidAlign (series float)
_3_MACD_LowAlign (series float)
_4_MACD_CurrentAlign (series float)
_4_MACD_CurrentHistogram (series float)
_4_MACD_Cross (series float)
_4_MACD_Extreme (series float)
_4_MACD_Convergence (series float)
_5_RSI_Divergence (series float)
_5_MACD_Divergence (series float)
_5_Bonus_Divergence (series float)
_total (series float)
_canContinue (series bool)
_directionAligned (series bool)
_IsNewBar
Fields:
_high (series bool)
_mid (series bool)
_low (series bool)
_Visual
Fields:
_prev (series float)
_increasing (series bool)
_color (series color)
_ScoreThresholds
Fields:
_1_MACD_HighTrend_MAX (series int)
_1_TRIX_Align_MAX (series int)
_2_MACD_MidAlign_MAX (series int)
_3_MACD_LowAlign_MAX (series int)
_4_MACD_CurrentAlign_MAX (series int)
_4_MACD_CurrentHistogram_MAX (series int)
_4_MACD_Cross_MAX (series int)
_4_MACD_Extreme_MAX (series int)
_4_MACD_Convergence_MAX (series int)
_5_RSI_Divergence_MAX (series int)
_5_MACD_Divergence_MAX (series int)
_5_Bonus_Divergence_MAX (series int)
_EntryThresholds
Fields:
_LONG (series int)
_SHORT (series int)
_StopLossThresholds
Fields:
_PCT (series float)
_SCORE_DROP (series int)
_MDDThresholds
Fields:
_DAILY_LIMIT (series float)
_PositionSizeMultipliers
Fields:
_SIZE_120_PLUS (series float)
_SIZE_100_119 (series float)
_SIZE_90_99 (series float)
_SIZE_75_89 (series float)
_SIZE_60_74 (series float)
_MDDMultipliers
Fields:
_MULT_0_1 (series float)
_MULT_1_2 (series float)
_MULT_2_25 (series float)
_MULT_25_3 (series float)
_MULT_3_PLUS (series float)
_TrixThresholds
Fields:
_STRONG_BULL (series float)
_WEAK_BULL (series float)
_STRONG_BEAR (series float)
_WEAK_BEAR (series float)
_RsiThresholds
Fields:
_OVERSOLD_STRONG (series int)
_OVERSOLD_WEAK (series int)
_OVERBOUGHT_WEAK (series int)
_OVERBOUGHT_STRONG (series int)
_MacdThresholds
Fields:
_OVERSOLD_STRONG (series int)
_OVERSOLD_WEAK (series int)
_OVERBOUGHT_WEAK (series int)
_OVERBOUGHT_STRONG (series int)
_LineThresholds
Fields:
_TOP (series int)
_MIDDLE (series int)
_BOTTOM (series int)
_HIST_BASE (series int)
_Transparency
Fields:
_MAX (series int)
_STRONG (series int)
_MEDIUM (series int)
_WEAK (series int)
_MIN (series int)
_FILL (series int)
_TimeframeNames
Fields:
_CURRENT (series string)
_HTF1 (series string)
_HTF2 (series string)
_HTF3 (series string)
_IndicatorColors
Fields:
_RSI (series color)
_TRIX (series color)
_MACD_CURRENT (series color)
_MACD_HTF1 (series color)
_MACD_HTF2 (series color)
_MACD_HTF3 (series color)
_EntryState
Fields:
_WAITING (series string)
_ENTERED (series string)
_CLOSED (series string)
_TradeState
Fields:
_state (series string)
_is_long (series bool)
_signal_bar (series int)
_signal_score (series float)
_signal_high (series float)
_signal_low (series float)
_entry_bar (series int)
_entry_price (series float)
_entry_score (series float)
_entry_reason (series string)
_exit_bar (series int)
_exit_price (series float)
_exit_reason (series string)
_h_line (series line)
_v_line (series line)
_signal_label (series label)
_entry_label (series label)
_exit_label (series label)
Mirpapa_Lib_SumBoxLibrary "Mirpapa_Lib_SumBox"
CreateSumCandleStates()
CreateSumCandleStates
@desc Creates a set of sum candle state strings.
Returns (SumCandleStates): State string set (pending, confirmed, completed)
Returns: SumCandleStates state string set
CreateSumCandleData(sumOpen, sumHigh, sumLow, sumClose, sumStartTime, sumEndTime, sumHighTime, sumLowTime, state)
CreateSumCandleData
@desc Creates sum candle data (factory function).
sumOpen (float): Sum open price
sumHigh (float): Sum high price
sumLow (float): Sum low price
sumClose (float): Sum close price
sumStartTime (int): Sum start time (milliseconds)
sumEndTime (int): Sum end time (milliseconds)
sumHighTime (int): High point occurrence time (milliseconds)
sumLowTime (int): Low point occurrence time (milliseconds)
state (string): State (pending/confirmed/completed)
Returns (SumCandleData): Created sum candle data
Parameters:
sumOpen (float): (float) Sum open price
sumHigh (float): (float) Sum high price
sumLow (float): (float) Sum low price
sumClose (float): (float) Sum close price
sumStartTime (int): (int) Sum start time
sumEndTime (int): (int) Sum end time
sumHighTime (int): (int) High point occurrence time
sumLowTime (int): (int) Low point occurrence time
state (string): (string) State
Returns: SumCandleData Created sum candle data
ValidateSumCandleData(sumData, confirmedState)
ValidateSumCandleData
@desc Validates sum candle data.
sumData (SumCandleData): Sum candle data to validate
confirmedState (string): CONFIRMED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to validate
confirmedState (string): (string) CONFIRMED state string
Returns:
CanConfirmSumCandle(sumData, pendingState, confirmedState, completedState)
CanConfirmSumCandle
@desc Validates whether a sum candle can be confirmed.
sumData (SumCandleData): Sum candle data to confirm
pendingState (string): PENDING state string
confirmedState (string): CONFIRMED state string
completedState (string): COMPLETED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to confirm
pendingState (string): (string) PENDING state string
confirmedState (string): (string) CONFIRMED state string
completedState (string): (string) COMPLETED state string
Returns:
UpdateSumCandleState(sumData, newState, pendingState, confirmedState, completedState)
UpdateSumCandleState
@desc Updates the state of a sum candle (includes validation).
sumData (SumCandleData): Sum candle data to update
newState (string): New state
pendingState (string): PENDING state string
confirmedState (string): CONFIRMED state string
completedState (string): COMPLETED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to update
newState (string): (string) New state
pendingState (string): (string) PENDING state string
confirmedState (string): (string) CONFIRMED state string
completedState (string): (string) COMPLETED state string
Returns:
CreateSumCandleBox(sumOpen, sumClose, sumStartTime, endTime, bullColor, bearColor, borderColor, borderWidth)
CreateSumCandleBox
@desc Creates a sum candle body box.
sumOpen (float): Sum open price
sumClose (float): Sum close price
sumStartTime (int): Sum start time (milliseconds)
endTime (int): Sum end time (milliseconds)
bullColor (color): Bullish candle color
bearColor (color): Bearish candle color
borderColor (color): Border color
borderWidth (int): Border width (1-5)
Returns (box): Created body box
Parameters:
sumOpen (float): (float) Sum open price
sumClose (float): (float) Sum close price
sumStartTime (int): (int) Sum start time
endTime (int): (int) Sum end time
bullColor (color): (color) Bullish candle color
bearColor (color): (color) Bearish candle color
borderColor (color): (color) Border color
borderWidth (int): (int) Border width
Returns: box Body box
CreateSumCandleLine(x, y1, y2, lineColor, lineWidth)
CreateSumCandleLine
@desc Creates a sum candle wick line.
x (int): Line x coordinate (time, milliseconds)
y1 (float): Line start y coordinate (price)
y2 (float): Line end y coordinate (price)
lineColor (color): Line color
lineWidth (int): Line width (1-5)
Returns (line): Created wick line
Parameters:
x (int): (int) Line x coordinate (time)
y1 (float): (float) Line start y coordinate
y2 (float): (float) Line end y coordinate
lineColor (color): (color) Line color
lineWidth (int): (int) Line width
Returns: line Wick line
DeleteSumCandleVisuals(sumData)
DeleteSumCandleVisuals
@desc Deletes visualization objects (boxes, lines) of a sum candle.
sumData (SumCandleData): Sum candle data to delete
Returns (void): No return value
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to delete
Returns: void
GetBodyBounds(sumOpen, sumClose)
GetBodyBounds
@desc Calculates the top and bottom boundaries of the body.
sumOpen (float): Sum open price
sumClose (float): Sum close price
Returns ( ):
Parameters:
sumOpen (float): (float) Sum open price
sumClose (float): (float) Sum close price
Returns:
ManageMemory(sumArray, maxSize)
ManageMemory
@desc Manages array size and deletes old data.
sumArray (array): Sum candle array to manage
maxSize (int): Maximum size
Returns (void): No return value
Parameters:
sumArray (array): (array) Sum candle array to manage
maxSize (int): (int) Maximum size
Returns: void
IsSingleCandle(sumData)
IsSingleCandle
@desc Checks if it's a sum consisting of only one candle.
sumData (SumCandleData): Sum candle data to check
Returns (bool): true if single candle, false otherwise
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to check
Returns: bool Single candle status
CalculateWickCenterTime(startTime, endTime)
CalculateWickCenterTime
@desc Calculates the center time where the wick will be displayed.
startTime (int): Sum start time (milliseconds)
endTime (int): Sum end time (milliseconds)
Returns (int): Center time (milliseconds)
Parameters:
startTime (int): (int) Sum start time
endTime (int): (int) Sum end time
Returns: int Center time
SumCandleStates
Fields:
pending (series string)
confirmed (series string)
completed (series string)
SumCandleData
Fields:
_open (series float)
_high (series float)
_low (series float)
_close (series float)
_startTime (series int)
_endTime (series int)
_highTime (series int)
_lowTime (series int)
_isBull (series bool)
_state (series string)
_boxBody (series box)
_wickHigh (series line)
_wickLow (series line)
smaemarvwapClaireLibrary "smaemarvwapClaire"
repeat_character(count)
Parameters:
count (int)
f_1_k_line_width()
is_price_in_merge_range(p1, p2, label_merge_range)
Parameters:
p1 (float)
p2 (float)
label_merge_range (float)
get_pre_label_string(kc, t, is_every)
Parameters:
kc (VWAP_key_levels_draw_settings)
t (int)
is_every (bool)
f_is_new_period_from_str(str)
Parameters:
str (string)
total_for_time_when(source, days, ma_set)
Parameters:
source (float)
days (int)
ma_set (ma_setting)
f_calculate_sma_ema_rolling_vwap(src, length, ma_settings)
Parameters:
src (float)
length (simple int)
ma_settings (ma_setting)
f_calculate_sma_ema_rvwap(ma_settings)
Parameters:
ma_settings (ma_setting)
f_get_ma_pre_label(ma_settings, sma, ema, rolling_vwap)
Parameters:
ma_settings (ma_setting)
sma (float)
ema (float)
rolling_vwap (float)
f_smart_ma_calculation(ma_settings2)
Parameters:
ma_settings2 (ma_setting)
f_calculate_endpoint(start_time, kc, is_every, endp, extend1, extend2, line_label_extend_length)
Parameters:
start_time (int)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
f_single_line_label_fatory(left_point, right_point, line_col, line_width, lines_style_select, labeltext_col, label_text_size, label_array, line_array, label_col, label_text, l1, label1)
根据两个点创建线段和/或标签,并将其添加到对应的数组中
Parameters:
left_point (chart.point) : 左侧起点坐标
right_point (chart.point) : 右侧终点坐标
line_col (color) : 线段颜色
line_width (int) : 线段宽度
lines_style_select (string) : 线段样式(实线、虚线等)
labeltext_col (color) : 标签文字颜色
label_text_size (string) : 标签文字大小
label_array (array) : 存储标签对象的数组
line_array (array) : 存储线段对象的数组
label_col (color) : 标签背景颜色(默认:半透明色)
label_text (string) : 标签文字内容(默认:空字符串)
l1 (bool) : 是否创建线段(默认:false)
label1 (bool) : 是否创建标签(默认:false)
Returns: void
f_line_and_label_merge_func(t, data, l_text, kc, is_every, endp, merge_str_map, label_array, line_array, extend1, extend2, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
t (int)
data (float)
l_text (string)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
merge_str_map (map)
label_array (array)
line_array (array)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_ohlc(kc, ohlc_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_keylevels(kc, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_bardata(kc, ohlc_data, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
f_start_end_total_min(session)
Parameters:
session (string)
f_get_vwap_array(anchor1, data_manager, is_historical)
Parameters:
anchor1 (string)
data_manager (data_manager)
is_historical (bool)
f_get_bardata_array(anchorh, data_manager, is_historical)
Parameters:
anchorh (string)
data_manager (data_manager)
is_historical (bool)
vwap_snapshot
Fields:
t (series int)
vwap (series float)
upper1 (series float)
lower1 (series float)
upper2 (series float)
lower2 (series float)
upper3 (series float)
lower3 (series float)
VWAP_key_levels_draw_settings
Fields:
enable (series bool)
index (series int)
anchor (series string)
session (series string)
vwap_col (series color)
bands_col (series color)
bg_color (series color)
text_color (series color)
val (series bool)
poc (series bool)
vah (series bool)
enable2x (series bool)
enable3x (series bool)
o_control (series bool)
h_control (series bool)
l_control (series bool)
c_control (series bool)
extend_control (series bool)
only_show_the_lastone_control (series bool)
bg_control (series bool)
line_col_labeltext_col (series color)
bardata
Fields:
o (series float)
h (series float)
l (series float)
c (series float)
v (series float)
start_time (series int)
end_time (series int)
ma_setting
Fields:
day_control (series bool)
kline_numbers (series int)
ma_color (series color)
ema_color (series color)
rvwap_color (series color)
ma_control (series bool)
ema_control (series bool)
rvwap_control (series bool)
session (series string)
merge_label_template
Fields:
left_point (chart.point)
right_point (chart.point)
label_text (series string)
p (series float)
label_color (series color)
merge_init_false (series bool)
anchor_snapshots
Fields:
vwap_current (array)
vwap_historical (array)
bardata_current (array)
bardata_historical (array)
data_manager
Fields:
snapshots_map (map)
draw_settings_map (map)
LapseBacktestingTableLibrary "LapseBacktestingMetrics"
This library provides a robust set of quantitative backtesting and performance evaluation functions for Pine Script strategies. It’s designed to help traders, quants, and developers assess risk, return, and robustness through detailed statistical metrics — including Sharpe, Sortino, Omega, drawdowns, and trade efficiency.
Built to enhance any trading strategy’s evaluation framework, this library allows you to visualize performance with the quantlapseTable() function, producing an interactive on-chart performance table.
Credit to EliCobra and BikeLife76 for original concept inspiration.
curve(disp_ind)
Retrieves a selected performance curve of your strategy.
Parameters:
disp_ind (simple string): Type of curve to plot. Options include "Equity", "Open Profit", "Net Profit", "Gross Profit".
Returns: (float) Corresponding performance curve value.
cleaner(disp_ind, plot)
Filters and displays selected strategy plots for clean visualization.
Parameters:
disp_ind (simple string): Type of display.
plot (simple float): Strategy plot variable.
Returns: (float) Filtered plot value.
maxEquityDrawDown()
Calculates the maximum equity drawdown during the strategy’s lifecycle.
Returns: (float) Maximum equity drawdown percentage.
maxTradeDrawDown()
Computes the worst intra-trade drawdown among all closed trades.
Returns: (float) Maximum intra-trade drawdown percentage.
consecutive_wins()
Finds the highest number of consecutive winning trades.
Returns: (int) Maximum consecutive wins.
consecutive_losses()
Finds the highest number of consecutive losing trades.
Returns: (int) Maximum consecutive losses.
no_position()
Counts the maximum consecutive bars where no position was held.
Returns: (int) Maximum flat days count.
long_profit()
Calculates total profit generated by long positions as a percentage of initial capital.
Returns: (float) Total long profit %.
short_profit()
Calculates total profit generated by short positions as a percentage of initial capital.
Returns: (float) Total short profit %.
prev_month()
Measures the previous month’s profit or loss based on equity change.
Returns: (float) Monthly equity delta.
w_months()
Counts the number of profitable months in the backtest.
Returns: (int) Total winning months.
l_months()
Counts the number of losing months in the backtest.
Returns: (int) Total losing months.
checktf()
Returns the time-adjusted scaling factor used in Sharpe and Sortino ratio calculations based on chart timeframe.
Returns: (float) Annualization multiplier.
stat_calc()
Performs complete statistical computation including drawdowns, Sharpe, Sortino, Omega, trade stats, and profit ratios.
Returns: (array)
.
f_colors(x, nv)
Generates a color gradient for performance values, supporting dynamic table visualization.
Parameters:
x (simple string): Metric label name.
nv (simple float): Metric numerical value.
Returns: (color) Gradient color value for table background.
quantlapseTable(option, position)
Displays an interactive Performance Table summarizing all major backtesting metrics.
Includes Sharpe, Sortino, Omega, Profit Factor, drawdowns, profitability %, and trade statistics.
Parameters:
option (simple string): Table type — "Full", "Simple", or "None".
position (simple string): Table position — "Top Left", "Middle Right", "Bottom Left", etc.
Returns: (table) On-chart performance visualization table.
This library empowers advanced quantitative evaluation directly within Pine Script®, ideal for strategy developers seeking deeper performance diagnostics and intuitive on-chart metrics.
fibonacci2Library "fibonacci2"
Useful methods to calculate and display fibonacci retracement
modelParamsNew(point_0, point_1)
Parameters:
point_0 (chart.point)
point_1 (chart.point)
modelParamsNew(this, point_0, point_1)
Parameters:
this (viewParams)
point_0 (chart.point)
point_1 (chart.point)
method toModelParams(this, point_0, point_1)
Namespace types: viewParams
Parameters:
this (viewParams)
point_0 (chart.point)
point_1 (chart.point)
method createModel(params)
Namespace types: modelParams
Parameters:
params (modelParams)
method createView(this, params)
Namespace types: model
Parameters:
this (model)
params (viewParams)
method delete(view)
Namespace types: view
Parameters:
view (view)
levelModelParams
Fields:
level (series float)
levelViewParams
Fields:
level (series float)
color (series color)
line_width (series int)
line_style (series lineStyleEnum enum from Hamster-Coder/drawing/1)
levelModel
Represents a Fibonacci retracement level
Fields:
level (series float) : The Fibonacci level ratio (e.g., 0.382, 0.5, 0.618)
value (series float) : The Y-coordinate on the chart corresponding to this level
modelParams
Represents the full parameter set for the Fibonacci retracement model
Fields:
point_1 (chart.point) : Coordinates of the anchor Point (1) of the model
point_0 (chart.point) : Coordinates of the anchor Point (0) of the model
levels (array) : List of levels to display for this model
model
Fields:
point_1 (chart.point)
point_0 (chart.point)
levels (array)
viewParams
Fields:
levels (array)
x1 (series int)
x2 (series int)
xloc (series string)
show_level_value (series bool)
value_format (series string)
force_overlay (series bool)
view
Fields:
model (model)
lines (array)
labels (array)
drawingLibrary "drawing"
Contains common types and methods to draw objects on the chart.
method toTextAlign(input)
Namespace types: series textHorizontalAlignEnum
Parameters:
input (series textHorizontalAlignEnum)
method toTextAlign(input)
Namespace types: series textVertialAlignEnum
Parameters:
input (series textVertialAlignEnum)
method toSize(input)
Namespace types: series sizeEnum
Parameters:
input (series sizeEnum)
method toStyle(input)
Namespace types: series lineStyleEnum
Parameters:
input (series lineStyleEnum)
MirPapa_Lib_trendLibrary: MirPapa_Lib_trend
getMaColor(level)
Parameters:
level (int): 1 = lowest, 2 = low, 3 = mid, 4 = high, 5 = highest, 6 = base
getMA(mode, src, len)
Parameters:
mode (string): MA type
src (float): source
len (simple int): period
Returns: selected MA
getMA(maName, src, intLow, intMid, intHigh)
Parameters:
maName (string): MA type
src (float): source
intLow (simple int): short-term
intMid (simple int): mid-term
intHigh (simple int): long-term
Returns: array
getMA(maName, src, intLowest, intLow, intMid, intHigh, intHighest, intBase)
Parameters:
maName (string): MA type
src (float): source
intLowest (simple int): ultra-short
intLow (simple int): short
intMid (simple int): mid
intHigh (simple int): long
intHighest (simple int): ultra-long
intBase (simple int): base line
Returns: array
getStochastic(src, intLen)
Parameters:
src (float): source
intLen (int): period
Returns: selected stochastic
getStochastic(src, intLow, intMid, intHigh)
Parameters:
src (float): source
intLow (int): short-term
intMid (int): mid-term
intHigh (int): long-term
Returns:
getStochastic(src, intLowest, intLow, intMid, intHigh, intHighest, intBase)
Parameters:
src (float): source
intLowest (int): ultra-short
intLow (int): short
intMid (int): mid
intHigh (int): long
intHighest (int): ultra-long
intBase (int): base
Returns:
getRSX(src, intLen)
Parameters:
src (float): source
intLen (int): period
Returns: selected RSX
getRSX(src, intLow, intMid, intHigh)
Parameters:
src (float): source
intLow (int): short-term
intMid (int): mid-term
intHigh (int): long-term
Returns:
getRSX(src, intLowest, intLow, intMid, intHigh, intHighest, intBase)
Parameters:
src (float): source
intLowest (int): ultra-short
intLow (int): short
intMid (int): mid
intHigh (int): long
intHighest (int): ultra-long
intBase (int): base
Returns:
getMACD(src, fastLen, slowLen, signalLen)
Parameters:
src (float): source
fastLen (simple int): fast EMA period
slowLen (simple int): slow EMA period
signalLen (simple int): signal line period
Returns:
getBollingerBand(src, len, mult)
Parameters:
src (float): source
len (int): period
mult (float): standard deviation multiplier
Returns:
getATR(intLen)
Parameters:
intLen (simple int): ATR period
Returns: selected ATR
getATR(intLow, intMid, intHigh)
Parameters:
intLow (simple int): short-term
intMid (simple int): mid-term
intHigh (simple int): long-term
Returns: array
getATR(intLowest, intLow, intMid, intHigh, intHighest, intBase)
Parameters:
intLowest (simple int): ultra-short
intLow (simple int): short
intMid (simple int): mid
intHigh (simple int): long
intHighest (simple int): ultra-long
intBase (simple int): base
isCross(fastLine, baseLine)
Parameters:
fastLine (float): fast line
baseLine (float): base line
Returns: state (true/false)
isMAtrend(maLow, maMid, maHigh)
Parameters:
maLow (float): fast MA
maMid (float): mid MA
maHigh (float): slow MA
Returns: trend state
isMAline(val, valPrev, intBaseLine)
Parameters:
val (float): current value
valPrev (float): previous value
intBaseLine (int): base value
Returns: state
getStage(v1, v2, v3)
Parameters:
v1 (float): first value
v2 (float): second value
v3 (float): third value
Returns: stage number (1–6)
getBgColor(stage)
Parameters:
stage (int): stage number
Returns: color
getBgColor(stage, transp)
Parameters:
stage (int): stage number
transp (int): transparency
Returns: color
getBGColor(v1, v2, v3)
Parameters:
v1 (float): first value
v2 (float): second value
v3 (float): third value
Returns: color
getBGColor(v1, v2, v3, transp)
Parameters:
v1 (float): first value
v2 (float): second value
v3 (float): third value
transp (int): transparency
Returns: color
createStackedLabel(labelText, isUp, maLowest, maLow, maMid, maHigh, maHighest, maBase)
Parameters:
labelText (string): label text
isUp (bool): true = up, false = down
maLowest (float)
maLow (float)
maMid (float)
maHigh (float)
maHighest (float)
maBase (float)
Returns: created label
isDoubleBottom(src, left, right)
Parameters:
src (float): reference series (e.g., mid MA or low)
left (int): left bar count for pivot search
right (int): right bar count for pivot search
Returns: true if double bottom detected (previous pivot low < current pivot low)
isDoubleTop(src, left, right)
Parameters:
src (float): reference series (e.g., mid MA or high)
left (int): left bar count for pivot search
right (int): right bar count for pivot search
Returns: true if double top detected (previous pivot high > current pivot high)
isFractalHigh(src, left, right)
Parameters:
src (float): high series (e.g., high or mid MA)
left (int): left confirmation bars
right (int): right confirmation bars
Returns: true if fractal high detected
isFractalLow(src, left, right)
Parameters:
src (float): low series (e.g., low or mid MA)
left (int): left confirmation bars
right (int): right confirmation bars
Returns: true if fractal low detected
mt_elliott_coreLibrary "mt_elliott_core"
ewo(maFastLen, maSlowLen, smoothLen)
Parameters:
maFastLen (simple int)
maSlowLen (simple int)
smoothLen (simple int)
mt_phase_num(_len, _minGap)
Parameters:
_len (simple int)
_minGap (simple float)
mt_color_from_phase(_len, _minGap)
Parameters:
_len (simple int)
_minGap (simple float)
mt_phase_progress_pct(_len, _minGap)
Parameters:
_len (simple int)
_minGap (simple float)
anchor_p1_close(len, minGap)
Parameters:
len (simple int)
minGap (simple float)
anchor_p1_pivot(len, minGap)
Parameters:
len (simple int)
minGap (simple float)
row_group_from_ewo(ewoValue, atrValue, strongPct, neutralPct)
Parameters:
ewoValue (float)
atrValue (float)
strongPct (simple float)
neutralPct (simple float)
wave_event_pivot_aligned(ewoSeries, left, right, divTolPct, minBarsGap)
Parameters:
ewoSeries (float)
left (simple int)
right (simple int)
divTolPct (simple float)
minBarsGap (simple int)
phx_liq_tlLibrary "phx_liq_tl"
new_state()
update(st, len, cup, cdn, space, proximity_pct, shs)
Parameters:
st (LTState)
len (int)
cup (color)
cdn (color)
space (float)
proximity_pct (float)
shs (bool)
LTState
Fields:
upln (array)
dnln (array)
upBroken (series bool)
dnBroken (series bool)
phx_kroLibrary "phx_kro"
compute(src, bandwidth, bbwidth, sdLook, sdMult, obos_mult)
Parameters:
src (float)
bandwidth (int)
bbwidth (float)
sdLook (int)
sdMult (float)
obos_mult (float)
start_flags(src, bandwidth, bbwidth)
Parameters:
src (float)
bandwidth (int)
bbwidth (float)
KROFeed
Fields:
Wave (series float)
is_green (series bool)
is_red (series bool)
band_width (series float)
band_width_sma (series float)
band_width_std (series float)
is_hyper_wide (series bool)
wave_sma (series float)
wave_std (series float)
wave_ob_threshold (series float)
wave_os_threshold (series float)
is_overbought (series bool)
is_oversold (series bool)
is_oversold_confirmed (series bool)
is_overbought_confirmed (series bool)
enhanced_os_confirmed (series bool)
enhanced_ob_confirmed (series bool)
triple_green_transition (series bool)
triple_red_transition (series bool)
startwave_bull (series bool)
startwave_bear (series bool)
phx_fvgfvg generator 4h and current time frame
library to import fvg from 4h with midle line and proximity support and resistance
JK_Traders_Reality_LibLibrary "JK_Traders_Reality_Lib"
This library contains common elements used in Traders Reality scripts
calcPvsra(pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, darkGreyCandleColor, lightGrayCandleColor)
calculate the pvsra candle color and return the color as well as an alert if a vector candle has apperared.
Situation "Climax"
Bars with volume >= 200% of the average volume of the 10 previous chart TFs, or bars
where the product of candle spread x candle volume is >= the highest for the 10 previous
chart time TFs.
Default Colors: Bull bars are green and bear bars are red.
Situation "Volume Rising Above Average"
Bars with volume >= 150% of the average volume of the 10 previous chart TFs.
Default Colors: Bull bars are blue and bear are violet.
Parameters:
pvsraVolume (float) : the instrument volume series (obtained from request.sequrity)
pvsraHigh (float) : the instrument high series (obtained from request.sequrity)
pvsraLow (float) : the instrument low series (obtained from request.sequrity)
pvsraClose (float) : the instrument close series (obtained from request.sequrity)
pvsraOpen (float) : the instrument open series (obtained from request.sequrity)
redVectorColor (simple color) : red vector candle color
greenVectorColor (simple color) : green vector candle color
violetVectorColor (simple color) : violet/pink vector candle color
blueVectorColor (simple color) : blue vector candle color
darkGreyCandleColor (simple color) : regular volume candle down candle color - not a vector
lightGrayCandleColor (simple color) : regular volume candle up candle color - not a vector
@return
adr(length, barsBack)
Parameters:
length (simple int) : how many elements of the series to calculate on
barsBack (simple int) : starting possition for the length calculation - current bar or some other value eg last bar
@return adr the adr for the specified lenght
adrHigh(adr, fromDo)
Calculate the ADR high given an ADR
Parameters:
adr (float) : the adr
fromDo (simple bool) : boolean flag, if false calculate traditional adr from high low of today, if true calcualte from exchange midnight
@return adrHigh the position of the adr high in price
adrLow(adr, fromDo)
Parameters:
adr (float) : the adr
fromDo (simple bool) : boolean flag, if false calculate traditional adr from high low of today, if true calcualte from exchange midnight
@return adrLow the position of the adr low in price
splitSessionString(sessXTime)
given a session in the format 0000-0100:23456 split out the hours and minutes
Parameters:
sessXTime (simple string) : the session time string usually in the format 0000-0100:23456
@return
calcSessionStartEnd(sessXTime, gmt)
calculate the start and end timestamps of the session
Parameters:
sessXTime (simple string) : the session time string usually in the format 0000-0100:23456
gmt (simple string) : the gmt offset string usually in the format GMT+1 or GMT+2 etc
@return
drawOpenRange(sessXTime, sessXcol, showOrX, gmt)
draw open range for a session
Parameters:
sessXTime (simple string) : session string in the format 0000-0100:23456
sessXcol (simple color) : the color to be used for the opening range box shading
showOrX (simple bool) : boolean flag to toggle displaying the opening range
gmt (simple string) : the gmt offset string usually in the format GMT+1 or GMT+2 etc
@return void
drawSessionHiLo(sessXTime, showRectangleX, showLabelX, sessXcolLabel, sessXLabel, gmt, sessionLineStyle)
Parameters:
sessXTime (simple string) : session string in the format 0000-0100:23456
showRectangleX (simple bool)
showLabelX (simple bool)
sessXcolLabel (simple color) : the color to be used for the hi/low lines and label
sessXLabel (simple string) : the session label text
gmt (simple string) : the gmt offset string usually in the format GMT+1 or GMT+2 etc
sessionLineStyle (simple string) : the line stile for the session high low lines
@return void
calcDst()
calculate market session dst on/off flags
@return indicating if DST is on or off for a particular region
timestampPreviousDayOfWeek(previousDayOfWeek, hourOfDay, gmtOffset, oneWeekMillis)
Timestamp any of the 6 previous days in the week (such as last Wednesday at 21 hours GMT)
Parameters:
previousDayOfWeek (simple string) : Monday or Satruday
hourOfDay (simple int) : the hour of the day when psy calc is to start
gmtOffset (simple string) : the gmt offset string usually in the format GMT+1 or GMT+2 etc
oneWeekMillis (simple int) : the amount if time for a week in milliseconds
@return the timestamp of the psy level calculation start time
getdayOpen()
get the daily open - basically exchange midnight
@return the daily open value which is float price
newBar(res)
new_bar: check if we're on a new bar within the session in a given resolution
Parameters:
res (simple string) : the desired resolution
@return true/false is a new bar for the session has started
toPips(val)
to_pips Convert value to pips
Parameters:
val (float) : the value to convert to pips
@return the value in pips
rLabel(ry, rtext, rstyle, rcolor, valid, labelXOffset)
a function that draws a right aligned lable for a series during the current bar
Parameters:
ry (float) : series float the y coordinate of the lable
rtext (simple string) : the text of the label
rstyle (simple string) : the style for the lable
rcolor (simple color) : the color for the label
valid (simple bool) : a boolean flag that allows for turning on or off a lable
labelXOffset (int) : how much to offset the label from the current position
rLabelOffset(ry, rtext, rstyle, rcolor, valid, labelOffset)
a function that draws a right aligned lable for a series during the current bar
Parameters:
ry (float) : series float the y coordinate of the lable
rtext (string) : the text of the label
rstyle (simple string) : the style for the lable
rcolor (simple color) : the color for the label
valid (simple bool) : a boolean flag that allows for turning on or off a lable
labelOffset (int)
rLabelLastBar(ry, rtext, rstyle, rcolor, valid, labelXOffset)
a function that draws a right aligned lable for a series only on the last bar
Parameters:
ry (float) : series float the y coordinate of the lable
rtext (string) : the text of the label
rstyle (simple string) : the style for the lable
rcolor (simple color) : the color for the label
valid (simple bool) : a boolean flag that allows for turning on or off a lable
labelXOffset (int) : how much to offset the label from the current position
drawLine(xSeries, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset, validTimeFrame)
a function that draws a line and a label for a series
Parameters:
xSeries (float) : series float the y coordinate of the line/label
res (simple string) : the desired resolution controlling when a new line will start
tag (simple string) : the text for the lable
xColor (simple color) : the color for the label
xStyle (simple string) : the style for the line
xWidth (simple int) : the width of the line
xExtend (simple string) : extend the line
isLabelValid (simple bool) : a boolean flag that allows for turning on or off a label
xLabelOffset (int)
validTimeFrame (simple bool) : a boolean flag that allows for turning on or off a line drawn
drawLineDO(xSeries, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset, validTimeFrame)
a function that draws a line and a label for the daily open series
Parameters:
xSeries (float) : series float the y coordinate of the line/label
res (simple string) : the desired resolution controlling when a new line will start
tag (simple string) : the text for the lable
xColor (simple color) : the color for the label
xStyle (simple string) : the style for the line
xWidth (simple int) : the width of the line
xExtend (simple string) : extend the line
isLabelValid (simple bool) : a boolean flag that allows for turning on or off a label
xLabelOffset (int)
validTimeFrame (simple bool) : a boolean flag that allows for turning on or off a line drawn
drawPivot(pivotLevel, res, tag, pivotColor, pivotLabelColor, pivotStyle, pivotWidth, pivotExtend, isLabelValid, validTimeFrame, levelStart, pivotLabelXOffset)
draw a pivot line - the line starts one day into the past
Parameters:
pivotLevel (float) : series of the pivot point
res (simple string) : the desired resolution
tag (simple string) : the text to appear
pivotColor (simple color) : the color of the line
pivotLabelColor (simple color) : the color of the label
pivotStyle (simple string) : the line style
pivotWidth (simple int) : the line width
pivotExtend (simple string) : extend the line
isLabelValid (simple bool) : boolean param allows to turn label on and off
validTimeFrame (simple bool) : only draw the line and label at a valid timeframe
levelStart (int) : basically when to start drawing the levels
pivotLabelXOffset (int) : how much to offset the label from its current postion
@return the pivot line series
getPvsraFlagByColor(pvsraColor, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, lightGrayCandleColor)
convert the pvsra color to an internal code
Parameters:
pvsraColor (color) : the calculated pvsra color
redVectorColor (simple color) : the user defined red vector color
greenVectorColor (simple color) : the user defined green vector color
violetVectorColor (simple color) : the user defined violet vector color
blueVectorColor (simple color) : the user defined blue vector color
lightGrayCandleColor (simple color) : the user defined regular up candle color
@return pvsra internal code
updateZones(pvsra, direction, boxArr, maxlevels, pvsraHigh, pvsraLow, pvsraOpen, pvsraClose, transperancy, zoneupdatetype, zonecolor, zonetype, borderwidth, coloroverride, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor)
a function that draws the unrecovered vector candle zones
Parameters:
pvsra (int) : internal code
direction (simple int) : above or below the current pa
boxArr (array) : the array containing the boxes that need to be updated
maxlevels (simple int) : the maximum number of boxes to draw
pvsraHigh (float) : the pvsra high value series
pvsraLow (float) : the pvsra low value series
pvsraOpen (float) : the pvsra open value series
pvsraClose (float) : the pvsra close value series
transperancy (simple int) : the transparencfy of the vecor candle zones
zoneupdatetype (simple string) : the zone update type
zonecolor (simple color) : the zone color if overriden
zonetype (simple string) : the zone type
borderwidth (simple int) : the width of the border
coloroverride (simple bool) : if the color overriden
redVectorColor (simple color) : the user defined red vector color
greenVectorColor (simple color) : the user defined green vector color
violetVectorColor (simple color) : the user defined violet vector color
blueVectorColor (simple color) : the user defined blue vector color
cleanarr(arr)
clean an array from na values
Parameters:
arr (array) : the array to clean
@return if the array was cleaned
calcPsyLevels(oneWeekMillis, showPsylevels, psyType, sydDST)
calculate the psy levels
4 hour res based on how mt4 does it
mt4 code
int Li_4 = iBarShift(NULL, PERIOD_H4, iTime(NULL, PERIOD_W1, Li_0)) - 2 - Offset;
ObjectCreate("PsychHi", OBJ_TREND, 0, Time , iHigh(NULL, PERIOD_H4, iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)), iTime(NULL, PERIOD_W1, 0), iHigh(NULL, PERIOD_H4,
iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)));
so basically because the session is 8 hours and we are looking at a 4 hour resolution we only need to take the highest high an lowest low of 2 bars
we use the gmt offset to adjust the 0000-0800 session to Sydney open which is at 2100 during dst and at 2200 otherwize. (dst - spring foward, fall back)
keep in mind sydney is in the souther hemisphere so dst is oposite of when london and new york go into dst
Parameters:
oneWeekMillis (simple int) : a constant value
showPsylevels (simple bool) : should psy levels be calculated
psyType (simple string) : the type of Psylevels - crypto or forex
sydDST (bool) : is Sydney in DST
@return
adrHiLo(length, barsBack, fromDO)
Parameters:
length (simple int) : how many elements of the series to calculate on
barsBack (simple int) : starting possition for the length calculation - current bar or some other value eg last bar
fromDO (simple bool) : boolean flag, if false calculate traditional adr from high low of today, if true calcualte from exchange midnight
@return adr, adrLow and adrHigh - the adr, the position of the adr High and adr Low with respect to price
drawSessionHiloLite(sessXTime, showRectangleX, showLabelX, sessXcolLabel, sessXLabel, gmt, sessionLineStyle, sessXcol)
Parameters:
sessXTime (simple string) : session string in the format 0000-0100:23456
showRectangleX (simple bool)
showLabelX (simple bool)
sessXcolLabel (simple color) : the color to be used for the hi/low lines and label
sessXLabel (simple string) : the session label text
gmt (simple string) : the gmt offset string usually in the format GMT+1 or GMT+2 etc
sessionLineStyle (simple string) : the line stile for the session high low lines
sessXcol (simple color) : - the color for the box color that will color the session
@return void
msToHmsString(ms)
converts milliseconds into an hh:mm string. For example, 61000 ms to '0:01:01'
Parameters:
ms (int) : - the milliseconds to convert to hh:mm
@return string - the converted hh:mm string
countdownString(openToday, closeToday, showMarketsWeekends, oneDay)
that calculates how much time is left until the next session taking the session start and end times into account. Note this function does not work on intraday sessions.
Parameters:
openToday (int) : - timestamps of when the session opens in general - note its a series because the timestamp was created using the dst flag which is a series itself thus producing a timestamp series
closeToday (int) : - timestamp of when the session closes in general - note its a series because the timestamp was created using the dst flag which is a series itself thus producing a timestamp series
@return a countdown of when next the session opens or 'Open' if the session is open now
showMarketsWeekends (simple bool)
oneDay (simple int)
countdownStringSyd(sydOpenToday, sydCloseToday, showMarketsWeekends, oneDay)
that calculates how much time is left until the next session taking the session start and end times into account. special case of intraday sessions like sydney
Parameters:
sydOpenToday (int)
sydCloseToday (int)
showMarketsWeekends (simple bool)
oneDay (simple int)
GBB_lib_utilsLibrary "GBB_lib_utils"
gbb_moving_average_source(_source, _length, _ma_type)
gbb_moving_average_source
@description Calculates the moving average of a source series.
Parameters:
_source (float) : (series float)
_length (simple int) : (int)
_ma_type (string) : (string)
Returns: (series) Moving average series
gbb_tf_to_display(tf_minutes, tf_string)
gbb_tf_to_display
@description Converts minutes and TF string into a short standard label.
Parameters:
tf_minutes (float) : (float)
tf_string (string) : (string)
Returns: (string) Timeframe label (M1,H1,D1,...)
gbb_convert_bars(_bars)
gbb_convert_bars
@description Formats a number of bars into a duration (days, hours, minutes + bar count).
Parameters:
_bars (int) : (int)
Returns: (string)
gbb_goldorak_init(_tf5Levels_input)
gbb_goldorak_init
@description Builds a contextual message about the current timeframe and optional 5-level TF.
Parameters:
_tf5Levels_input (string) : (string) Alternative timeframe ("" = current timeframe).
Returns: (string, string, float)






















