欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 自己做的持仓同步,请问为何没有开平仓动作

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5110人关注过本帖树形打印复制链接

主题:自己做的持仓同步,请问为何没有开平仓动作

帅哥哟,离线,有人找我吗?
fly
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:5082 积分:17642 威望:0 精华:6 注册:2010/7/15 9:05:58
  发帖心情 Post By:2013/4/12 11:00:30    Post IP:58.246.57.26[显示全部帖子]

//用全局变量,实现次周期恢复持仓功能,供参考

 

buycond:=ref(count(c>o,2)=2,1);
sellcond:=ref(count(c<o,2)=2,1);

if holding>0 and sellcond and not(islastbar) then sell(1,1,marketr);
if holding<0 and buycond and not(islastbar) then sellshort(1,1,marketr);

if buycond and holding=0 and not(islastbar) then
 begin
 buy(1,1,marketr);
 end
 
if holding=0 and sellcond and not(islastbar) then buyshort(1,1,marketr);

 
if islastbar and tholding2<>holding then
 begin
  if barpos=EXTGBDATA('kai')+1 then//开仓信号消失,平仓恢复仓
  begin
  sell(tholding2>0,1,marketr);
  sellshort(tholding2<0,1,marketr);
  EXTGBDATASET( 'kai',0);
  end
  
  if barpos=EXTGBDATA('ping')+1 then//平仓信号消失,开仓恢复仓
  begin
  buy(holding>0,1,marketr);
  buyshort(holding<0,1,marketr);
  EXTGBDATASET( 'ping',0);
  end    
 end

if holding>0 and sellcond and islastbar then
begin
sell(1,1,marketr);
EXTGBDATASET( 'ping',BARPOS);
end

if holding<0 and buycond and islastbar then
begin
sellshort(1,1,marketr);
EXTGBDATASET( 'ping',BARPOS);
end


//全局变量BAR,信号消失一根K线上也只开一次仓
if ISLASTBAR AND buycond and barpos>EXTGBDATA('kai') and holding=0 then
 begin
 buy(1,1,marketr);
 EXTGBDATASET( 'kai',BARPOS);
 end

if ISLASTBAR AND sellcond and barpos>EXTGBDATA('kai') and holding=0 then
 begin
 buyshort(1,1,marketr);
 EXTGBDATASET( 'kai',BARPOS);
 end



金字塔—专业程序化交易量化投资平台

客户服务部

-----------------------------------------------------------

欢迎您参加我公司的技术培训,具体培训需求请发邮件到

service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部