PINE LIBRARY
Cập nhật Liquidation_lines

Library "Liquidationline"
f_calculateLeverage(_leverage, _maintainance, _value, _direction)
Parameters:
_leverage
_maintainance
_value
_direction
f_liqline_update(_Liqui_Line, _killonlowhigh)
Parameters:
_Liqui_Line
_killonlowhigh
f_liqline_draw(_Liqui_Line, _priceorliq)
Parameters:
_Liqui_Line
_priceorliq
f_liqline_add(_Liqui_Line, linetoadd, _limit)
Parameters:
_Liqui_Line
linetoadd
_limit
Liquidationline
Fields:
creationtime
stoptime
price
leverage
maintainance
line_active
line_color
line_thickness
line_style
line_direction
line_finished
text_active
text_size
text_color
this library can draw typical liquidation lines, which can be called e.g. by indicator signals
You can see the default implementation in the lower part of the code, starting with RUNTIME
Don't forget to increase max lines to 500 in your script.
It can look like this screenshot here, with only minor changes to your executing script.
The base is the same

f_calculateLeverage(_leverage, _maintainance, _value, _direction)
Parameters:
_leverage
_maintainance
_value
_direction
f_liqline_update(_Liqui_Line, _killonlowhigh)
Parameters:
_Liqui_Line
_killonlowhigh
f_liqline_draw(_Liqui_Line, _priceorliq)
Parameters:
_Liqui_Line
_priceorliq
f_liqline_add(_Liqui_Line, linetoadd, _limit)
Parameters:
_Liqui_Line
linetoadd
_limit
Liquidationline
Fields:
creationtime
stoptime
price
leverage
maintainance
line_active
line_color
line_thickness
line_style
line_direction
line_finished
text_active
text_size
text_color
this library can draw typical liquidation lines, which can be called e.g. by indicator signals
You can see the default implementation in the lower part of the code, starting with RUNTIME
Don't forget to increase max lines to 500 in your script.
It can look like this screenshot here, with only minor changes to your executing script.
The base is the same
Phát hành các Ghi chú
v2Runtime Demo update, no function changes
Phát hành các Ghi chú
This update mainly does 2 things:Deleting lines which are just wasting free lines (selectable min length, -1 to disable (standard value in the function)
Speeding up the runtime by filtering doublegets inside the liqline_update by a additional if branche for preselection
gets are slow, so why calculate when not needed.
small fixes:
typo on bollinger block always requesting BB Nr. 1 instead of 1 2 3
v3
Added:
f_getbartime()
this does give you the average time per bar from a sample of 100 bars
Updated:
f_liqline_update(_Liqui_Line, _killonlowhigh, _minlength, _timeperbar)
Parameters:
_Liqui_Line (Liquidationline[])
_killonlowhigh (bool)
_minlength (int)
_timeperbar (float)
minlength and timeperbar is added but not needed to function correctly.
aware this adds some repainting behavior as it deletes lines after detecting
Phát hành các Ghi chú
v4Added:
f_calculate_liquidation_price_v2(_entry_price, _leverage, _maintenance_input, _direction)
Calculates a liquidation price using the established legacy formula.
note The maintenance input semantics intentionally match f_calculateLeverage().
Parameters:
_entry_price (float)
_leverage (float)
_maintenance_input (float)
_direction (string)
f_liqline_new_v2(_entry_price, _leverage, _maintenance_input, _direction, _line_color, _line_width, _line_style, _text_active, _text_size, _text_color, _strength, _source_id, _leverage_tier)
Creates a fully initialized managed liquidation level.
Parameters:
_entry_price (float)
_leverage (float)
_maintenance_input (float)
_direction (string)
_line_color (color)
_line_width (int)
_line_style (string)
_text_active (bool)
_text_size (string)
_text_color (color)
_strength (float)
_source_id (int)
_leverage_tier (int)
f_liqline_price_v2(_level, _show_position_price)
Returns either the entry price or calculated liquidation price.
Parameters:
_level (LiquidationlineV2)
_show_position_price (bool)
f_liqline_delete_v2(_level)
Deletes all drawings belonging to one managed level.
Parameters:
_level (LiquidationlineV2)
f_liqline_add_v2(_levels, _level, _limit)
Adds a level and explicitly deletes drawings of an evicted level.
Parameters:
_levels (array<LiquidationlineV2>)
_level (LiquidationlineV2)
_limit (int)
f_liqline_update_v2(_levels, _kill_on_low_high, _minimum_bars, _keep_finished)
Updates active levels, marks hits, and optionally removes finished levels.
Parameters:
_levels (array<LiquidationlineV2>)
_kill_on_low_high (bool)
_minimum_bars (int): Set to -1 to retain all finished levels regardless of lifetime.
_keep_finished (bool): If false, a hit level and its drawings are removed immediately.
f_liqline_near_price_v2(_levels, _price, _maximum_distance, _active_only)
Returns true when an eligible level lies within _maximum_distance of _price.
Parameters:
_levels (array<LiquidationlineV2>)
_price (float)
_maximum_distance (float)
_active_only (bool): If true, finished levels are ignored.
f_liqline_active_count_v2(_levels)
Counts active, unfinished managed liquidation levels.
Parameters:
_levels (array<LiquidationlineV2>)
f_liqline_draw_v2(_levels, _show_position_price, _show_finished, _finished_transparency, _age_fade_bars)
Draws or updates persistent line/label objects on the last chart bar.
Parameters:
_levels (array<LiquidationlineV2>)
_show_position_price (bool)
_show_finished (bool)
_finished_transparency (int)
_age_fade_bars (int)
f_liqline_hide_v2(_levels)
Deletes managed drawings without removing their data objects.
description Use this as a visibility toggle; calling f_liqline_draw_v2() later recreates the drawings.
Parameters:
_levels (array<LiquidationlineV2>)
f_liqline_clear_v2(_levels)
Deletes every managed line/label and clears the array.
Parameters:
_levels (array<LiquidationlineV2>)
LiquidationlineV2
Managed liquidation level with persistent drawing references.
Fields:
creation_time (series int)
stop_time (series int)
creation_bar (series int)
stop_bar (series int)
entry_price (series float)
leverage (series float)
maintenance_input (series float)
liquidation_price (series float)
direction (series string)
line_active (series bool)
line_finished (series bool)
line_color (series color)
line_width (series int)
line_style (series string)
text_active (series bool)
text_size (series string)
text_color (series color)
strength (series float)
source_id (series int)
leverage_tier (series int)
drawing (series line)
caption (series label)
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
telegram - @djmad_0815
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
telegram - @djmad_0815
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.