:( 是个书上的代码,为啥运行有错
function [PATTERNS]=flags(ys, w, typeofdist, thor, pflag)
%% Data preparation
l=length(ys);
[Peaks,Bottoms]=RW(ys,w,0);
% Ignore locals identified the first days
Peaks(Peaks(:,2)<=20,:)=[];
Bottoms(Bottoms(:,2)<=20,:)=[];
P_Indx=Peaks(:,2);B_Indx=Bottoms(:,2);
P_Indx=[P_Indx ones(length(P_Indx),1)];
B_Indx=[B_Indx 2*ones(length(B_Indx),1)];
PB_Indx=sortrows([P_Indx;B_Indx]);
m=size(PB_Indx,1); % Number of locals
Pot.FlagBull=[1;2;1;2];
Pot.FlagBear=[2;1;2;1];
Pot.Index=zeros(m,1);
for i=1:m-3
if PB_Indx(i:i+3,2)==Pot.FlagBull
Pot.Index(i+3,1)=1; % Potential Bullish Flags
elseif PB_Indx(i:i+3,2)==Pot.FlagBear
Pot.Index(i+3,1)=2; % Potential Bearish Flags
end
end
%% FLAGS (BULLISH)
PFBullidx=find(Pot.Index==1);
j=0;% Counter
mn=length(PFBullidx);
if mn~=0
for i=1:mn
PC=zeros(4,3);% PerCase
PC(:,[1,2])=PB_Indx(PFBullidx(i,1)-3:PFBullidx(i,1),:);
PC(:,3)=ys(PC(:,1));
YS=[ys,(1:l)'];
if PC(1,1)-thor<=0
Flocalx=1;
else
Flocalx=PC(1,1)-thor;
end
YS2=YS(Flocalx:PC(1,1),:);
% Beginning of the prevailing trend
[~, Flocalx2 ]=min(YS2(:,1));
最后一行为啥说我可能少了括号啥的呀。。。。。???? 我是抄书上的额


雷达卡


京公网安备 11010802022788号







