Download MetaTrader 5

Multi-Color buffer line - Need more clarification

To add comments, please log in or register
selnomeria
261
selnomeria  

In this article - https://www.mql5.com/en/articles/135

there is not writen, how color-buffers are assigned to specific buffer.

for example:

   SetIndexBuffer(0,buffer_line1,INDICATOR_DATA);

PlotIndexSetInteger(0,PLOT_LINE_COLOR,0, clrGreen); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1, clrRed);

   SetIndexBuffer(1,buffer_line2,INDICATOR_DATA);

PlotIndexSetInteger(1,PLOT_LINE_COLOR,0, clrGreen); PlotIndexSetInteger(1,PLOT_LINE_COLOR,1, clrRed);

   SetIndexBuffer(4, color_buffer,INDICATOR_COLOR_INDEX);


My question is , when we set values in the loop:


color_buffer[i] = 1;


which buffer-line color is changed?  1st or 2nd buffer?


how to refer the color-buffer to specific data-buffer?

Creating Multi-Colored Indicators in MQL5
Creating Multi-Colored Indicators in MQL5
  • 2010.08.02
  • Дмитрий Александрович
  • www.mql5.com
In this article, we will consider how to create multi-colored indicators or convert the existing ones to multi-color. MQL5 allows to represent the information in the convenient form. Now it isn't necessary to look at a dozen of charts with indicators and perform analyses of the RSI or Stochastic levels, it's better just to paint the candles with different colors depending on the values of the indicators.
Mladen Rakic
90415
Mladen Rakic  
selnomeria:

In this article - https://www.mql5.com/en/articles/135

there is not writen, how color-buffers are assigned to specific buffer.

for example:

   SetIndexBuffer(0,buffer_line1,INDICATOR_DATA);

PlotIndexSetInteger(0,PLOT_LINE_COLOR,0, clrGreen); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1, clrRed);

   SetIndexBuffer(1,buffer_line2,INDICATOR_DATA);

PlotIndexSetInteger(1,PLOT_LINE_COLOR,0, clrGreen); PlotIndexSetInteger(1,PLOT_LINE_COLOR,1, clrRed);

   SetIndexBuffer(4, color_buffer,INDICATOR_COLOR_INDEX);


My question is , when we set values in the loop:


color_buffer[i] = 1;


which buffer-line color is changed?  1st or 2nd buffer?


how to refer the color-buffer to specific data-buffer?

The way you wrote it, none of your lines will be colored line

Check the link in your post

selnomeria
261
selnomeria  

I have read and that's why I have asked...  I couldnt find out with those examples...  please tell me how to do that, 

the colorbuffer-index should be the next index of the desired buffer-index???

selnomeria
261
selnomeria  

have I to add only this?


PlotIndexSetInteger(indexx,PLOT_DRAW_TYPE, DRAW_COLOR_LINE  ); 
Mladen Rakic
90415
Mladen Rakic  
selnomeria:

have I to add only this?


PlotIndexSetInteger(indexx,PLOT_DRAW_TYPE, DRAW_COLOR_LINE  ); 

Colored lines always go in pairs

Something like this

 SetIndexBuffer(0,buffer_line1,INDICATOR_DATA);
 SetIndexBuffer(1,buffer_line1colors,INDICATOR_COLOR_INDEX);
 SetIndexBuffer(2,buffer_line2,INDICATOR_DATA);
 SetIndexBuffer(3,buffer_line2colors,INDICATOR_COLOR_INDEX);


 SetIndexBuffer(nn  ,buffer_line(nn),INDICATOR_DATA);
 SetIndexBuffer(nn+1,buffer_line(nn)colors,INDICATOR_COLOR_INDEX);
You can not have one colors buffer for multiple color lines
selnomeria
261
selnomeria  
Mladen Rakic:

Colored lines always go in pairs

Something like this

You can not have one colors buffer for multiple color lines

THANKS! now i understand. THAT SHOULD BE WRITTEN IN DOCS, what you say.
Alain Verleyen
Moderator
37215
Alain Verleyen  
selnomeria:

