cond1:Hprofit1>20*MINDIFF and Hprofit1<=40*MINDIFF and holding>0 and Hprofit1-Cprofit1>=5*MINDIFF; cond2:Hprofit1>=40*MINDIFF and Hprofit1<=60*MINDIFF and holding>0 and Hprofit1-Cprofit1>=5*MINDIFF;
if (cond1 and count(cond1=1,ENTERBARS+2)) or (cond2 and count(cond2,ENTERBARS+2)=1) then begin sell(holding>0,50%,market); end
cond3:Hprofit2>20*MINDIFF and Hprofit2<=40*MINDIFF and holding<0 and Hprofit2-Cprofit2>=5*MINDIFF; cond4:Hprofit2>=40*MINDIFF and Hprofit2<=60*MINDIFF and holding<0 and Hprofit2-Cprofit2>=5*MINDIFF;
if (cond1 and count(cond3=1,ENTERBARS+2)) or (cond2 and count(cond4,ENTERBARS+2)=1) then begin sell(holding>0,50%,market); end