PINE LIBRARY
Updated StrengthFactors

Library "StrengthFactors"
Strength factor calculations for various market analysis metrics
get_threshold(opt, input_val, avg_val, lineancy)
Calculate threshold based on options
Parameters:
opt (string): Threshold option ("Disabled", "User Input Threshold", "Average as Threshold")
input_val (float): User input threshold value
avg_val (float): Average value for threshold
lineancy (float): Lineancy adjustment percentage
Returns: Calculated threshold
get_percentage_of_threshold(value, threshold)
Calculate percentage of threshold
Parameters:
value (float): Current value
threshold (float): Threshold value
Returns: Percentage of threshold
get_distance_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Distance Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [distance_sf, distance_avg, distance_threshold, distance_prc_of_thr]
get_uniformity_sf(lookback, thr_opt, thr_inp, stddev_mult, lineancy)
Calculate Uniformity Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
stddev_mult (float): Standard deviation multiplier
lineancy (float): Lineancy adjustment
Returns: [uniformity_sf, uniformity_threshold, uniformity_prc_of_thr]
get_overlap_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Overlap Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [overlap_sf, overlap_avg, overlap_threshold, overlap_prc_of_thr]
get_body_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Body Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [body_sf, body_avg, body_threshold, body_prc_of_thr]
get_close_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Close Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [close_sf, close_avg, close_threshold, close_prc_of_thr]
get_breakout_sf(lookback, thr_opt, thr_inp, lineancy, bro_dir, is_inside_bar)
Calculate Breakout Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
bro_dir (int): Breakout direction
is_inside_bar (bool): Is inside bar flag
Returns: [breakout_sf, breakout_avg, breakout_threshold, breakout_prc_of_thr]
get_always_in_sf(thr_opt, thr_inp, lineancy)
Calculate Always-In Strength Factor
Parameters:
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [always_in_sf, always_in_avg, always_in_threshold, always_in_prc_of_thr]
get_directional_sf(overlap_prc, distance_prc, body_prc, close_prc, breakout_prc, lookback, thr_opt, thr_inp, lineancy)
Calculate Directional Strength Factor (composite)
Parameters:
overlap_prc (float): Overlap SF as percentage of threshold
distance_prc (float): Distance SF as percentage of threshold
body_prc (float): Body SF as percentage of threshold
close_prc (float): Close SF as percentage of threshold
breakout_prc (float): Breakout SF as percentage of threshold
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [directional_sf, directional_avg, directional_threshold, directional_prc_of_thr]
get_combined_direction_sf(body_prc, close_prc, breakout_prc, lookback, thr_opt, thr_inp, lineancy)
Calculate Combined Direction Strength Factor
Parameters:
body_prc (float): Body SF as percentage of threshold
close_prc (float): Close SF as percentage of threshold
breakout_prc (float): Breakout SF as percentage of threshold
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [combined_sf, combined_avg, combined_threshold, combined_prc_of_thr]
get_all_strength_factors(lookback, lineancy, dist_thr_opt, dist_thr_inp, body_thr_opt, body_thr_inp, close_thr_opt, close_thr_inp, breakout_thr_opt, breakout_thr_inp, bro_dir, is_inside_bar)
Get all strength factors at once (convenience function)
Parameters:
lookback (int): Lookback period for averages
lineancy (float): Lineancy adjustment percentage
dist_thr_opt (string): Distance threshold option
dist_thr_inp (float): Distance threshold input
body_thr_opt (string): Body threshold option
body_thr_inp (float): Body threshold input
close_thr_opt (string): Close threshold option
close_thr_inp (float): Close threshold input
breakout_thr_opt (string): Breakout threshold option
breakout_thr_inp (float): Breakout threshold input
bro_dir (int): Breakout direction
is_inside_bar (bool): Is inside bar flag
Returns: Map containing all strength factor results
Strength factor calculations for various market analysis metrics
get_threshold(opt, input_val, avg_val, lineancy)
Calculate threshold based on options
Parameters:
opt (string): Threshold option ("Disabled", "User Input Threshold", "Average as Threshold")
input_val (float): User input threshold value
avg_val (float): Average value for threshold
lineancy (float): Lineancy adjustment percentage
Returns: Calculated threshold
get_percentage_of_threshold(value, threshold)
Calculate percentage of threshold
Parameters:
value (float): Current value
threshold (float): Threshold value
Returns: Percentage of threshold
get_distance_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Distance Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [distance_sf, distance_avg, distance_threshold, distance_prc_of_thr]
get_uniformity_sf(lookback, thr_opt, thr_inp, stddev_mult, lineancy)
Calculate Uniformity Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
stddev_mult (float): Standard deviation multiplier
lineancy (float): Lineancy adjustment
Returns: [uniformity_sf, uniformity_threshold, uniformity_prc_of_thr]
get_overlap_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Overlap Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [overlap_sf, overlap_avg, overlap_threshold, overlap_prc_of_thr]
get_body_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Body Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [body_sf, body_avg, body_threshold, body_prc_of_thr]
get_close_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Close Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [close_sf, close_avg, close_threshold, close_prc_of_thr]
get_breakout_sf(lookback, thr_opt, thr_inp, lineancy, bro_dir, is_inside_bar)
Calculate Breakout Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
bro_dir (int): Breakout direction
is_inside_bar (bool): Is inside bar flag
Returns: [breakout_sf, breakout_avg, breakout_threshold, breakout_prc_of_thr]
get_always_in_sf(thr_opt, thr_inp, lineancy)
Calculate Always-In Strength Factor
Parameters:
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [always_in_sf, always_in_avg, always_in_threshold, always_in_prc_of_thr]
get_directional_sf(overlap_prc, distance_prc, body_prc, close_prc, breakout_prc, lookback, thr_opt, thr_inp, lineancy)
Calculate Directional Strength Factor (composite)
Parameters:
overlap_prc (float): Overlap SF as percentage of threshold
distance_prc (float): Distance SF as percentage of threshold
body_prc (float): Body SF as percentage of threshold
close_prc (float): Close SF as percentage of threshold
breakout_prc (float): Breakout SF as percentage of threshold
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [directional_sf, directional_avg, directional_threshold, directional_prc_of_thr]
get_combined_direction_sf(body_prc, close_prc, breakout_prc, lookback, thr_opt, thr_inp, lineancy)
Calculate Combined Direction Strength Factor
Parameters:
body_prc (float): Body SF as percentage of threshold
close_prc (float): Close SF as percentage of threshold
breakout_prc (float): Breakout SF as percentage of threshold
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
lineancy (float): Lineancy adjustment
Returns: [combined_sf, combined_avg, combined_threshold, combined_prc_of_thr]
get_all_strength_factors(lookback, lineancy, dist_thr_opt, dist_thr_inp, body_thr_opt, body_thr_inp, close_thr_opt, close_thr_inp, breakout_thr_opt, breakout_thr_inp, bro_dir, is_inside_bar)
Get all strength factors at once (convenience function)
Parameters:
lookback (int): Lookback period for averages
lineancy (float): Lineancy adjustment percentage
dist_thr_opt (string): Distance threshold option
dist_thr_inp (float): Distance threshold input
body_thr_opt (string): Body threshold option
body_thr_inp (float): Body threshold input
close_thr_opt (string): Close threshold option
close_thr_inp (float): Close threshold input
breakout_thr_opt (string): Breakout threshold option
breakout_thr_inp (float): Breakout threshold input
bro_dir (int): Breakout direction
is_inside_bar (bool): Is inside bar flag
Returns: Map containing all strength factor results
Release Notes
v2Updated:
get_uniformity_sf(lookback, thr_opt, thr_inp, stddev_mult, lineancy)
Calculate Uniformity Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input
stddev_mult (float): Standard deviation multiplier
lineancy (float): Lineancy adjustment
Returns: [uniformity_sf, uniformity_avg, uniformity_threshold, uniformity_prc_of_thr]
Release Notes
v3Release Notes
v4Added:
get_breakout_direction(higH, loW, high_prev, low_prev)
Calculate breakout direction based on price action
Parameters:
higH (float): Current high
loW (float): Current low
high_prev (float): Previous high
low_prev (float): Previous low
Returns: [bro_dir, is_outside_bar, is_inside_bar] Breakout direction and bar type flags
Updated:
get_distance_sf(lookback, thr_opt, thr_inp, lineancy)
Calculate Distance Strength Factor
Parameters:
lookback (int): Lookback period for average
thr_opt (string): Threshold option
thr_inp (float): User threshold input (as multiplier of average)
lineancy (float): Lineancy adjustment
Returns: [distance_sf, distance_avg, distance_threshold, distance_prc_of_thr]
get_all_strength_factors(lookback, lineancy, dist_thr_opt, dist_thr_inp, uni_thr_opt, uni_thr_inp, uni_stddev_mult, ovl_thr_opt, ovl_thr_inp, body_thr_opt, body_thr_inp, close_thr_opt, close_thr_inp, breakout_thr_opt, breakout_thr_inp, bro_dir, is_inside_bar)
Get all strength factors at once (convenience function)
Parameters:
lookback (int): Lookback period for averages
lineancy (float): Lineancy adjustment percentage
dist_thr_opt (string): Distance threshold option
dist_thr_inp (float): Distance threshold input
uni_thr_opt (string): Uniformity threshold option
uni_thr_inp (float): Uniformity threshold input
uni_stddev_mult (float): Uniformity standard deviation multiplier
ovl_thr_opt (string): Overlap threshold option
ovl_thr_inp (float): Overlap threshold input
body_thr_opt (string): Body threshold option
body_thr_inp (float): Body threshold input
close_thr_opt (string): Close threshold option
close_thr_inp (float): Close threshold input
breakout_thr_opt (string): Breakout threshold option
breakout_thr_inp (float): Breakout threshold input
bro_dir (int): Breakout direction
is_inside_bar (bool): Is inside bar flag
Returns: Map containing all strength factor results
Release Notes
v5Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.