THANKS! now i understand. THAT SHOULD BE WRITTEN IN DOCS, what you say.
Are you sure it is not ?
tina232
7
tina232  

Hello, thanks a lots

I'wited code that drow standard deviation index in multicolor (red when up, green when down) and other two indicator that drow move with different period time.

Here there a mql4 example of couple of my custom indicator (standardeviation with move and color as alert and new saratoga indicator), When i try to write standard deiation multicolored index with 2 move index

i'find a lot of matter.

I'think that mql5 manual are made only for mega expert, or simply it eritted in wrong mode!

here is a side of code in mql5. The result is  no multicolor in stddev

int OnInit()

{  

   Hstd                = iStdDev(_Symbol, _Period, SDPrd, 0, MODE_SMA, PRICE_CLOSE);  // deviazione standard a SDPrd

   min_rates_total     = int(MathMax((SDPrd + 1), movNormale));

//--- indicator buffers mapping

   SetIndexBuffer(0, STD, INDICATOR_DATA);

   SetIndexBuffer(1, StdMoveCorta, INDICATOR_DATA);

   SetIndexBuffer(2, StdMoveNormale, INDICATOR_DATA);

   

   s = "Tiz Std(" +  DoubleToString(SDPrd) + ")";   

   PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_LINE);

   PlotIndexSetInteger(0, PLOT_LINE_STYLE, STYLE_SOLID);

   PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrLime);  

   PlotIndexSetInteger(0, PLOT_LINE_WIDTH, 2);   

   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, min_rates_total );  

   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);  

   PlotIndexSetString(0, PLOT_LABEL, s);


   if (OKMovCorta){

      s = "Tiz StdMov(" + movCorta + ")"; //      metto prima l'ombra.... per favorire la visualizzazione....

      PlotIndexSetInteger(1, PLOT_DRAW_TYPE, DRAW_LINE);

      PlotIndexSetInteger(1, PLOT_LINE_STYLE, STYLE_DOT);

      PlotIndexSetInteger(1, PLOT_LINE_COLOR, clrBlue);

      PlotIndexSetInteger(1, PLOT_LINE_WIDTH, 1);     

      PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, min_rates_total );  

      PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0.0);

      PlotIndexSetString(1, PLOT_LABEL, s);   

   }

   if (OKMovNormale){

      s = "Tiz StdMov(" + movNormale + ")"; //      metto prima l'ombra.... per favorire la visualizzazione....

      PlotIndexSetInteger(2, PLOT_DRAW_TYPE, DRAW_LINE);

      PlotIndexSetInteger(2, PLOT_LINE_STYLE, STYLE_DOT);

      PlotIndexSetInteger(2, PLOT_LINE_COLOR, clrBlack);

      PlotIndexSetInteger(2, PLOT_LINE_WIDTH, 1);     

      PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, min_rates_total );  

      PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, 0.0);

      PlotIndexSetString(2, PLOT_LABEL, s);   

   }

   

   SetIndexBuffer(3, StdColor, INDICATOR_COLOR_INDEX); // serve per indicare il colore fra direzione su e giu       

   

   // si devono indicare i colori dopo la dichiarazione del buffer colori

   PlotIndexSetInteger(0, PLOT_COLOR_INDEXES, 2);  // due colori x l'indice

   PlotIndexSetInteger(0, PLOT_LINE_COLOR, 0, Up);   // colore per su

   PlotIndexSetInteger(0, PLOT_LINE_COLOR, 1, Down); // colore per giù      

   

   IndicatorSetInteger(INDICATOR_DIGITS, 5);   


Yes, of course, in onCalculate side I put this code

      // determino il colore

      if ( STD[k] > STD[k-1] ) // LIME SU

         StdColor[k] = 0; 

      else

         StdColor[k] = 1; 

Someone can help me ? thank you.

      

Here are result in mql5 (last indicator, stddev is of lime color and not in multicolor)


whroeder1
18230
whroeder1  
When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
          Messages Editor
To add comments, please log in or register