股票均线颜色函数-股票均线颜色函数是什么

2023-07-25 入门知识 0次阅读 admin
股票均线颜色函数.jpg

关于股票均线颜色函数的问题,我们总结了以下几点,给你解答:

股票均线颜色函数


股票均线颜色函数


def get_ma_color(self, ma_list):
color_list = []
for i in range(len(ma_list)):
if ma_list[i] > ma_list[i-1]:
color_list.append('red')
elif ma_list[i] < ma_list[i-1]:
color_list.append('green')
else:
color_list.append('black')
return color_list

# 获取股票均线宽度函数
def get_ma_width(self, ma_list):
width_list = []
for i in range(len(ma_list)):
if ma_list[i] > ma_list[i-1]:
width_list.append(2)
elif ma_list[i] < ma_list[i-1]:
width_list.append(2)
else:
width_list.append(1)
return width_list

# 获取股票均线标签函数
def get_ma_label(self, ma_list):
label_list = []
for i in range(len(ma_list)):
label_list.append(str(ma_list[i]))
return label_list

# 获取股票均线标签位置函数
def get_ma_label_pos(self, ma_list):
label_pos_list = []
for i in range(len(ma_list)):
label_pos_list.append(i-0.4)
return label_pos_list

# 绘制股票均线函数
def draw_ma(self, ax, ma_list):
color_list = self.get_ma_color(ma_list)
width_list = self.get_ma_width(ma_list)
label_list = self.get_ma_label(ma_list)
label_pos_list = self.get_ma_label_pos(ma_list)
for i in range(len(ma_list)):
ax.plot(i, ma_list[i], color=color_list[i], linewidth=width_list[i], label=label_list[i])
ax.text(label_pos_list[i], ma_list[i], label_list[i], color=color_list[i], fontsize=10)

# 绘制股票K线函数
def draw_k_line(self, ax, k_data):
# 获取K线数据
date_list = k_data['date']
open_list = k_data['open']
close_list = k_data['close']
high_list = k_data['high']
low_list = k_data['low']
# 绘制K线
for i in range(len(date_list)):
# 判断K线颜色
if close_list[i] > open_list[i]:
color = 'red'
elif close_list[i] < open_list[i]:
color = 'green'
else:
color = 'black'
# 绘制K线
ax.plot([i-0.25, i-0.25], [low_list[i], high_list[i]], color=color, linewidth=1.5)
ax.plot([i-0.25, i+0.25], [open_list[i], open_list[i]], color=color, linewidth=1.5)
ax.plot([i-0.25, i+0.25], [close_list[i], close_list[i]], color=color, linewidth=1.5)
ax.plot([i+0.25, i+0.25], [low_list[i], high_list[i]], color=color, linewidth=1.5)
# 绘制K线标签
ax.text(i, high_list[i], str(high_list[i]), color=color, fontsize=10)
ax.text(i, low_list[i], str(low_list[i]), color=color, fontsize=10)
ax.text(i, open_list[i], str(open_list[i]), color=color, fontsize=10)
ax.text(i, close_list[i], str(close_list[i]), color=color, fontsize=10)
# 设置X轴刻度
ax.set_xticks(range(len(date_list)))
ax.set_xticklabels(date_list, rotation=45)

# 绘制股票K线图函数
def draw_k_chart(self, k_data, ma_list):
# 创建画布
fig = plt.figure(figsize=(16, 8))
# 创建子图
ax = fig.add_subplot(111)
# 绘制K线
self.draw_k_line(ax, k_data)
# 绘制均线
self.draw_ma(ax, ma_list)
# 显示图形
plt.show()

# 主函数
if __name__ == '__main__':
# 创建K线图类
k_chart = KChart()
# 获取股票数据
k_data = k_chart.get_k_data('600000')
# 获取股票均线数据
ma_list = k_chart.get_ma_data(k_data, 5)
# 绘制股票K线图
k_chart.draw_k_chart(k_data, ma_list)

均线颜色公式指标


均线颜色公式指标

{MA N:MA(CLOSE,N),COLOR00D200,linethick1,DOTLINE;}partline(MA N,MA N>=ref(MA N,1),rgb(255,0,0),MA N

股票均线颜色函数是什么


股票均线颜色函数是什么

1、同花顺默认是黑底白字的。K线图中有粉红线、黄线、绿线、蓝线、白线,指的是那是移动平均线,在日K线图中一来自般白线、黄线、紫线、绿线依次分别表示:5、10、20、60日移动平均线,但这并不是固定的,会根据设置的不同而不同,比如也可以在系统里把它们设为5、15、30、60均线。
2、同花顺股票软件是一个提供行情显示、行情分析和行情交易的股票书缺显软件,它分为免费PC产品,付费PC产品,电脑平板段觉低织制附双握产品,手机产品等适用性强的多个版本。同花顺股票软件注重各大证券机构、广大股民的需求视云底把足规八转司和使用习惯,同花顺股票软件全新版免注册。全新版同花顺股票软件新增强大功能:自主研发的搜牛财经及自定义选股,新增通达信模式。

猜你感兴趣: 股票均线颜色函数