以文本方式查看主题

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

--  作者:sidadeapu
--  发布时间:2016/7/30 21:57:01
--  [求助]新手求助
     如果品种a和品种b具有相同的开仓条件和平仓条件,但是达到开仓条件的时间有先后,假如品种a先符合开多条件,品种b后符合开多条件,则只品种a开多;假如品种a先符合开多条件,品种b后符合开空条件,则品种a开多,品种b开空;假如品种b先符合开多条件,品种a后符合开多条件,则只品种b开多;假如品种b先符合开多条件,品种a后符合开空条件,则品种b开多,品种a开空;
请教编写思路。

--  作者:jinzhe
--  发布时间:2016/8/1 8:58:24
--  

公式1:

nn1:=barslast(开多a);

nn2:=barslast(开空a);

 

mm1:=barslast(开多b);

mm2:=barslast(开空b);

 

公式2:

nn1:stkindi(\'\',\'公式1.nn1\',0,datatype);

nn2:stkindi(\'\',\'公式1.nn2\',0,datatype);

mm1:stkindi(\'\',\'公式1.mm1\',0,datatype);

mm2:stkindi(\'\',\'公式1.mm2\',0,datatype);

if nn1<nn2 and stricmp(stklabel,\'品种a\') then buy(holding=0,1,market);

if nn1>nn2 and stricmp(stklabel,\'品种b\') then buy(holding=0,1,market);

 

if mm1<mm2 and stricmp(stklabel,\'品种a\') then buyshort(holding=0,1,market);

if mm1>mm2 and stricmp(stklabel,\'品种b\') then buyshort(holding=0,1,market);