以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  交易策略发布专区  (http://www.weistock.com/bbs/list.asp?boardid=10)
----  分享一个判断主力合约的代码  (http://www.weistock.com/bbs/dispbbs.asp?boardid=10&id=50160)

--  作者:klc
--  发布时间:2013/3/24 19:26:27
--  分享一个判断主力合约的代码

参考了之前jinzhe的代码,写了一个判断主力合约的代码:

//判断主力合约,作为走势判断依据
v0:=callstock(\'if00\',vtopenint,6,-1);
v1:=callstock(\'if01\',vtopenint,6,-1);
v2:=callstock(\'if02\',vtopenint,6,-1);
v3:=callstock(\'if03\',vtopenint,6,-1);
v4:=callstock(\'if04\',vtopenint,6,-1);
v5:=callstock(\'if05\',vtopenint,6,-1);
v6:=callstock(\'if06\',vtopenint,6,-1);
v7:=callstock(\'if07\',vtopenint,6,-1);
v8:=callstock(\'if08\',vtopenint,6,-1);
v9:=callstock(\'if09\',vtopenint,6,-1);
v10:=callstock(\'if10\',vtopenint,6,-1);
v11:=callstock(\'if11\',vtopenint,6,-1);
v12:=callstock(\'if12\',vtopenint,6,-1);
nn:=if(v1>v12*0.85 and v1>v0*0.85 and v1>v2,\'IF01\',if(v2>v1*0.85 and v2>v0*0.85 and v2>v3,\'IF02\',if(v3>v2*0.85 and v3>v0*0.85 and v3>v4,\'IF03\',if(v4>v3*0.85 and v4>v0*0.85 and v4>v5,\'IF04\',if(v5>v4*0.85 and v5>v0*0.85 and v5>v6,\'IF05\',if(v6>v5*0.85 and v6>v0*0.85 and v6>v7,\'IF06\',if(v7>v6*0.85 and v7>v0*0.85 and v7>v8,\'IF07\',if(v8>v7*0.85 and v8>v0*0.85 and v8>v9,\'IF08\',if(v9>v8*0.85 and v9>v0*0.85 and v9>v10,\'IF09\',if(v10>v9*0.85 and v10>v0*0.85 and v10>v11,\'IF10\',if(v11>v10*0.85 and v11>v0*0.85 and v11>v12,\'IF11\',if(v12>v11*0.85 and v12>v0*0.85 and v12>v1,\'IF12\',\'IF00\'))))))))))));

原理就是用昨日收盘持仓量来判断,持仓量最大的或下一月份持仓量即将超过本月持仓量时,就选取为主力合约。

nn就是主力合约的代码。可以用来在公式里面用callstock等函数来分析,一般用持仓量最大的主力合约来作交易信号分析比较有效,因为主力和约持仓量交易量都大,一般不容易出现小概率的极端行情。


--  作者:回声探路
--  发布时间:2015/12/23 6:46:50
--  
luguo
--  作者:幸运60
--  发布时间:2018/12/9 20:31:47
--  
怎么使用呀?怎么加到策略里去?