以文本方式查看主题
- 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp)
-- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4)
---- 数组下标越界问题 (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=7271)
|
-- 作者: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;
编译通过,插入图表时显示数组下标越界。呵呵,高手帮帮忙,看看怎么改
|
-- 作者: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给表示了出来
|
-- 作者: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;
|
-- 作者:hjl
-- 发布时间:2011/7/20 16:08:42
--
呵呵,谢谢呀
|