//限价止损
{IF h>=ENTERPRICE+D*mindiff and HOLDING<0 THEN BEGIN//D---D个价位止损
SELLshort(HOLDING<0,HOLDING,stopr,ENTERPRICE+D*mindiff);//止空
END;
IF l<=ENTERPRICE-D*mindiff and HOLDING>0 THEN BEGIN//D---D个价位止损
SELL(HOLDING>0,HOLDING,stopr,ENTERPRICE-D*mindiff);//止多
END;}
//追踪止损
{
stps:ref(if(holding<0,if(enterprice-llv(l,openbar)>=mindiff*step,enterprice+d*mindiff-CEILING((enterprice-llv(l,openbar))/mindiff/step)*step*mindiff,enterprice+d*mindiff),drawnull),1);
stpl:ref(if(holding>0,if(hhv(h,openbar)-enterprice>=mindiff*step,floor(((hhv(h,openbar)-enterprice)/mindiff/step))*step*mindiff+enterprice-d*mindiff,enterprice-d*mindiff),drawnull),1);
IF h>=stps and HOLDING<0 THEN BEGIN//D---D个价位止损;step---步长;stps----空单止损位;
SELLshort(HOLDING<0,HOLDING,stopr,stps);//止空
END;
IF l<=stpl THEN BEGIN//D---D个价位止损;step---步长;stpl----多单止损位;
SELL(HOLDING>0,HOLDING,stopr,stpl);//止多
END;
}
//限价止损+追踪止盈
{
stps:ref(if(holding<0,if(llv(l,openbar)>=enterprice-dd*mindiff-step*mindiff,enterprice+d*mindiff,llv(l,openbar)+step*mindiff),drawnull),1);
stpl:ref(if(holding>0,if(hhv(h,openbar)<=enterprice+dd*mindiff+step*mindiff,enterprice-d*mindiff,hhv(h,openbar)-step*mindiff),drawnull),1);
IF h>=stps and HOLDING<0 THEN BEGIN//D---D个价位止损;step---步长;stps----空单止损位;dd---dd个价位止盈;
SELLshort(HOLDING<0,HOLDING,stopr,stps);//止空
END;
IF l<=stpl THEN BEGIN//D---D个价位止损;step---步长;stpl----多单止损位;dd---dd个价位止盈;
SELL(HOLDING>0,HOLDING,stopr,stpl);//止多
END;
}