请问以下思路应该怎么写:
多空双向开仓时,做多后,有A B C三种平多仓的方式。
连续三次多头平仓后是盈利的(包括隔夜,今日之前的都算),则全局变量N:=1。
aa:=asset;
a1:=ref(asset,todaybar);
variable:k=0;
if 平仓条件a and 持仓判断 then begin
平仓语句;
k:=k+1;
end
if 平仓条件b and 持仓判断 then begin
平仓语句;
k:=k+1;
end
if 平仓条件c and 持仓判断 then begin
平仓语句;
k:=k+1;
end
if k=3 and aa-a1>0 then n:=1;
if date<>ref(date,1) then k:=0;
我描述的不准确,应该是每次多头平仓后都是盈利的,这样连续三次
而不是平仓三次后,总和是盈利的,所以没法用ref(asset,todaybar)来比较
连续三次盈利,是包括隔夜的,不要求都在日内,不用初始化为0吧,if date<>ref(date,1) then k:=0;
variable:k=0;
if 平仓条件a and 持仓判断 then begin
平仓语句;
if numprofit(1)>0 then k:=k+1;
if numprofit(1)<=0 then k:=0;
end
if 平仓条件b and 持仓判断 then begin
平仓语句;
if numprofit(1)>0 then k:=k+1;
if numprofit(1)<=0 then k:=0;
end
if 平仓条件c and 持仓判断 then begin
平仓语句;
if numprofit(1)>0 then k:=k+1;
if numprofit(1)<=0 then k:=0;
end
if k=3 then n:=1;