以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  程序中交易笔数如何表达  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=153910)

--  作者:xm61
--  发布时间:2017/5/23 10:40:50
--  程序中交易笔数如何表达

请问,我在程序中以“i:=0;i=i+1;"表示期货的交易笔数,为什么金之塔程序输出中的i值是300,而实际交易笔数是12000笔?怎样设置?


--  作者:yukizzc
--  发布时间:2017/5/23 11:06:26
--  
你的完整程序是怎么写的,光看这个i工作人员也没理解。。。
--  作者:xm61
--  发布时间:2017/5/23 11:36:21
--  

variable:a=0;
...............

variable:i=0;

.............
variable:b=0;

 

i:=i+1;  //dynainfo(52);
price:=close;

 

..........

..........

if  islastbar then
  begin
  aggdownretmean:=trimmean(aggdownretvec,downperiod,0);
  aggdownretsd:=sqrt(var(aggdownretvec,downperiod));  //无偏方差
  aggupretmean:=trimmean(aggupretvec,upperiod,0);
  aggupretsd:=sqrt(var(aggupretvec,upperiod));       //无偏方差
  i值:i,colorgray,linethick0;
   end


--  作者:xm61
--  发布时间:2017/5/23 11:40:44
--  

由于保密原因,程序不便在此公开,但用到i的累加计算的地方只有这里,关键是程序中如何表达并使用交易笔数。


--  作者:wenarm
--  发布时间:2017/5/23 12:15:44
--  

你上述的代码对问题分析没有任何意义,请表达下你关于i变量处理的思路。

[此贴子已经被作者于2017/5/23 12:16:11编辑过]

--  作者:xm61
--  发布时间:2017/5/23 14:01:26
--  

以下是我的程序,程序在“分笔成交”环境下运行,i应该是交易笔数,但交易笔数小于300时运行正确,交易笔数超过300时不正确,主要是i停留在300不变,不知哪里出了问题。

variable:upperiod = 0;      

variable:downperiod = 0;    

variable:increasenum = 0;    
variable:decreasenum = 0;   
variable:aggincidx = 0; 
variable:aggdecidx = 0;
variable:aggincidx1 = 0; 
variable:aggdecidx1 = 0;
variable:uptrend=false;     
variable:downtrend =false;  
variable:price[]=0;         
variable:indexvec[]=0;      
variable:aggupretvec[]=0;    
variable:aggdownretvec[]=0; 

variable:aggupretmean = 0;  
variable:aggupretvar = 0;   
variable:aggdownretmean = 0;
variable:aggdownretvar = 0; 
variable:i=0;
variable:a=0;
variable:b=0;

i:=i+1;  //dynainfo(52);
price:=close;
if i>=2 then
begin
   indexvec:=price[i])/price[i-1];
      curidx:=indexvec;
     if uptrend=true then
       begin
        aggincidx1:=price[i]/price[a];  
         aggincidx:=max(aggincidx1,price[b]/price[a]);
         increasenum:=0;
       end   
      if downtrend=true then
       begin
        aggdecidx1:=price[i]/price[b];
         aggdecidx:=min(aggdecidx1,price[a]/price[b]);
         decreasenum:=0;
        end   
      
      if curidx>0 and uptrend=false  then
      begin
       increasenum:=increasenum + 1;
         if increasenum=1  then    
            a:=i-1;
         
        if increasenum=2 then
        begin   
           for j=a to i-1 do
           begin
             if (price[j+1]<price[j])and (price[i]<=price[a+1]) then
              begin
               t1:=false;
               increasenum:=1;
               a:=i-1;              
               break;
              end
           else          
             t1:=true;     
          end
          end
          if t1=true then  
            begin
             
            if downtrend=true then
              aggdownretvec:=aggdecidx*100000000;     
              uptrend:=true;
              aggincidx1:=price[i]/price[a];
              upperiod:=upperiod + 1;    
              increasenum:=0;
              decreasenum:=0;
              downtrend:=false;
              s1:=false;
             end  
            end 
     
    if curidx<0 and downtrend=false then
    begin
       decreasenum:=decreasenum+1;
        if decreasenum=1 then 
            b:=i-1;  
          
        if decreasenum=2 then
        begin   
         for j=b to i-1 do
         begin
           if (price[j+1]>price[j])and (price[i]>=price[b+1]) or(increasenum>=2) then
             begin
             s1:=false;
              decreasenum:=1;
               b:=i;           
             break;
             end
        else           
            s1:=true;
       end
     end
       
         if s1=true then//判断下跌       
          begin
            if uptrend=true then
            aggupretvec:=aggincidx*100000000;                   
            downtrend:= true;  
            aggdecidx1:=price[i]/price[b];
            downperiod:=downperiod+1;         // 下跌周期数 
            uptrend:=false;
            t1:=false;
            increasenum:=0; 
            decreasenum:=0;
          end
      end
  end 
 
 if islastbar and uptrend=true then
        aggupretvec:=aggincidx*100000000;
 
 if islastbar and downtrend=true then                                 
       aggdownretvec:=aggdecidx*100000000; 

 //计算相应的均值和方差
 if  islastbar then
  begin
  aggdownretmean:=trimmean(aggdownretvec,downperiod,0);
  aggdownretsd:=sqrt(var(aggdownretvec,downperiod));  //无偏方差
  aggupretmean:=trimmean(aggupretvec,upperiod,0);
  aggupretsd:=sqrt(var(aggupretvec,upperiod));       //无偏方差
  i值:i,colorgray,linethick0;
  下跌均值:aggdownretmean,colorwhite,linethick0;
  下跌标准差:aggdownretsd,colorwhite,linethick0;
  上涨均值:aggupretmean,colorwhite,linethick0;
  上涨标准差:aggupretsd,colorwhite,linethick0;
  上涨期数:upperiod,colorwhite,linethick0;
  下跌期数:downperiod,colorwhite,linethick0;
 end

 


--  作者:wenarm
--  发布时间:2017/5/23 14:18:31
--  

你是怎么得到只有300的,本地测试你上述的代码得到的结果就是k线数量,你的i其实就是barpos.

 


图片点击可在新窗口打开查看此主题相关图片如下:8.png
图片点击可在新窗口打开查看