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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 改写一下,实现立即下单

   

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


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

主题:改写一下,实现立即下单

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


加好友 发短信
等级:论坛游民 帖子:271 积分:730 威望:0 精华:0 注册:2011/6/22 15:58:05
改写一下,实现立即下单  发帖心情 Post By:2013/2/25 16:28:18    Post IP:219.136.141.231[只看该作者]

ss:=1; //手数
maa:ema(c,10);
tt1:=H>maa;
tt2:=L<maa;
//当开始没有持仓
if holding=0 then begin
if tt1 then begin
buy(1,ss,market)
end

if tt2 then begin
buyshort(1,ss,market);
end
end

//持仓状态

if tt1 and holding<0 and enterbars>=0 then begin
sellshort(1,ss,market);
buy(1,ss,market);
end

if tt2 and holding>0 and enterbars>=0 then begin
sell(1,ss,market);
buyshort(1,ss,market);
end

 

aa-TT:if(TT1,1,if(TT2,-1,0)),NODRAW;
bb-holding:holding,NODRAW;
cc-Enterbars:enterbars,nodraw;

 

上面的代码,我想实现下面要求

一根K线只出现一次同方向的平开(上面的代码实盘运行过,是会两边一起开仓的),这个和金字塔限制说明的有所不同

 

请问怎么实现

 



 回到顶部
帅哥哟,离线,有人找我吗?
jinzhe
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2013/2/25 16:31:14    Post IP:58.246.57.26[只看该作者]

全局变量限制下单



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

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

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

 回到顶部
帅哥哟,离线,有人找我吗?
eric917
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:271 积分:730 威望:0 精华:0 注册:2011/6/22 15:58:05
  发帖心情 Post By:2013/2/25 22:20:41    Post IP:221.5.67.193[只看该作者]

请问这样可以不?

ss:=1; //手数
extgbdataset('t1_position',0);
//0表示没有仓位,1表示持有多头, -1表示持有空头
extgbdataset('t1_holding',0);
//0表示没有仓位,>0表示持有多头, <0表示持有空头
extgbdataset('t1_enterbarpos',0);//记录其开仓的K线

maa:ema(c,10);
bpk:=cross(c,maa);
spk:=cross(maa ,c);

if not(islastbar) or workmode<>1 then exit;

//如果当前棒是最后一根k线,执行
if islastbar and  time<151000 then begin

 // 如果最后一根k线发生过出场信号,则那一根k线不再交易
 if extgbdata('t1_enterbarpos') = barpos then begin
  goto continueline ;
 end
 
//没有持仓状态
if extgbdata('t1_position')=0  and extgbdata('t1_holding')=0 then begin
     if  bpk then begin
  
        tbuy(1,ss,mkt);
        extgbdataset('t1_position',1);
        extgbdataset('t1_holding',ss);
        extgbdataset('t1_enterbarpos',barpos);
     
      end

      if spk then begin
      
         tbuyshort(1,ss,mkt);
         extgbdataset('t1_position',-1);
         extgbdataset('t1_holding',-ss);
         extgbdataset('t1_enterbarpos',barpos);
        
      end
    goto continueline ;
end//没有持仓状态
    
//持有仓位状态
   //持空头
if bpk and extgbdata('t1_position')=-1   and  extgbdata('t1_holding')<0 then begin

       tsellshort(1,ss,mkt);
       tbuy(1,ss,mkt);
       extgbdataset('t1_position',1);
       extgbdataset('t1_holding',ss);
       extgbdataset('t1_enterbarpos',barpos);
       goto continueline ;
end
    //持多头
if spk and extgbdata('t1_position')=1    and  extgbdata('t1_holding')>0  then begin

        tsell(1,ss,mkt);
        tbuyshort(1,ss,mkt);
        extgbdataset('t1_position',-1);
        extgbdataset('t1_holding',-ss);
        extgbdataset('t1_enterbarpos',barpos);
        goto continueline ;
end

end//if  如果是最后K线 ISLASTBAR

 

if  time>=151300 then begin

             tsell(extgbdata('t1_holding')>0,ss,mkt);
             tsellshort(extgbdata('t1_holding')>0,ss,mkt);
             extgbdataset('t1_position',0);
             extgbdataset('t1_holding',0);
                     
end


