if m1>ref(m1,1) then begin if c=m1 and holding=0 then buy(1,1,market); if c-m1>=x and holding>0 then sell(1,1,market); end if m1<ref(m1,1) then begin if c=m1 and holding=0 then buyshort(1,1,market); if m1-c>=x and holding<0 then sellshort(1,1,market); end