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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → BUY(COND,V,Type,P);的格式问题。

   

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


  共有2975人关注过本帖平板打印复制链接

主题:BUY(COND,V,Type,P);的格式问题。

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


加好友 发短信
等级:新手上路 帖子:3 积分:0 威望:0 精华:0 注册:2012/8/29 16:34:36
改后还是不能正常  发帖心情 Post By:2014/5/12 11:16:39    Post IP:27.115.97.2[只看该作者]

我把循环删了,没有加仓环节了,buy等交易指令后的cond也都改了   还是只有第一次开仓后面没有交易和平仓了   这是怎么回事呢  谢谢老师

//声明参数
input:D20(20,10,60,1);;
input:D10(10,5,30,1);
input:ATRL(13,5,30,1);
input: risk(1,0.5,5,0.1)

//声明变量
VARIABLE:H20:=close;
VARIABLE:L20:=CLOSE;
VARIABLE:H10:=Close;
VARIABLE:L10:=CLOSE;
VARIABLE:myenterprice:=0; //初始开仓价格;
VARIABLE:myexitprice:=0;//初始平仓价格
VARIABLE:units:=0;//交易单位
VARIABLE:position:=0;//初始仓位
VARIABLE:sendorderthisbar:=0;

H20:=ref(HHV(h,20),1);
L20:=ref(LLV(l,20),1);
H10:=ref(HHV(h,10),1);
L10:=ref(LLV(l,10),1);

KD:=c>H20;          //开多条件
PD:=c<L10;          //平多条件
KK:=c<L20;          //开空条件
PK:=c>H10;          //平空条件
N:=ma(TR,ATRL);
units:=ASSET*risk*0.01/N;

 //建立仓位
if BARPOS=1 then begin
  end; //初始化;
 if position=0 and BARPOS>D20 and h>l then begin
   //建立多头仓位 
   if KD  then  BEGIN
     myentryprice:=if(open>H20+MINDIFF, open ,H20+MINdiff);
      buy(KD,units,LIMITR,myentryprice);
      position:=1;
      tuntis:=1;
      sendoederthisbar:=1;
    end;
    
  //建立空头仓位
    if KK then begin 
    myentryprice:=if(open<L20-MINDIFF ,open ,L20-MINDIFF);
    BUYSHORT( KK,units,LIMITR,myentryprice);
    position:=-1;
    tunits:=1;
    sendorderthisbar:=1;
    end
    
   end


 if  position=1 and BARPOS>D20 and H>l then begin
  
  //多头离场
  pdcond:= pd and sendorderthisbar=0 ;
  if pdcond then begin
  myexitprice:=if(open<L10-MINDIFF,open,L10-MINDIFF);
  sell( pdcond, holding,limitr,myexitprice);
  position:=0;
  end
  
   //多头止损
   dzcond:= low<myentryprice-2*N and position=1 and sendorderthisbar=0 ;
   if dzcond then begin
   myexitprice:=if(open<myentryprice-2*N,open,myentryprice-2*N);
   myexitprice:=floor(myexitprice/MINDIFF)*mindiff;
   sell(  dzcond,holding,limitr,myexitprice);
   position:=0;
   ENd;
   
   end
    

  if position=-1 and BARPOS>d20 and H>l then begin

  //空头离场
  pkcond:= pk and sendorderthisbar=0 ;
  if pkcond then begin
  myexitrice:=if(open>H10+MINDIFF,open,h10+MINDIFF);
  sellshort( pkcond,HOLDING,limitr,myexitprice);
  position:=0;
  end
  
   //空头止损
   kzcond:= h>myentryprice+2*N and position=-1 and sendorderthisbar=0;
   if kzcond then begin
   myexitprice:=if(open>myentryprice+2*N,open,myentryprice+2*N);
   myexitprice:=CEILING(myexitprice/MINDIFF)*mindiff;
   sellshort( kzcond,HOLDING,limitr,myexitprice);
   position:=0;
   ENd;
   
   end
    




//信号语句排列规则——先平后开
//“费率设置”按钮——用于合理设置模型“费率”,以便在图形上正确输出如下帐户信息:

持仓:asset,linethick0;

 回到顶部