下载MetaTrader 5

如何把buffer放进数组中?一个有趣的指标正在编写中我需要您的帮助。

要添加评论,请登录注册
Ma Yuliang
269
Ma Yuliang  

I need to put  buffer in Arry do you know how to do it .

you will know why i need it by read the code below.

The code result is like this. Maybe you had noticed the larg blank area in the right of MACD. Yes There are KDJ,VOL.......and tons of information to go.

Did I miss some powerful function that can get data directly like I do in mql4. Or do you know how to put a buffer in array.

Help me. I will sent the mq5 file to you after I finished them all.

这是我正在制作中的一个指标。在mql4中简单即可完成的代码到了mql5中要变的很复杂。

除了MACD我还要加入KDJ,VOL。。。。等等海量信息。如果可以把buffer 或 handle 放入数组中会让工作量减轻。

或者有方法像mql4一样简单直接地获取数据。

我需要您的帮助,完成后我会与您分享此mq5文件。


this is the original code I am using in Mql4.

      double timeFrame[8]={1,5,15,30,60,240,1440,10080};
      for(t=0;t<=8;t++)
        {
         for(i=0;i<=5;i++)
           {
            if(iCustom(symbol,timeFrame[t],"K/K_MACD",7,i)-iCustom(symbol,timeFrame[t],"K/K_MACD",7,i+1)>0)
              {
               iDisplayInfo("MACD"+IntegerToString(t+1)+"_"+i,"↑",0,355-i*8,20+t*15,8,"",indicator_color2);
              }
            else
              {
               iDisplayInfo("MACD"+IntegerToString(t+1)+"_"+i,"↓",0,355-i*8,20+t*15,8,"",indicator_color3);
              }
           }
        }

now I want to use it in Mql5, I have to code it like this.

   SetIndexBuffer(0,macdM1,INDICATOR_CALCULATIONS);
   SetIndexBuffer(1,macdM5,INDICATOR_CALCULATIONS);
   SetIndexBuffer(2,macdM15,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,macdM30,INDICATOR_CALCULATIONS);
   SetIndexBuffer(4,macdH1,INDICATOR_CALCULATIONS);
   SetIndexBuffer(5,macdH4,INDICATOR_CALCULATIONS);
   SetIndexBuffer(6,macdD1,INDICATOR_CALCULATIONS);
   SetIndexBuffer(7,macdW1,INDICATOR_CALCULATIONS);

   macdHandleM1=iCustom(NULL,PERIOD_M1,"K\\K_MACD",PRICE_CLOSE);
   macdHandleM5=iCustom(NULL,PERIOD_M5,"K\\K_MACD",PRICE_CLOSE);
   macdHandleM15=iCustom(NULL,PERIOD_M15,"K\\K_MACD",PRICE_CLOSE);
   macdHandleM30=iCustom(NULL,PERIOD_M30,"K\\K_MACD",PRICE_CLOSE);
   macdHandleH1=iCustom(NULL,PERIOD_H1,"K\\K_MACD",PRICE_CLOSE);
   macdHandleH4=iCustom(NULL,PERIOD_H4,"K\\K_MACD",PRICE_CLOSE);
   macdHandleD1=iCustom(NULL,PERIOD_D1,"K\\K_MACD",PRICE_CLOSE);
   macdHandleW1=iCustom(NULL,PERIOD_W1,"K\\K_MACD",PRICE_CLOSE);

   CopyBuffer(macdHandleM1,3,0,rates_total,macdM1);
   CopyBuffer(macdHandleM5,3,0,rates_total,macdM5);
   CopyBuffer(macdHandleM15,3,0,rates_total,macdM15);
   CopyBuffer(macdHandleM30,3,0,rates_total,macdM30);
   CopyBuffer(macdHandleH1,3,0,rates_total,macdH1);
   CopyBuffer(macdHandleH4,3,0,rates_total,macdH4);
   CopyBuffer(macdHandleD1,3,0,rates_total,macdD1);
   CopyBuffer(macdHandleW1,3,0,rates_total,macdW1);

   int r=0,top=15;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdM1))
         K_createLable(0,"macdM1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdM1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;

   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdM5))
         K_createLable(0,"macdM5_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdM5_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdM15))
         K_createLable(0,"macdM15_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdM15_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdM30))
         K_createLable(0,"macdM30_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdM30_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdH1))
         K_createLable(0,"macdH1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdH1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdH4))
         K_createLable(0,"macdH4_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdH4_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;
   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdD1))
         K_createLable(0,"macdD1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdD1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }r++;

   for(i=rates_total-7;i<rates_total;i++)
     {
      if(K_trend(i,macdW1))
         K_createLable(0,"macdW1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↑","Arial",10,upClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
      else K_createLable(0,"macdW1_"+(string)i,windowsHandle,200-8*(rates_total-i),top+r*15,CORNER_LEFT_UPPER,"↓","Arial",10,downClr,0,ANCHOR_RIGHT_UPPER,true,false,false,0);
     }



要添加评论,请登录注册