如何在以下平仓条件中增加止损小于30个点,止盈大于45个点,这个代码该如何添加进去。
VARIABLE:VMIN = 090000;
IF (ABS(O-REF(C,1))>=20*MINDIFF AND TIME>090000 AND TIME<090400) THEN VMIN := 091500;
//开多仓条件:
BOPEON1:=C>UPPER AND DIFF>0 AND C>O AND C>MA4 AND HOLDING=0 AND TIME>VMIN AND TIME<162500;
//平多仓条件:
BLIQCON:=HOLDING>0 AND CROSS(MA3,MA2);
//开空仓条件:
SOPCON1:=C<LOWER AND DIFF<0 AND C<O AND C<MA4 AND HOLDING=0 AND TIME>VMIN AND TIME<162500;
//平空仓条件:
SLIQCON:=HOLDING<0 AND CROSS(MA2,MA3);
BUY(BOPEON1,手数,thisclose);
SELL(BLIQCON,HOLDING,thisclose);
BUYSHORT(SOPCON1,手数,thisclose);
SELLSHORT(SLIQCON,HOLDING,thisclose);
if holding>0 and c>enterprice+45 then sell(1,0,marketr);
if holding>0 and c<enterprice-30 then sell(1,0,marketr);
if holding<0 and c<enterprice-45 then sellshort(1,0,marketr);
if holding<0 and c>enterprice+30 then sellshort(1,0,marketr);
BLIQCON:=HOLDING>0 AND CROSS(MA3,MA2) or h>enterprice+45 or c<enterprice-30 ;SLIQCON:=HOLDING<0 AND CROSS(MA2,MA3) or l<enterprice-45 or h>enterprice+30;
老师为什么我这么写不行。
把后面3个条件要括号括起来,不然会先算前面的and
难怪我一直测试都测试不出来,是这个原因。代码中都是先计算and 再计算 or是吗。