如果现在有多单持仓,而且持仓以来最大盈利除以持仓手数大于500,当价格小于持仓以来最高价-20时,就平仓
if holding>0 and hhv(openprofit,enterbars+1)/holding>500 and close<hhv(h,enterbars+1)-20 then sell(1,0,marketr);
if holding<0 and hhv(openprofit,enterbars+1)/abs(holding)>500 and close>llv(l,enterbars+1)+20 then sellshort(1,0,marketr);