金字塔老师您好,我是你们的客户,我编了几天就是搞不成这个想法,麻烦给编一个:
X:=5;
A:=4
开多仓条件:CLOSE>M(c,30)+X;
符合这个开仓条件的后边1、2、3、4根线的次周期开盘价加仓,加仓4根线不再加仓
平多仓条件:CLOSE<最后开多价格-A;
开空仓条件:CLOSE<M(c,30)-X;
符合这个开仓条件的后边1、2、3、4根线的次周期开盘价加仓,加仓4根线不再加仓
平空仓条件:CLOSE<最后开空价格+A;
这种不好写的,类似于确定现在条件再往后推,都有种未来的意思
x:=5;
a:=4;
r1:=c>ma(c,30)+x;
if r1 then buy(holding=0,1,thisclose);
if ref(r1,1) and enterbars=2 then buy(holding=1,1,limitr,o);
if ref(r1,1) and enterbars=1 then buy(holding=2,1,limitr,o);
if ref(r1,1) and enterbars=1 then buy(holding=3,1,limitr,o);
if enterprice-c>a then sell(holding>0,0,limitr,enterprice-a);
自己调试测试一下,随手写的供参考。
x:=5;a:=4;
cx:=4;//最大持仓
r1:=c>ma(c,30)+x;
if r1 then buy(holding=0,1,thisclose);
if ref(r1,1) and enterbars=2 then buy(holding=1,1,limitr,o);
if ref(r1,1) and enterbars=1 then buy(holding<cx,1,limitr,o);
if enterprice-c>a then sell(holding>0,0,limitr,enterprice-a);
同样的方法写加空仓位。
//只写了多仓
x:=5;
a:=4;
ma30:ma(c,30);
r1:=c>ma30+x;
if r1 then buy(holding=0,1,market);
if ref(r1,1) and holding=1 then buy(1,1,market);
if ref(r1,2) and holding=2 then buy(1,1,market);
if ref(r1,3) and holding=3 then buy(1,1,market);
if c<enterprice-a then sell(holding>0,0,market);