Download MetaTrader 5

Can you put a buffer in Arry

To add comments, please log in or register
Ma Yuliang
255
Ma Yuliang 2015.07.03 02:52 

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.


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);
     }



To add comments, please log in or register