我的系统是一手一手开,一手一手平的。现在持多单,手数为a:holding,我需要引用开第a-1手时的价格。我该怎么办?
这个问题的难点是把现在的holding定义成一个固定常数往回赋值。
请看如下,假如我开了6手多单,然后平了3手,手上还有3手,我要引用当初开第3手的价格。
variable:izhisun=0;
variable:kdcs=0;//kd次数
variable:kkcs=0;//kk次数
variable:dfjb=0;
starttime:=093500;
endtime:=143000;
ss:=1;
zs:=6;
资产:asset-1000000,noaxis,colorred,linethick2;
胜率:percentwin,linethick0;
交易次数:totaltrade,linethick0;
持仓:holding,linethick0;
dfj:=date>ref(date,1);
dfjb:=barslast(dfj)+1;
if dfj {or time>151000} then begin
izhisun:=0.001*o*zs;
kdcs:=0;
kkcs:=0;
end
refc:=ref(c,1);
refo:=ref(o,1);
if time>=starttime and time<=143000 then begin
if mod(minute,5)=0 and refc>refo then begin
if holding>=0 and kdcs<15 and totaldaytrade<10 then begin
buy(1,ss,limitr,c);
kdcs:=kdcs+1;
holdh:=h;
end
end
end
//时间平仓
if time>=150800 then
begin
if holding>0 then sell(1,holding,limitr,o);
if holding<0 then sellshort(1,holding,limitr,o);
end
if holding>0 and enterprice-l>=izhisun then begin
sell(1,1,limitr,enterprice-izhisun);//止损
end
valuewhen(holding=3 and ref(holding=2,1),enterprice);
这个写在开仓语句后面
手上有三手是打个比方。比如手上有i手时呢,怎么办?i取值holding后再往回赋值?
一样,获取第I手的下单价格就是valuewhen(holding=i and ref(holding=i-1,1),enterprice)
你试过没?加入
i:=holding;
aa:valuewhen(holding=i and ref(holding=i-1,1),enterprice),noaxis;
aa永远都是0.
我说的假如目前是3手。i:=目前的手数.请看标题,如果是固定手数,那就简单了,不是难题了啊
问题的关键是怎么把现在的手数赋值成一个向回赋值的常数吧。