if ref(l=llv(l,5) and barslast(h=hhv(h,20))<=7,1) then buy(holding=0,1,marketr);
if openprofit<-1000 then sell(1,0,marketr);
if enterbars=n then sell(1,0,marketr);
if enterbars>0 and h=hhv(h,20) then sell(1,0,marketr);
if enterbars>0 and l=llv(l,40) then sell(1,0,marketr)