if k-d>0 then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if k-d<0 then begin
sell(1,0,market);
buyshort(holding=0,1,market);