Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:数组下标越界问题

1楼
hjl 发表于:2011/7/20 13:26:06

代码:


tj2:=0;
tj3:=0;

for i=1 to datacount do
begin
 q2h[i]:=ref(high,2);
 q2l[i]:=ref(low,2);

 if ref(high,2)>=ref(high,3) and ref(high,2)>=ref(high,4) and ref(high,2)>=ref(high,1) and ref(high,2)>=high and i>=5 then gw[i]:=q2h[i];
 else gw[i]:=gw[i-1];
 if ref(low,2)<=ref(low,3) and ref(low,2)<=ref(low,4) and ref(low,2)<=ref(low,1) and ref(low,2)<=low and i>=5 then dw[i]:=q2l[i];
 else dw[i]:=dw[i-1];

end

gg:gw;
dd:dw;

编译通过,插入图表时显示数组下标越界。呵呵,高手帮帮忙,看看怎么改

2楼
jinzhe 发表于:2011/7/20 13:43:36


for i=1 to datacount do
begin
 q2h[i]:ref(high,2);
 q2l[i]:ref(low,2);
 dw[1]:=1;gw[1]:=1;
 dw[2]:=1;gw[2]:=1;
 dw[3]:=1;gw[3]:=1;
 dw[4]:=1;gw[4]:=1;
 if ref(high,2)>=ref(high,3) and ref(high,2)>=ref(high,4) and ref(high,2)>=ref(high,1) and ref(high,2)>=high and i>=5 then gw[i]:=q2h[i];
 if ref(high,2)<ref(high,3) and ref(high,2)<ref(high,4) and ref(high,2)<ref(high,1) and ref(high,2)<high and i>=5 then gw[i]:=gw[i-1];
 if ref(low,2)<=ref(low,3) and ref(low,2)<=ref(low,4) and ref(low,2)<=ref(low,1) and ref(low,2)<=low and i>=5 then dw[i]:=q2l[i];
 if ref(low,2)>ref(low,3) and ref(low,2)>ref(low,4) and ref(low,2)>ref(low,1) and ref(low,2)>low and i>=5 then dw[i]:=dw[i-1];

dd:dw;
gg:gw;
end

我把数组的前4赋值,以及把else的意思用if给表示了出来
3楼
26327756l 发表于:2011/7/20 14:24:41


variable:a=0,b=0;
a=ref(high,2);b=ref(low,2);
tj2:=0;
tj3:=0;

for i=1 to datacount do
begin
 q2h[i]:=ref(high,2);
 q2l[i]:=ref(low,2);

 if ref(high,2)>=ref(high,3) and ref(high,2)>=ref(high,4) and ref(high,2)>=ref(high,1) and ref(high,2)>=high and i>=5 then
 begin
  gw[i]:=q2h[i]; a=q2h[i];
  end
 else
  gw[i]:=a;
 if ref(low,2)<=ref(low,3) and ref(low,2)<=ref(low,4) and ref(low,2)<=ref(low,1) and ref(low,2)<=low and i>=5 then
 begin
 dw[i]:=q2l[i];b=q2l[i];
 end
 else
 dw[i]:=b;

end

gg:gw;
dd:dw;

4楼
hjl 发表于:2011/7/20 16:08:42
呵呵,谢谢呀
共4 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.05078 s, 3 queries.