请问,我在程序中以“i:=0;i=i+1;"表示期货的交易笔数,为什么金之塔程序输出中的i值是300,而实际交易笔数是12000笔?怎样设置?
variable:a=0;
...............
variable:i=0;
.............
variable:b=0;
i:=i+1; //dynainfo(52);
price:=close;
..........
..........
if islastbar then
begin
aggdownretmean:=trimmean(aggdownretvec,downperiod,0);
aggdownretsd:=sqrt(var(aggdownretvec,downperiod)); //无偏方差
aggupretmean:=trimmean(aggupretvec,upperiod,0);
aggupretsd:=sqrt(var(aggupretvec,upperiod)); //无偏方差
i值:i,colorgray,linethick0;
end
由于保密原因,程序不便在此公开,但用到i的累加计算的地方只有这里,关键是程序中如何表达并使用交易笔数。
你上述的代码对问题分析没有任何意义,请表达下你关于i变量处理的思路。
以下是我的程序,程序在“分笔成交”环境下运行,i应该是交易笔数,但交易笔数小于300时运行正确,交易笔数超过300时不正确,主要是i停留在300不变,不知哪里出了问题。
variable:upperiod = 0;
variable:downperiod = 0;
variable:increasenum = 0;
variable:decreasenum = 0;
variable:aggincidx = 0;
variable:aggdecidx = 0;
variable:aggincidx1 = 0;
variable:aggdecidx1 = 0;
variable:uptrend=false;
variable:downtrend =false;
variable:price[]=0;
variable:indexvec[]=0;
variable:aggupretvec[]=0;
variable:aggdownretvec[]=0;
variable:aggupretmean = 0;
variable:aggupretvar = 0;
variable:aggdownretmean = 0;
variable:aggdownretvar = 0;
variable:i=0;
variable:a=0;
variable:b=0;
i:=i+1; //dynainfo(52);
price:=close;
if i>=2 then
begin
indexvec:=price[i])/price[i-1];
curidx:=indexvec;
if uptrend=true then
begin
aggincidx1:=price[i]/price[a];
aggincidx:=max(aggincidx1,price[b]/price[a]);
increasenum:=0;
end
if downtrend=true then
begin
aggdecidx1:=price[i]/price[b];
aggdecidx:=min(aggdecidx1,price[a]/price[b]);
decreasenum:=0;
end
if curidx>0 and uptrend=false then
begin
increasenum:=increasenum + 1;
if increasenum=1 then
a:=i-1;
if increasenum=2 then
begin
for j=a to i-1 do
begin
if (price[j+1]<price[j])and (price[i]<=price[a+1]) then
begin
t1:=false;
increasenum:=1;
a:=i-1;
break;
end
else
t1:=true;
end
end
if t1=true then
begin
if downtrend=true then
aggdownretvec:=aggdecidx*100000000;
uptrend:=true;
aggincidx1:=price[i]/price[a];
upperiod:=upperiod + 1;
increasenum:=0;
decreasenum:=0;
downtrend:=false;
s1:=false;
end
end
if curidx<0 and downtrend=false then
begin
decreasenum:=decreasenum+1;
if decreasenum=1 then
b:=i-1;
if decreasenum=2 then
begin
for j=b to i-1 do
begin
if (price[j+1]>price[j])and (price[i]>=price[b+1]) or(increasenum>=2) then
begin
s1:=false;
decreasenum:=1;
b:=i;
break;
end
else
s1:=true;
end
end
if s1=true then//判断下跌
begin
if uptrend=true then
aggupretvec:=aggincidx*100000000;
downtrend:= true;
aggdecidx1:=price[i]/price[b];
downperiod:=downperiod+1; // 下跌周期数
uptrend:=false;
t1:=false;
increasenum:=0;
decreasenum:=0;
end
end
end
if islastbar and uptrend=true then
aggupretvec:=aggincidx*100000000;
if islastbar and downtrend=true then
aggdownretvec:=aggdecidx*100000000;
//计算相应的均值和方差
if islastbar then
begin
aggdownretmean:=trimmean(aggdownretvec,downperiod,0);
aggdownretsd:=sqrt(var(aggdownretvec,downperiod)); //无偏方差
aggupretmean:=trimmean(aggupretvec,upperiod,0);
aggupretsd:=sqrt(var(aggupretvec,upperiod)); //无偏方差
i值:i,colorgray,linethick0;
下跌均值:aggdownretmean,colorwhite,linethick0;
下跌标准差:aggdownretsd,colorwhite,linethick0;
上涨均值:aggupretmean,colorwhite,linethick0;
上涨标准差:aggupretsd,colorwhite,linethick0;
上涨期数:upperiod,colorwhite,linethick0;
下跌期数:downperiod,colorwhite,linethick0;
end