再表述清楚一点,
记录每天第一笔建仓的价格,(一天只记这个价格),并标识出这一笔是建多单还是建空单,方便后续引用运算
variable:n=0;
if 开多条件 and holding=0 then begin
buy........;
n:=n+1;
end
if 开空条件 and holding=0 then begin
buyshort......;
n:=n+1;
end
nn:if(n=1 and 开多条件 ,1 ,if(n=1 and 开空条件,2,3));//nn=1表示当日第一个开仓是开多,nn=2表示当日第一个开仓是开空
ee:valuewhen(n=1,enterprice);//第一次开仓时的价格
if time=closetime(0) then n:=0;