VARIABLE:n1=0,n2=0,n3=0,n4=0;
if d2 then n:=1;
if n=1 and d1 then begin
buy(holding=0,1,market);
n:=0;
end
if d3 then n2:=1;
if n2=1 and d4 then begin
buy(holding=0,1,market);
n2:=0;
end
if pd1 then sell(holding>0,0.5*holding,market);
if pd2 then sell(holding>0,0.5*holding,market);
if pd3 then sell(holding>0,holding,market);
if pd4 then sell(holding>0,holding,market);
if pd5 then sell(holding>0,holding,market);
if pd6 then sell(holding>0,holding,market);
if k2 then n3:=1;
if n3=1 and k1 then begin
buyshort(holding=0,1,market);
n3:=0;
end
if k3 then n4:=1;
if n4=1 and k4 then begin
buyshort(holding=0,1,market);
n4:=0;
end
if pk1 then sellshort(holding<0,0.5*holding,market);
if pk2 then sellshort(holding<0,0.5*holding,market);
if pk3 then sellshort(holding<0,holding,market);
if pk4 then sellshort(holding<0,holding,market);
if pk5 then sellshort(holding<0,holding,market);
if pk6 then sellshort(holding<0,holding,market);