Multi colored indicator mt5

 

hi...trying to master mq5

i have made some research but not a single forum about calling a multi color indicator buffer to EA

how do i call it..

DeepPink=Buffer 1?

LimeGreen=Buffer 2?

is that right?

   if(CopyBuffer(hma_handle, 1, 0, 200, hmup) <= 0) return;
   ArraySetAsSeries(hmup, true);
   if(CopyBuffer(hma_handle, 2, 0, 200, hmdn) <= 0) return;
   ArraySetAsSeries(hmdn, true);

if(hmup[0]>0)buy_filt=true; if(hmdn[0]>0)sell_filt=true;
if(buy==true && buy_filt==true)   
{
sendbuy....//
}
if(sell==true && sell_filt==true)   
{
sendsell....//
}

Thank you..

 
Abubakar Saidu:

hi...trying to master mq5

i have made some research but not a single forum about calling a multi color indicator buffer to EA

how do i call it..

DeepPink=Buffer 1?

LimeGreen=Buffer 2?

is that right?

Thank you..

Ignore the color... if hmup and hmdn return values corresponding to what is on the chart, then you're right.

 
Hi Thanks for the reply i still don't get you.

what i mean is there are 7 colors in indicator

when i call Buffer 0 to send order it works fine

buffer 2,3,4,5,6 all worked fine..

what i want to learn is how do i call the Buffer with indicator color index ?

clrLightSkyBlue = BUY
clrPik = SELL

#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1  clrLightSkyBlue,clrPink
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2


SetIndexBuffer(0,tmac,INDICATOR_DATA);
   SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(2,tmau,INDICATOR_DATA);
   SetIndexBuffer(3,tmad,INDICATOR_DATA);
// ** inserted code:
        SetIndexBuffer(4,ReboundD,INDICATOR_DATA); PlotIndexSetInteger(3, PLOT_ARROW, 226);
        SetIndexBuffer(5,ReboundU,INDICATOR_DATA); PlotIndexSetInteger(4, PLOT_ARROW, 225);
        SetIndexBuffer(6,Caution,INDICATOR_DATA); PlotIndexSetInteger(5, PLOT_ARROW, 251);
EA only recognize the line but not the colors.
Thanks..
 
Abubakar Saidu:
Hi Thanks for the reply i still don't get you.
what i mean is there are 7 colors in indicator
when i call Buffer 0 to send order it works fine
buffer 2,3,4,5,6 all worked fine..
what i want to learn is how do i call the Buffer with indicator color index ?
clrLightSkyBlue = BUY
clrPik = SELL

You can't.

Abubakar Saidu:
EA only recognize the line but not the colors.
Thanks..

You've answered your own question.

 
Seng Joo Thio:

You can't.

You've answered your own question.

Is there any way to identify the color of the line.. i just want to use it as filter?

 
Seng Joo Thio:

You can't.

You've answered your own question.

Of course you can. A color buffer is an indicator buffer as any other one.

   SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX);

So it's buffer index 1.

#property indicator_color1  clrLightSkyBlue,clrPink

LightSkyBlue is color 0, pink is color 1.

   if(CopyBuffer(hma_handle, 1, 0, 200, hmcolor) <= 0) return;
   ArraySetAsSeries(hmcolor, true);
hmcolor[i] can be 0 or 1.
 
Alain Verleyen:

Of course you can. A color buffer is an indicator buffer as any other one.

So it's buffer index 1.

LightSkyBlue is color 0, pink is color 1.

hmcolor[i] can be 0 or 1.

 (right, this is mql5, not mql4... but even if it's mql4 it's possible too).

 
Seng Joo Thio:

 (right, this is mql5, not mql4... but even if it's mql4 it's possible too).

Hi.. 

Yes that what i did..

Call the buffer 1 i to EA.. but did not work

Tried calling the buffer 0.. but the Ea place trades even if the color is LightSkyBlue or Pink..

   if(CopyOpen(Symbol(), PERIOD_CURRENT, 0, 200, Open) <= 0) return;
   ArraySetAsSeries(Open, true);
   if(CopyBuffer(team_handle, 0, 0, 6, slpup) <= 0) return;
   ArraySetAsSeries(slpup, true);
   if(CopyBuffer(team_handle, 1, 0, 6, slpdn) <= 0) return;
   ArraySetAsSeries(slpdn, true);
   if(Cross(0, Open[0] > slpup[0]))B=true;
   if(Cross(2, Open[0] < slpdn[0]))S=true;
if(B==true)
  {
buy
}

if(S==true)
  {

sell

///
example indicator source
 
Abubakar Saidu:

Hi.. 

Yes that what i did..

Call the buffer 1 i to EA.. but did not work

Tried calling the buffer 0.. but the Ea place trades even if the color is LightSkyBlue or Pink..

example indicator source

No, buffer 0 is the line value, buffer 1 is color (0 or 1, representing the index of LightSkyBlue or Pink)... 

So you should be having something like this:

   if(CopyBuffer(team_handle, 0, 0, 6, values) <= 0) return;
   ArraySetAsSeries(values, true);
   if(CopyBuffer(team_handle, 1, 0, 6, colors) <= 0) return;
   ArraySetAsSeries(colors, true);

   if (colors[1]==0)
   {
      buy
   }

   if (colors[1]==1)
   {
      sell
   }

So in a way this is still not perfect... but at least you do get values that changes according to different colors... 

But if you reeeeeeeeeeeeeeeeeeaaally want to get the color instead of 0 or 1, you'll have to make use of windows' functions.

 

Wow perfect it works very good..

thanks to you all mql5 community :)

Reason: