BUY(开多, 1, thisclose);
SELL(平多, 1, thisclose);
BUYSHORT(开空, 1, thisclose);
SELLSHORT(平空, 1, thisclose);
有以上的程序,需要增加下面的思路
平多或者平空以后,判断盈利超过50点,那么后面的3个开多或开空条件成立,也不开仓。
请问这样如何写程序?
variable:bj=0;
variable:yl=0;
if 开多 and holding=0 and bj=0 then begin
BUY(开多, 1, thisclose);
bj:=1;
end
if 开多 and holding=0 and bj=0 then begin
BUYSHORT(开空, 1, thisclose);
bj:=1;
end
if yl=0 and holding<0 and 平空 then begin
SELLSHORT(平空, 1, thisclose);
if numprofit(1)>50 then yl:=1;
end
if yl=0 and holding>0 and 平多 then begin
SELL(平多, 1, thisclose);
if numprofit(1)>50 then yl:=1;
end
if bj=1 and holding=0 and 开多 and ref(count(开多,exitbars+1),1)=3 then begin
buy(开多,1,thisclose);
yl:=0;
end
if bj=1 and holding=0 and 开空 and ref(count(开空,exitbars+1),1)=3 then begin
buyshort(开空,1,thisclose);
yl:=0;
end