Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共7 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:新年献礼:股指换月自动移仓策略

1楼
guotx2010 发表于:2012/1/28 22:26:59

//说明:此策略为后台自动移仓策略

//使用说明:后台加载此策略,时间可设置为每10分钟检测一次,当持有的仓位不是主力合约时自动换到主力合约。


variable:AccountID='800000';  //指定交易账户

M1:=MONTH();
HY1:='IF' + If(M1>9,M1,'0'+numtostr(M1,0));  //当前月合约
HY2:='IF' + If(M1+1>9,M1+1,'0'+numtostr(M1+1,0));//下月合约
HY0:='IF00';

VHY0:CALLSTOCK(HY0,VTVOL,6,0),linethick0;
VHY1:CALLSTOCK(HY1,VTVOL,6,0),linethick0;
VHY2:CALLSTOCK(HY2,VTVOL,6,0),linethick0;

if VHY1=VHY0 then CurMonth:=Month();
if VHY2=VHY0 then CurMonth:=Month()+1; 
主力:CurMonth,linethick0;
if CurMonth>M1 then begin
 PreBuyHold:tbuyholdingex(AccountID,HY1,1),linethick0; //上月买入持仓
 PreSellHold:tsellholdingex(AccountID,HY1,1),linethick0; //上月卖出持仓
 if PreBuyHold>0 then begin  //多单移仓
  tSell(1,PreBuyHold,mkt,0,0,AccountID,HY1);
  tbuy(1,PreBuyHold,mkt,0,0,AccountID,HY2); 
 end
 if PreSellHold>0 then begin  //空单移仓
  tSellShort(1,PreSellHold,mkt,0,0,AccountID,HY1);
  tbuyShort(1,PreSellHold,mkt,0,0,AccountID,HY2); 
 end
end

 

//这个策略专门针对股指来实现的,如果需要用于商品,应做些修改

//本人使用VBA开发了针对任何品种的自动移仓功能,需要的朋友可与我联系。

 

 

2楼
阿火 发表于:2012/1/29 21:30:24
图片点击可在新窗口打开查看
3楼
solarhe2006 发表于:2012/1/30 0:18:29

http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=9750

//说明:此策略为后台自动移仓策略

//使用说明:后台加载此策略,时间可设置为每10分钟检测一次,当持有的仓位不是主力合约时自动换到主力合约。


variable:AccountID='800000';  //指定交易账户

M1:=MONTH();
HY1:='IF' + If(M1>9,M1,'0'+numtostr(M1,0));  //当前月合约
HY2:='IF' + If(M1+1>9,M1+1,'0'+numtostr(M1+1,0));//下月合约
HY0:='IF00';

VHY0:CALLSTOCK(HY0,VTVOL,6,0),linethick0;
VHY1:CALLSTOCK(HY1,VTVOL,6,0),linethick0;
VHY2:CALLSTOCK(HY2,VTVOL,6,0),linethick0;

if VHY1=VHY0 then CurMonth:=Month();
if VHY2=VHY0 then CurMonth:=Month()+1; 
主力:CurMonth,linethick0;
if CurMonth>M1 then begin
 PreBuyHold:tbuyholdingex(AccountID,HY1,1),linethick0; //上月买入持仓
 PreSellHold:tsellholdingex(AccountID,HY1,1),linethick0; //上月卖出持仓
 if PreBuyHold>0 then begin  //多单移仓
  tSell(1,PreBuyHold,mkt,0,0,AccountID,HY1);
  tbuy(1,PreBuyHold,mkt,0,0,AccountID,HY2); 
 end
 if PreSellHold>0 then begin  //空单移仓
  tSellShort(1,PreSellHold,mkt,0,0,AccountID,HY1);
  tbuyShort(1,PreSellHold,mkt,0,0,AccountID,HY2); 
 end
end

4楼
zsjwhy 发表于:2012/11/10 22:39:01
图片点击可在新窗口打开查看
5楼
wangshijun78 发表于:2012/12/6 22:18:21
 存在点小问题
HY1:='IF' + If(M1>9,M1,'0'+numtostr(M1,0));  //当前月合约
HY2:='IF' + If(M1+1>9,M1+1,'0'+numtostr(M1+1,0));//下月合约

这里到12月初的时候HY2是不对的,按这个算法,HY2变成了IF13,应该是IF01,需要完善下。
或者再加一句:if m1=12 then HY2:='IF01';
6楼
cathero2001 发表于:2014/4/19 14:33:58
楼主,遇到一个问题:

VHY1:CALLSTOCK(HY1,VTVOL,6,0), NOAXIS, COLORRED;
VHY2:CALLSTOCK(HY2,VTVOL,6,0), NOAXIS, COLORGREEN;



我用的是图表交易程序,为什么在程序里加了以上两句话,图上却没有线出来?

谢谢~
7楼
haizxj 发表于:2015/8/31 9:44:51
增加大的滑点
共7 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.03125 s, 2 queries.