当满足A A1 A2 时多头信号出现
当满足B B1 B2时空头信号出现;
要编写一个,当出现A信号时开多10%仓位,后面出现同方向满足A信号时不管他,出现A1 多头信号时加仓10%,出现A2多头时再加仓10%
当出现空头信号时(无论B B1 B2) 平多开空,加仓操作同上。
请教老师这个代码要怎么写
谢谢指点!
variable:n=0,m=0;
if a and n=0 then begin
buy(holding=0 ,10%,market);
n:=1;
end
if a1 and n=1 then begin
buy(1,10%,market);
n:=2;
end
if a2 and n=2 then begin
buy(1,10%,market);
n:=3;
end
if b or b1 or b2 then begin
sell(1,0,market);
buyshort(holding=0,1,10%);
n:=0;
end
if b and m=0 then begin
buyshort(holding=0 ,10%,market);
m:=1;
end
if b1 and m=1 then begin
buyshort(1,10%,market);
m:=2;
end
if b2 and m=2 then begin
buyshort(1,10%,market);
m:=3;
end
把带ref的条件写在if外面
你把ref写进了if后面的then里面了,比如 if then b:=ref(a,1);
这个要写在外面 aa:=ref(a,1) if then b:=aa;
类似这样改