N:=250;
买入条件:=CROSS(MA(C,5),MA(C,20));{自定买入条件}
卖出条件:=CROSS(MA(C,20),MA(C,5));{自定卖出条件}
{卖出条件:=(C-REF(C,BARSLAST(买入条件)))/C>0.2 OR (REF(C,BARSLAST(买入条件))-C)/C>0.1;
如抄底指标只有买入条件而无卖出条件,可套用上面的,也可以试试这个}
ENTERLONG:=TFILTER(买入条件,卖出条件,1);
EXITLONG:=TFILTER(买入条件,卖出条件,2);
买入:ENTERLONG,NODRAW,COLOR00FF80;
卖出:EXITLONG,NODRAW,COLORFF8000;
SY:=IF(EXITLONG,(C/REF(C,BARSLAST(ENTERLONG))-1)*100,DRAWNULL);
LJSY:=IF(CURRBARSCOUNT<=N,SUM(SY,0),DRAWNULL);
RQSY:=CONST(REF(LJSY,N-1));
收益:LJSY-RQSY,COLORYELLOW;
NOTEXT1:IF(收益>0,收益,DRAWNULL),COLORYELLOW;
NOTEXT2:IF(收益<=0,收益,DRAWNULL),COLORMAGENTA;
DRAWICON(ENTERLONG,收益*0.94,1);
DRAWICON(EXITLONG,收益*1.03,2);
DRAWNUMBER(EXITLONG,收益*1.2,IF((C/REF(C,BARSLAST(ENTERLONG))-1)*100>0,(C/REF(C,BARSLAST(ENTERLONG))-1)*100,DRAWNULL)),COLORYELLOW;
DRAWNUMBER(EXITLONG,收益*0.98,IF((C/REF(C,BARSLAST(ENTERLONG))-1)*100<=0,(C/REF(C,BARSLAST(ENTERLONG))-1)*100,DRAWNULL)),COLORMAGENTA;
DRAWTEXT_FIX(CURRBARSCOUNT=1,0.01,0.1,0,'自定义买卖条件,看收益曲线图'),COLORRED;