Library "TA"
General technical analysis functions
div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bullish divergence
Parameters:
pS: Price series (float)
iS: Indicator series (float)
cp_length_after: Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
cp_length_before: Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
pivot_length: Bars before and after prior pivot low to be considered valid pivot (optional int)
lookback: Bars back to search for prior pivot low (optional int)
no_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW: Weight of change in price, used in degree of divergence calculation (optional float)
iW: Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW: Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW: Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns: [flag,degree,type,lx1,ly1,lx2,ly2]
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW)
Test for bearish divergence
Parameters:
pS: Price series (float)
iS: Indicator series (float)
cp_length_after: Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
cp_length_before: Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
pivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int)
lookback: Bars back to search for prior pivot high (optional int)
no_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW: Weight of change in price, used in degree of divergence calculation (optional float)
iW: Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW: Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW: Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns: [flag,degree,type,lx1,ly1,lx2,ly2]
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)