PINE LIBRARY
מעודכן lib_fvg

Library "lib_fvg"
further expansion of my object oriented library toolkit. This lib detects Fair Value Gaps and returns them as objects.
Drawing them is a separate step so the lib can be used with securities. It also allows for usage of current/close price to detect fill/invalidation of a gap and to adjust the fill level dynamically. FVGs can be detected while forming and extended indefinitely while they're unfilled.
method draw(this)
Namespace types: FVG
Parameters:
this (FVG)
method draw(fvgs)
Namespace types: FVG[]
Parameters:
fvgs (FVG[])
is_fvg(mode, precondition, filter_insignificant, filter_insignificant_atr_factor, live)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
Returns: a tuple of (bar_index of gap bar, gap top, gap bottom)
create_fvg(mode, idx, top, btm, filled_at_pc, config)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
idx (int): the bar_index of the FVG gap bar
top (float): the top level of the FVG
btm (float): the bottom level of the FVG
filled_at_pc (float): the ratio (0-1) that the fill source needs to retrace into the gap to consider it filled/invalidated/ready for removal
config (FVGConfig): the plot configuration/styles for the FVG
Returns: a new FVG object if there was a new FVG, else na
detect_fvg(mode, filled_at_pc, precondition, filter_insignificant, filter_insignificant_atr_factor, live, config)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
filled_at_pc (float)
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
config (FVGConfig)
Returns: a new FVG object if there was a new FVG, else na
method update(this, fill_src)
Namespace types: FVG
Parameters:
this (FVG)
fill_src (float): allows for usage of different fill source series, e.g. high for bearish FVGs, low vor bullish FVGs or close for both
method update(all, fill_src)
Namespace types: FVG[]
Parameters:
all (FVG[])
fill_src (float)
method remove_filled(unfilled_fvgs)
Namespace types: FVG[]
Parameters:
unfilled_fvgs (FVG[])
method delete(this)
Namespace types: FVG
Parameters:
this (FVG)
method delete_filled_fvgs_buffered(filled_fvgs, max_keep)
Namespace types: FVG[]
Parameters:
filled_fvgs (FVG[])
max_keep (int): the number of filled, latest FVGs to retain on the chart.
FVGConfig
Fields:
box_args (|robbatt/lib_plot_objects/36;BoxArgs|#OBJ)
line_args (|robbatt/lib_plot_objects/36;LineArgs|#OBJ)
box_show (series__bool)
line_show (series__bool)
keep_filled (series__bool)
extend (series__bool)
FVG
Fields:
config (|FVGConfig|#OBJ)
startbar (series__integer)
mode (series__integer)
top (series__float)
btm (series__float)
center (series__float)
size (series__float)
fill_size (series__float)
fill_lvl_target (series__float)
fill_lvl_current (series__float)
fillbar (series__integer)
filled (series__bool)
_fvg_box (|robbatt/lib_plot_objects/36;Box|#OBJ)
_fill_line (|robbatt/lib_plot_objects/36;Line|#OBJ)
further expansion of my object oriented library toolkit. This lib detects Fair Value Gaps and returns them as objects.
Drawing them is a separate step so the lib can be used with securities. It also allows for usage of current/close price to detect fill/invalidation of a gap and to adjust the fill level dynamically. FVGs can be detected while forming and extended indefinitely while they're unfilled.
method draw(this)
Namespace types: FVG
Parameters:
this (FVG)
method draw(fvgs)
Namespace types: FVG[]
Parameters:
fvgs (FVG[])
is_fvg(mode, precondition, filter_insignificant, filter_insignificant_atr_factor, live)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
Returns: a tuple of (bar_index of gap bar, gap top, gap bottom)
create_fvg(mode, idx, top, btm, filled_at_pc, config)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
idx (int): the bar_index of the FVG gap bar
top (float): the top level of the FVG
btm (float): the bottom level of the FVG
filled_at_pc (float): the ratio (0-1) that the fill source needs to retrace into the gap to consider it filled/invalidated/ready for removal
config (FVGConfig): the plot configuration/styles for the FVG
Returns: a new FVG object if there was a new FVG, else na
detect_fvg(mode, filled_at_pc, precondition, filter_insignificant, filter_insignificant_atr_factor, live, config)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
filled_at_pc (float)
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
config (FVGConfig)
Returns: a new FVG object if there was a new FVG, else na
method update(this, fill_src)
Namespace types: FVG
Parameters:
this (FVG)
fill_src (float): allows for usage of different fill source series, e.g. high for bearish FVGs, low vor bullish FVGs or close for both
method update(all, fill_src)
Namespace types: FVG[]
Parameters:
all (FVG[])
fill_src (float)
method remove_filled(unfilled_fvgs)
Namespace types: FVG[]
Parameters:
unfilled_fvgs (FVG[])
method delete(this)
Namespace types: FVG
Parameters:
this (FVG)
method delete_filled_fvgs_buffered(filled_fvgs, max_keep)
Namespace types: FVG[]
Parameters:
filled_fvgs (FVG[])
max_keep (int): the number of filled, latest FVGs to retain on the chart.
FVGConfig
Fields:
box_args (|robbatt/lib_plot_objects/36;BoxArgs|#OBJ)
line_args (|robbatt/lib_plot_objects/36;LineArgs|#OBJ)
box_show (series__bool)
line_show (series__bool)
keep_filled (series__bool)
extend (series__bool)
FVG
Fields:
config (|FVGConfig|#OBJ)
startbar (series__integer)
mode (series__integer)
top (series__float)
btm (series__float)
center (series__float)
size (series__float)
fill_size (series__float)
fill_lvl_target (series__float)
fill_lvl_current (series__float)
fillbar (series__integer)
filled (series__bool)
_fvg_box (|robbatt/lib_plot_objects/36;Box|#OBJ)
_fill_line (|robbatt/lib_plot_objects/36;Line|#OBJ)
הערות שחרור
v2 renamed field startbar to idxהערות שחרור
v3 added get_candles to generate Candle objects for the 3 candles forming the FVGAdded:
method get_candles(this)
Namespace types: FVG
Parameters:
this (FVG)
הערות שחרור
v4 fix max_bars_back error on extended boxes drawהערות שחרור
v5 added tostringAdded:
method tostring(this)
converts object to json representation
Namespace types: FVG
Parameters:
this (FVG)
הערות שחרור
v6 improved calculationהערות שחרור
v7 bugfixהערות שחרור
v8 added a fix for insignificant FVG detection before xth candle, did not work due to ta.atr(x) preventing detection earlier.Updated:
is_fvg(mode, precondition, filter_insignificant, filter_insignificant_atr_factor, insignificant_atr_len, live)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
insignificant_atr_len (simple int)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
Returns: a tuple of (bar_index of gap bar, gap top, gap bottom)
detect_fvg(mode, filled_at_pc, precondition, filter_insignificant, filter_insignificant_atr_factor, insignificant_atr_len, live, config)
Parameters:
mode (int): switch for detection 1 for bullish FVGs, -1 for bearish FVGs
filled_at_pc (float)
precondition (bool): allows for other confluences to block/enable detection
filter_insignificant (bool): allows to ignore small gaps
filter_insignificant_atr_factor (float): allows to adjust how small (compared to a 50 period ATR)
insignificant_atr_len (simple int)
live (bool): allows to detect FVGs while the third bar is forming -> will cause repainting
config (FVGConfig)
Returns: a new FVG object if there was a new FVG, else na
הערות שחרור
v9 fixed insignificant fvg filterהערות שחרור
v10 drawing FVG boxes one bar earlier to match the wick they originate fromהערות שחרור
v11 added fill_size_current and filled_pc to store amount of FVG filled in absolute and relative valuesהערות שחרור
v12 fixed calculation of filled_pcהערות שחרור
v13 allow overfilled with flll_lvl_current > fill_size and filled_pc > 1הערות שחרור
v14 upgrade to lib_plot_objects v56הערות שחרור
v15 added fields last_touch_time and last_touch_idx to FVG.ספריית Pine
ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומי קוד פתוח אחרים, אך השימוש החוזר בקוד זה בפרסומים כפוף לכללי הבית.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
ספריית Pine
ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומי קוד פתוח אחרים, אך השימוש החוזר בקוד זה בפרסומים כפוף לכללי הבית.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.