[PEL] 复制代码 input:a(30,1,10000,1);
ma1:=ma(close,5);
ma2:=ma(close,30);
variable:maxprofit:=0;//有仓位时最大获利幅度
//开仓
if cross(ma2,ma1) then
begin
buyshort(1,1,limit,c);
maxprofit:=0;
end
//判断当前持仓状态下的最大盈利
win:=0;
if holding < 0 and enterbars > 0 then
begin
win:=(enterprice-c); //记录最大盈利
if win > maxprofit then
maxprofit:=win;
end
最大浮动盈亏:if(holding<>0,maxprofit,0);
浮动盈亏:win;
if (c-avgenterprice)>=a then 止损a:sellshort(1,holding,market);
//分段回撤止盈
if maxprofit>=2*A and win>0 and win<=0.5*A then 止盈1:sellshort(1,holding,market);
if maxprofit>=3*A and win>0 and win<=1*A then 止盈2:sellshort(1,holding,market);
if maxprofit>=4*A and win>0 and win<=2*A then 止盈3:sellshort(1,holding,market);
if maxprofit>=5*A and win>0 and win<=3*A then 止盈4:sellshort(1,holding,market);
|