continueline@ 资产:tasset,linethick0;
position:=extgbdata('t1_position');
t1holding:=extgbdata('t1_holding');
debugfile('d:\debug\803555.txt','position=%.0f' ,position) ;
debugfile('d:\debug\803555.txt','t1holding=%.0f' ,t1holding) ;

 

 

[此贴子已经被作者于2013-2-25 22:21:59编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
eric917
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:271 积分:730 威望:0 精华:0 注册:2011/6/22 15:58:05
  发帖心情 Post By:2013/2/25 22:50:18    Post IP:221.5.67.193[只看该作者]

上面有些不合理的地方,修改了一下:

 

ss:=1; //手数
extgbdataset('t1_position',0);
//0表示没有仓位,1表示持有多头, -1表示持有空头
extgbdataset('t1_holding',0);
//0表示没有仓位,>0表示持有多头, <0表示持有空头
extgbdataset('t1_enterbarpos',0);//记录其开仓的K线

maa:ema(c,10);
bpk:=cross(c,maa);
spk:=cross(maa ,c);
//非最后一根K线退出
if not(islastbar) or workmode<>1 then exit;

//如果当是最后一根k线,执行
IF islastbar and  time<151000 then begin

 // 如果最后一根k线发生过开仓信号,则那一根k线不再交易
 if extgbdata('t1_enterbarpos') = barpos then begin
  goto continueline ;
 end
 
//没有持仓状态
if extgbdata('t1_position')=0  and extgbdata('t1_holding')=0 then begin
     if  bpk then begin
       
        tbuy(1,ss,mkt);
        extgbdataset('t1_position',1);
        extgbdataset('t1_holding',ss);
        extgbdataset('t1_enterbarpos',barpos);
        goto continueline ;
       
      end

      if spk then begin
      
         tbuyshort(1,ss,mkt);
         extgbdataset('t1_position',-1);
         extgbdataset('t1_holding',-ss);
         extgbdataset('t1_enterbarpos',barpos);
         goto continueline ;
        
      end
end//没有持仓状态
    
//持有仓位状态
   //持有空头
if bpk and extgbdata('t1_position')=-1   and  extgbdata('t1_holding')<0 then begin

       tsellshort(1,ss,mkt);
       tbuy(1,ss,mkt);
       extgbdataset('t1_position',1);
       extgbdataset('t1_holding',ss);
       extgbdataset('t1_enterbarpos',barpos);
       goto continueline ;
      
end
    //持有多头
if spk and extgbdata('t1_position')=1    and  extgbdata('t1_holding')>0  then begin

        tsell(1,ss,mkt);
        tbuyshort(1,ss,mkt);
        extgbdataset('t1_position',-1);
        extgbdataset('t1_holding',-ss);
        extgbdataset('t1_enterbarpos',barpos);
        goto continueline ;
       
end
END//if  ISLASTBAR

if  time>=151300 then begin

             tsell(extgbdata('t1_holding')>0,ss,mkt);
             tsellshort(extgbdata('t1_holding')<0,ss,mkt);
             extgbdataset('t1_position',0);
             extgbdataset('t1_holding',0);
                     
end

continueline@ 资产:tasset,linethick0;
position:=extgbdata('t1_position');
t1holding:=extgbdata('t1_holding');
debugfile('d:\debug\803555.txt','position=%.0f' ,position) ;
debugfile('d:\debug\803555.txt','t1holding=%.0f' ,t1holding) ;

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
admin
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:7302 积分:32559 威望:1000 精华:45 注册:2003/12/30 16:34:32
  发帖心情 Post By:2013/2/25 23:31:48    Post IP:122.225.36.52[只看该作者]

后台的代码直接贴给我们的客服我们是很难从中看到逻辑问题的,因为你的交易思路我们无法准确的了解。

建议你多看看 http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=332 问题4中的后台调试部分,加入代码的变量跟踪部分,也就是DEBUGFILE函数输出你代码中的变量值,然后多进行跟踪调试,这样才能发现其中的不合理部分


 回到顶部
帅哥哟,离线,有人找我吗?
eric917
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:271 积分:730 威望:0 精华:0 注册:2011/6/22 15:58:05
  发帖心情 Post By:2013/2/26 9:35:06    Post IP:219.136.141.231[只看该作者]

好的,我试试,谢谢


 回到顶部