现在主要是没有开仓信号。
variable:num=0;
if (c-ref(c,1))/ref(c,1)<-0.01 and num=0 then
begin
buy(1,1,c);
num:=1;
end
variable:num=0;
if (c-ref(c,1))/ref(c,1)<-0.055 and num=0 then
begin
buy(1,1,c);
num:=1;
end
variable:num=0;
if (c-ref(c,1))/ref(c,1)>0.034 and num=0 then
begin
sell(1,holding,C);
num:=1;
end
代码里面num是用来干什么的?
控制每天每条只触发一次。
variable:num1=0,num2=0;
if date<>ref(date,1) then begin
num1:=0;
num2:=0;
end
if (c-ref(c,1))/ref(c,1)<-0.01 and num1=0 and holding=0 then
begin
buy(1,1,limitr,c);
num1:=1;
end
if (c-ref(c,1))/ref(c,1)<-0.055 and num2=0 and holding=0 then
begin
buy(1,1,limitr,c);
num2:=1;
end
if (c-ref(c,1))/ref(c,1)>0.034 then
begin
sell(1,holding,limitr,C);
end
调整之后可以触发了,谢谢!
我希望能做到跌1个点,跌3个点,跌5个点加仓,每天触发每档只加一次,所以我把上面的holding=0去掉了,不然可能会影响第二天的加仓,但是今天在同洲电子的运行结果上:
只在8.57限价开了一单,跌1个点和跌3个点并没有限价开出仓位。这个是什么原因呢?
variable:num1=0,num2=0;
if date<>ref(date,1) then begin
num1:=0;
num2:=0;
end
if (c-ref(c,1))/ref(c,1)<=-0.01 and num1=0 then
begin
buy(1,1,limitr,c);
num1:=1;
end
if (c-ref(c,1))/ref(c,1)<=-0.055 and num2=0 then
begin
buy(1,1,limitr,c);
num2:=1;
end
if (c-ref(c,1))/ref(c,1)>0=.034 then
begin
sell(1,holding,limitr,C);
end
if (c-ref(c,1))/ref(c,1)<=-0.01 and num1=0
if (c-ref(c,1))/ref(c,1)<=-0.05 and num1=0
这个是跌1个点和跌5个点的条件语句。
问题是他只开一单,我想要他触发条件-1.-3.-5,就各开一次。
你贴完整代码