以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  加仓模型  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=49679)

--  作者:zzsg
--  发布时间:2013/3/14 10:24:47
--  加仓模型
金字塔老师您好,我是你们的客户,我编了几天就是搞不成这个想法,麻烦给编一个:
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;

--  作者:jinzhe
--  发布时间:2013/3/14 10:41:46
--  
这种不好写的,类似于确定现在条件再往后推,都有种未来的意思

--  作者:qwe123
--  发布时间:2013/3/14 10:58:45
--  
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);

自己调试测试一下,随手写的供参考。




--  作者:qwe123
--  发布时间:2013/3/14 11:05:31
--  
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);

同样的方法写加空仓位。

--  作者:zzsg
--  发布时间:2013/3/14 12:50:40
--  
这个还是不行呀,图片放不上去,你倒进去看看


--  作者:zzsg
--  发布时间:2013/3/14 12:51:11
--  
如何发图片呢,否则看不清楚
--  作者:zzsg
--  发布时间:2013/3/14 13:33:09
--  
现在条件 再往后推,不可能有未来的意思,那不是所有技术都不能交易了吗
技术本来就是统计前边,这个策略也是呀

--  作者:fly
--  发布时间:2013/3/14 13:55:34
--  

//只写了多仓

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);


--  作者:zzsg
--  发布时间:2013/3/14 14:35:20
--  
谢谢老师,我试试