Im trying to to create a heatmap with candle stick chart together , in heatmap i would like to reset the heatmap level when the levels is closed by price,
我试图创建一个热图与蜡烛棒图表在一起,在热图我想要重置热图水平时,水平是关闭的价格,
def generate_heatmap(data, price_levels, date_range):
L100x = calculate_price_levels(data)
heatmap = np.zeros((len(price_levels) - 1, len(date_range)))
close_gt_open = data['Close'] > data['Open']
open_gt_close = data['Open'] > data['Close']
for j in range(len(price_levels) - 1):
price_level = price_levels[j]
next_price_level = price_levels[j + 1]
cell_value = np.zeros(len(date_range), dtype=int)
for i, date in enumerate(date_range):
date_mask = (data.index <= date)
if date_mask.any() and np.any((data[date_mask]['Low'] < price_level)):
cell_value[i] = 0
else:
cell_value[i] += np.sum(
[
(date_mask & (L100x >= price_level) & (L100x < next_price_level) & close_gt_open),
]
)
heatmap[j, :] = cell_value
return heatmap, date_range, price_levels[:-1]
here is the code
以下是代码
in code above when price close below level i did set cell value to zero , it works but later the broken level never gets colored again even if condition is true for it ,
the question is how to reset it when broke but it should be allowed to be colored again starting from first occurrence .
在上面的代码中,当价格收盘低于水平时,我确实将单元格值设置为零,但它起作用了,但后来打破的水平永远不会再次着色,即使它的条件为真,问题是当它被打破时如何重置它,但应该允许它从第一次出现时再次着色。
thanks
谢谢
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!