[PEL] 复制代码 //n:=10;
//
//hlen:hhvbars(h,n),nodraw;
//h1:=hhv(h,n);
//
//l1_len:=n-hlen;
//
//left_lindex:0,nodraw; //最大值左侧最小值的k线位置
//left_minl:0,nodraw;//最大值左侧的最小值
//
//right_lindex:0,nodraw; //最大值右侧最小值的k线位置
//right_minl:0,nodraw;//最大值右侧的最小值
//
//
//v1:=llvbars(l,hlen);
//v2:=llv(l,hlen);
////要排除掉n根k内 第一个或者最后一个k是最大值的情况
//if hlen<n-1 and hlen>0 then
//begin
//for i=l1_len+1 to n-1 do
//begin
//if left_minl=0 then left_minl:= l[barpos-i];
//
//if l[barpos-i]<left_minl then
//begin
//left_lindex:=i;
//left_minl:=l[barpos-i];
//end
//end
//
//right_lindex:=v1;tenterbars
//right_minl:=v2;
//end
N:=3;
currentl:=rounds(l*(1+N/100),1);//做个小数点的处理,这样就能比较了。否则几乎不可能有相等的值。
ctr:=1;//控制循环
index:=barpos-1;//当前k的前一个位置
while ctr do
begin
if currentl<=H[index] or index<0 then
begin
ctr:=0;
end
index:=index-1;
end
showbarpos1:index+1,nodraw;//返回的是满足条件的k线位置的序号。如果返回值是-1 说明前面没有找到这样的k线位置。
//对历史位置取值
r1:if(showbarpos1<>-1,h[showbarpos1],drawnull),nodraw;
M:=3;
currenth:=rounds(H*(1-M/100),1);
ctr:=1;//控制循环
index:=barpos-1;//当前k的前一个位置
while ctr do
begin
if currenth>=l[index] or index<0 then
begin
ctr:=0;
end
index:=index-1;
end
showbarpos2:index+1,nodraw;//返回的是满足条件的k线位置的序号。如果返回值是-1 说明前面没有找到这样的k线位置。
//对历史位置取值
r2:if(showbarpos2<>-1,l[showbarpos2],drawnull),nodraw; |