以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  如何合并多个模型的开仓信号?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=63548)

--  作者:yanxc
--  发布时间:2014/4/5 21:48:27
--  如何合并多个模型的开仓信号?
多个模型,各自有若干对开平策略,写法也各不相同,没法整合为一个模型。 有没办法通过引用各模型的持仓状态,来达到以下目的: 当每个模型都holding<0的时候,开仓做空; 其中一个模型反多或平仓的时候,平空。
--  作者:Ivan
--  发布时间:2014/4/8 0:39:56
--  

可以的,通过stkindi函数,引用N个模型的持仓,然后汇总起来处理即可:

if c1+c2+...=N and holding=0 then buyshort(1,1,market);

if c1+c2+...>N and holding<0 then sellshort(1,1,market);

 


--  作者:yanxc
--  发布时间:2014/4/8 16:51:56
--  
以下是引用Ivan在2014/4/8 0:39:56的发言:

可以的,通过stkindi函数,引用N个模型的持仓,然后汇总起来处理即可:

if c1+c2+...=N and holding=0 then buyshort(1,1,market);

if c1+c2+...>N and holding<0 then sellshort(1,1,market);

 


问题就是如何引用持仓?

如下写法正确吗?

C1:=stkindi(\'\',\'holding,模型1\',0,1);

 

貌似不对。


--  作者:jinzhe
--  发布时间:2014/4/8 17:17:23
--  

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=63632

 

[此贴子已经被作者于2014/4/8 17:17:29编辑过]

--  作者:qwer123
--  发布时间:2014/4/8 21:22:04
--  
rr1:=stkindiex(\'if00\',\'qq20.持仓\',0,21,2,0);
rr2:=stkindi(\'if00\',\'qq7.持仓\',0,1);
//rr3:=stkindi(\'if00\',\'qq12.持仓\',0,22,110);
//rr4:=stkindi(\'if00\',\'qq12.持仓\',0,22,125);
//rr5:=stkindi(\'if00\',\'qq12.持仓\',0,22,130);
//rr6:=stkindi(\'if00\',\'qq12.持仓\',0,22,95);
//rr7:=stkindi(\'if00\',\'qq12.持仓\',0,22,90);

//r11:=stkindi(\'if00\',\'qq31.持仓\',0,11);

r12:=rr1+rr2;

//********************************
hd:=if(islastbar,3,2.0);
hd1:=if(islastbar,3,0.1);

//********************************
if holding=0 and r12>0 then buy(1,r12,limitr,c+hd1);
if holding=0 and r12<0 then buyshort(1,abs(r12),limitr,c-hd1);

if holding>0 and r12>0 and holding>r12 then sell(1,holding-r12,limitr,c-hd1);
if holding>0 and r12>0 and holding<r12 then buy(1,r12-holding,limitr,c+hd1);
if holding>0 and r12<0 then
begin
sell(1,holding,limitr,c-hd1);
buyshort(1,abs(r12),limitr,c-hd1);
end

if holding<0 and r12<0 and holding>r12 then buyshort(1,holding-r12,limitr,c-hd1);
if holding<0 and r12<0 and holding<r12 then sellshort(1,r12-holding,limitr,c+hd1);
if holding<0 and r12>0 then
begin
sellshort(1,holding,limitr,c+hd1);
buy(1,r12,limitr,c+hd1);
end 
[此贴子已经被作者于2014/4/8 21:22:51编辑过]