talib如何检测模式?

时间:2020-01-15 05:56:33

标签: python ta-lib

sample_data = [
    ['1/22/14', 10, 18, 5, 20],
    ['1/23/14', 12, 21, 7, 22],
    ['1/24/14', 14, 24, 9, 24],
    ['1/25/14', 16, 27, 11, 26],
    ['1/26/14', 18, 30, 13, 28],
    ['1/27/14', 20, 33, 15, 30],
    ['1/28/14', 22, 36, 17, 32],
    ['1/29/14', 24, 39, 19, 34],
    ['1/30/14', 26, 41, 21, 38],
    ['1/31/14', 30, 45, 25, 30],
    ['2/03/14', 241.75, 243.15, 240.65, 241.80],
    ['1/31/14', 30, 45, 25, 30],
]

# convert data to columns
sample_data = np.column_stack(sample_data)

# extract the columns we need, making sure to make them 64-bit floats
o = sample_data[1].astype(float)
h = sample_data[2].astype(float)
l = sample_data[3].astype(float)
c = sample_data[4].astype(float)

print(talib.CDLDOJI(o, h, l, c))

输出为:[0 0 0 0 0 0 0 0 0 0 0 100 100]

但是如果您查看的最后一个数据和倒数第二个数据是相同的,但是仍然没有检测到,我注意到它仅在经过10支蜡烛后才开始检测模式,这是正确的,或者我错过了一些东西。 / p>

1 个答案:

答案 0 :(得分:1)

根据代码:

/ *小于10%的真实身体就像十字星的身体 10 上一个蜡烛的高低范围的平均值* /

如果检测到蜡烛,函数将返回0或100。 因此,前10个值必须为0。