PINE LIBRARY
Güncellendi TPOSmartMoneyLib

Library "TPOSmartMoneyLib"
Library for TPO (Time Price Opportunity) and Smart Money concepts including session management, PDH/PDL detection, sweeping logic, and volume profile utilities
f_price_to_tick(p)
Convert price to tick
Parameters:
p (float): Price value
Returns: Tick value
f_tick_to_row(t, row_ticks_in)
Convert tick to row
Parameters:
t (int): Tick value
row_ticks_in (int): Number of ticks per row
Returns: Row index
f_row_to_price(row, row_ticks_in)
Convert row to price (midpoint)
Parameters:
row (int): Row index
row_ticks_in (int): Number of ticks per row
Returns: Price at row midpoint
f_calc_row_ticks(natr_ref, row_gran_mult)
Calculate dynamic row size based on normalized ATR
Parameters:
natr_ref (float): Daily normalized ATR reference value
row_gran_mult (float): Row granularity multiplier
Returns: Number of ticks per row
f_more_transp_pct(c, pct)
Increase color transparency by percentage
Parameters:
c (color): Input color
pct (float): Percentage to increase transparency (0.0 to 1.0)
Returns: Color with increased transparency
f_dom_color(dom, buy_col, sell_col, gamma, transp_weak, transp_strong)
Calculate dominance color based on buy/sell ratio
Parameters:
dom (float): Dominance ratio (-1 to 1, negative = sell, positive = buy)
buy_col (color): Buy dominant color
sell_col (color): Sell dominant color
gamma (float): Gamma correction for color intensity
transp_weak (int): Transparency for weak dominance
transp_strong (int): Transparency for strong dominance
Returns: Blended color
f_sess_part(sess_str, get_start)
Parse session string to get start or end time
Parameters:
sess_str (string): Session string in format "HHMM-HHMM"
get_start (bool): True to get start time, false to get end time
Returns: Time string in HHMM format
f_hhmm_to_h(hhmm)
Convert HHMM string to hours
Parameters:
hhmm (string): Time string in HHMM format
Returns: Hours (0-23)
f_hhmm_to_m(hhmm)
Convert HHMM string to minutes
Parameters:
hhmm (string): Time string in HHMM format
Returns: Minutes (0-59)
f_prev_day_window_bounds(today_day_rth, win_start, win_end, session_tz)
Calculate previous day window bounds
Parameters:
today_day_rth (int): Today's RTH start timestamp
win_start (string): Window start time in HHMM format
win_end (string): Window end time in HHMM format
session_tz (string): Session timezone
Returns: Tuple of [window_start_ms, window_end_ms]
f_default_session_colors()
Get default session colors
Returns: Array of 4 colors [Asia, Frankfurt, London, NY]
f_session_names()
Get session names
Returns: Array of 4 session names
f_process_hl(arr, rng, keep_bars, lock_to_live)
Process high/low lines with sweeping detection
Parameters:
arr (array<HLLine>): Array of HLLine objects
rng (float): Price range for visibility filtering
keep_bars (int): Maximum bars to keep lines
lock_to_live (bool): Whether to lock line end to current bar
Returns: 0 (for chaining)
f_process_naked_lines(arr, calc_bars, bars_per_day, keep_to_day_end)
Process naked lines (POC/VAH/VAL) with sweeping detection
Parameters:
arr (array<NakedLine>): Array of NakedLine objects
calc_bars (int): Maximum calculation bars
bars_per_day (int): Bars per day for scope calculation
keep_to_day_end (bool): Whether to extend to day end
Returns: 0 (for chaining)
f_update_pdhl_lines(pd_hl, pdh, pdl, new_day, pd_rng, bars_per_day, pdh_color, pdl_color)
Detect and create PDH/PDL lines
Parameters:
pd_hl (array<HLLine>): Array to store HLLine objects
pdh (float): Previous day high
pdl (float): Previous day low
new_day (bool): Whether it's a new day
pd_rng (float): Price range for visibility
bars_per_day (int): Bars per day
pdh_color (color): PDH line color
pdl_color (color): PDL line color
Returns: 0 (for chaining)
f_poc_from_vals(keys, vals)
Calculate POC from sorted keys and values
Parameters:
keys (array<int>): Sorted array of row keys
vals (array<float>): Array of volume values
Returns: POC row key
f_value_area(keys, vals, poc_key, va_pct)
Calculate Value Area from volume distribution
Parameters:
keys (array<int>): Sorted array of row keys
vals (array<float>): Array of volume values
poc_key (int): POC row key
va_pct (float): Value Area percentage (typically 0.70)
Returns: Tuple of [VAL_key, VAH_key]
f_find_key_sorted(keys, target)
Find key in sorted array using binary search
Parameters:
keys (array<int>): Sorted array of keys
target (int): Target key to find
Returns: Index of key, or -1 if not found
f_zscore_safe(x, len)
Safe z-score calculation using built-in functions
Parameters:
x (float): Input series
len (int): Lookback length
Returns: Z-score
HLLine
Represents a high/low line with sweeping detection
Fields:
ln (series line): Line object
lb (series label): Label object
lvl (series float): Price level
startBar (series int): Bar index where line starts
swept (series bool): Whether the level has been swept
isHigh (series bool): True if this is a high, false if low
col (series color): Line color
NakedLine
Represents a naked POC/VAH/VAL line
Fields:
ln (series line): Line object
lb (series label): Label object
lvl (series float): Price level
startBar (series int): Bar index where line starts
swept (series bool): Whether the level has been swept
sweptBar (series int): Bar index where swept occurred
endBar (series int): Bar index where line should end
Library for TPO (Time Price Opportunity) and Smart Money concepts including session management, PDH/PDL detection, sweeping logic, and volume profile utilities
f_price_to_tick(p)
Convert price to tick
Parameters:
p (float): Price value
Returns: Tick value
f_tick_to_row(t, row_ticks_in)
Convert tick to row
Parameters:
t (int): Tick value
row_ticks_in (int): Number of ticks per row
Returns: Row index
f_row_to_price(row, row_ticks_in)
Convert row to price (midpoint)
Parameters:
row (int): Row index
row_ticks_in (int): Number of ticks per row
Returns: Price at row midpoint
f_calc_row_ticks(natr_ref, row_gran_mult)
Calculate dynamic row size based on normalized ATR
Parameters:
natr_ref (float): Daily normalized ATR reference value
row_gran_mult (float): Row granularity multiplier
Returns: Number of ticks per row
f_more_transp_pct(c, pct)
Increase color transparency by percentage
Parameters:
c (color): Input color
pct (float): Percentage to increase transparency (0.0 to 1.0)
Returns: Color with increased transparency
f_dom_color(dom, buy_col, sell_col, gamma, transp_weak, transp_strong)
Calculate dominance color based on buy/sell ratio
Parameters:
dom (float): Dominance ratio (-1 to 1, negative = sell, positive = buy)
buy_col (color): Buy dominant color
sell_col (color): Sell dominant color
gamma (float): Gamma correction for color intensity
transp_weak (int): Transparency for weak dominance
transp_strong (int): Transparency for strong dominance
Returns: Blended color
f_sess_part(sess_str, get_start)
Parse session string to get start or end time
Parameters:
sess_str (string): Session string in format "HHMM-HHMM"
get_start (bool): True to get start time, false to get end time
Returns: Time string in HHMM format
f_hhmm_to_h(hhmm)
Convert HHMM string to hours
Parameters:
hhmm (string): Time string in HHMM format
Returns: Hours (0-23)
f_hhmm_to_m(hhmm)
Convert HHMM string to minutes
Parameters:
hhmm (string): Time string in HHMM format
Returns: Minutes (0-59)
f_prev_day_window_bounds(today_day_rth, win_start, win_end, session_tz)
Calculate previous day window bounds
Parameters:
today_day_rth (int): Today's RTH start timestamp
win_start (string): Window start time in HHMM format
win_end (string): Window end time in HHMM format
session_tz (string): Session timezone
Returns: Tuple of [window_start_ms, window_end_ms]
f_default_session_colors()
Get default session colors
Returns: Array of 4 colors [Asia, Frankfurt, London, NY]
f_session_names()
Get session names
Returns: Array of 4 session names
f_process_hl(arr, rng, keep_bars, lock_to_live)
Process high/low lines with sweeping detection
Parameters:
arr (array<HLLine>): Array of HLLine objects
rng (float): Price range for visibility filtering
keep_bars (int): Maximum bars to keep lines
lock_to_live (bool): Whether to lock line end to current bar
Returns: 0 (for chaining)
f_process_naked_lines(arr, calc_bars, bars_per_day, keep_to_day_end)
Process naked lines (POC/VAH/VAL) with sweeping detection
Parameters:
arr (array<NakedLine>): Array of NakedLine objects
calc_bars (int): Maximum calculation bars
bars_per_day (int): Bars per day for scope calculation
keep_to_day_end (bool): Whether to extend to day end
Returns: 0 (for chaining)
f_update_pdhl_lines(pd_hl, pdh, pdl, new_day, pd_rng, bars_per_day, pdh_color, pdl_color)
Detect and create PDH/PDL lines
Parameters:
pd_hl (array<HLLine>): Array to store HLLine objects
pdh (float): Previous day high
pdl (float): Previous day low
new_day (bool): Whether it's a new day
pd_rng (float): Price range for visibility
bars_per_day (int): Bars per day
pdh_color (color): PDH line color
pdl_color (color): PDL line color
Returns: 0 (for chaining)
f_poc_from_vals(keys, vals)
Calculate POC from sorted keys and values
Parameters:
keys (array<int>): Sorted array of row keys
vals (array<float>): Array of volume values
Returns: POC row key
f_value_area(keys, vals, poc_key, va_pct)
Calculate Value Area from volume distribution
Parameters:
keys (array<int>): Sorted array of row keys
vals (array<float>): Array of volume values
poc_key (int): POC row key
va_pct (float): Value Area percentage (typically 0.70)
Returns: Tuple of [VAL_key, VAH_key]
f_find_key_sorted(keys, target)
Find key in sorted array using binary search
Parameters:
keys (array<int>): Sorted array of keys
target (int): Target key to find
Returns: Index of key, or -1 if not found
f_zscore_safe(x, len)
Safe z-score calculation using built-in functions
Parameters:
x (float): Input series
len (int): Lookback length
Returns: Z-score
HLLine
Represents a high/low line with sweeping detection
Fields:
ln (series line): Line object
lb (series label): Label object
lvl (series float): Price level
startBar (series int): Bar index where line starts
swept (series bool): Whether the level has been swept
isHigh (series bool): True if this is a high, false if low
col (series color): Line color
NakedLine
Represents a naked POC/VAH/VAL line
Fields:
ln (series line): Line object
lb (series label): Label object
lvl (series float): Price level
startBar (series int): Bar index where line starts
swept (series bool): Whether the level has been swept
sweptBar (series int): Bar index where swept occurred
endBar (series int): Bar index where line should end
Sürüm Notları
v2Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.