请问:
从第一次开多仓后,接下来限制成最多还能再做三次多,也就是说,在做了四次多并平多后,接下来即使再有开多信号也不再做多了,而是一直等待开空信号开始做空。做空也一样,最多只能做四次,一但做够四次,即使再有开空信号也不再开空,而是一直等待开多信号开始做多……
开平算一次还是开仓算一次?
开仓算一次
variable:n=0,m=0;
ss:=1;
if n<4 and holding>=0 and 开多条件 then begin
buy(1,ss,market);
n:=n+1;
end
if m<4 and holding<=0 and 开空条件 then begin
buyshort(1,ss,market);
m:=m+1;
end
if m=4 then n:=0;
if n=4 then m:=0;
亲爱的jinzhe老师,在你这个基础上,我自己改成了开平算一次,结果程序出现了很邪门的情况(程序不做空了,条件达成也不做空,晕),所以,还是烦请你再给我写一个开平算一次的程序。
而且我希望能改进一下,假如是在做多,那么不管目前做多是做了二次三次还是四次,只要有做空,那么做多的N就自动清零。
谢谢了。
假设做多了三次,然后做了一次空,那么就从这次做空之后的第一次做多开始重新限定只能连续做四次多。
如果不是这样限定,那么就存在这样一种情况:做多三次后,做了一次空,但趋势再次向上,可是,多却只能再做一次就不能再做了。
variable:n=0,m=0;
ss:=1;
if n<4 and holding>=0 and 开多条件 then begin
buy(1,ss,market);
n:=n+1;
m:=0;
end
if m<4 and holding<=0 and 开空条件 then begin
buyshort(1,ss,market);
m:=m+1;
n:=0;
end
if m=4 then n:=0;
if n=4 then m:=0;
variable:n=0,m=0;
ss:=1;
if n<4 and holding>=0 and 开多条件 then begin
buy(1,ss,market);
n:=n+1;
m:=0;
end
if m<4 and holding<=0 and 开空条件 then begin
buyshort(1,ss,market);
m:=m+1;
n:=0;
end
if m=4 then n:=0;
if n=4 then m:=0;
这样的话,这两句是不是就没必要有了?