function [X1,X2,X3,X4,X5,X6,X7,data] = func_Technical_Indicators(data0);
%SMA
N = 8;
M = 3;
data = data0(:,4);
for i = 1:length(data);
if i == 1
X1(i) = data(i);
else
X1(i) = M*data(i)/(N+1)+(N-1)/(N+1)*X1(i-1);
end
end
%EMA
N = 8;
data = data0(:,4);
for i = 1:length(data);
if i == 1
X2(i) = data(i);
else
X2(i) = 2*data(i)/(N+1)+(N-1)/(N+1)*X2(i-1);
end
end
%MACD
data = data0(:,4);
X3 = [macd(data)]';
%MFI
% R = [Price_max',Price_min',Price_open',Price_close',Volume'];
TYP = (data0(:,1) + data0(:,2) + data0(:,4))/3;
N = 8;
for i = 1:length(data)
if i == 1
tmp1(i) = TYP(i) * data0(i,5);
tmp2(i) = TYP(i) * data0(i,5);
else
if TYP(i) > TYP(i-1)
tmp1(i) = TYP(i) * data0(i,5);
else
tmp1(i) = 0;
end
if TYP(i) < TYP(i-1)
tmp2(i) = TYP(i) * data0(i,5);
else
tmp2(i) = 0;
end
end
end
for i = 1:length(data)
if i <= N
V1(i) = sum(tmp1(1:i))/sum(tmp2(1:i));
else
V1(i) = sum(tmp1(i-N+1:i))/sum(tmp2(i-N+1:i));
end
end
X4 = V1;
%AI
N = 8;
data = data0(:,4);
for i = 1:length(data);
if i <= N
X5(i) = data(i)/sum(data(1:i));
else
X5(i) = data(i)/sum(data(i-N:i));
end
end
%RSI
data = data0(:,4);
for i = 1:length(data);
if i == 1
tmps0(i) = 1;
else
if data(i) >= data(i-1)
tmps0(i) = 1;
else
tmps0(i) = -1;
end
end
end
tmps0=tmps0';
tmps = zeros(14,length(data));
for i = 1:length(data);
if i <= 14
tmps(:,i) = [zeros(14-i,1);tmps0(1:i).*data(1:i)];
else
tmps(:,i) = [tmps0(i-13:i).*data(i-13:i)];
end
end
for i = 1:length(tmps);
A=0;
B=0;
for j = 1:14
if tmps(j,i) >=0
A = A+tmps(j,i);
else
B = B-tmps(j,i);
end
end
X6(i) = 100*A/(A+B);
end
%CCI
TYP = (data0(:,1) + data0(:,2) + data0(:,4))/3;
N = 14;
for i = 1:length(data)
if i <= 14
tm1(i) = mean(data(1:i));
else
tm1(i) = mean(data(i-N+1:i));
end
if i <= 14
tm2(i) = data(i)-mean(data(1:i));
else
tm2(i) = data(i)-mean(data(i-N+1:i));
end
CCI(i) = (TYP(i) - tm1(i))/(0.015*tm2(i));
end
X7 = CCI;
ide1 = find(isnan(X1)==1);
X1(ide1) = 0;
ide2 = find(isnan(X2)==1);
X2(ide2) = 0;
ide3 = find(isnan(X3)==1);
X3(ide3) = 0;
ide4 = find(isnan(X4)==1);
X4(ide4) = 0;
ide5 = find(isnan(X5)==1);
X5(ide5) = 0;
ide6 = find(isnan(X6)==1);
X6(ide6) = 0;
ide7 = find(isnan(X7)==1);
X7(ide7) = 0;
ide1 = find(abs(X1)>=1000000);
X1(ide1) = 100;
ide2 = find(abs(X2)>=1000000);
X2(ide2) = 100;
ide3 = find(abs(X3)>=1000000);
X3(ide3) = 100;
ide4 = find(abs(X4)>=1000000);
X4(ide4) = 100;
ide5 = find(abs(X5)>=1000000);
X5(ide5) = 100;
ide6 = find(abs(X6)>=1000000);
X6(ide6) = 100;
ide7 = find(abs(X7)>=1000000);
X7(ide7) = 100;
fpga和matlab
- 粉丝: 18w+
- 资源: 2644
最新资源
- 03-【培训流程】05-新员工入职培训流程图.docx
- 04-【培训通知】01-新员工培训通知.docx
- 03-【培训流程】06-新员工培训流程图及工作标准.doc.docx
- 02-【培训方案】06-新员工入职培训的方案.docx
- 02-【培训方案】08-新员工入职培训体系.docx
- 02-【培训方案】02-员工培训课程设计方案.doc.docx
- 01-【培训计划】19-新员工培训第一周课程表.docx
- 01-【培训计划】20-新员工培训课程表.doc.docx
- 01-【培训计划】17-新员工轮岗培训计划.docx
- 01-【培训计划】05-新员工入职培训计划.docx
- 01-【培训计划】06-新员工入职培训计划.docx
- 01-【培训计划】01-入职培训流程计划.docx
- 00-【管理制度】06-新员工入职培训管理制度.docx
- 00-【管理制度】04-新员工入职培训管理制度1.docx
- 00-【管理制度】03-新员工入职培训管理制度.docx
- 11-【其他】03-新进员工入职培训计划策划(通用版).pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