Different Buffers = No Data Window Labels and Values

 

Hi,

I'm making an indicator with the option to display COLOR_LINE or COLOR_CANDLES.

Everything goes 100% if I load the indicator and choose the desired mode (COLOR_LINE or COLOR_CANDLES), but if it is already loaded and running and I try to change its DRAW mode, all of the indicator buffers disappear from DATA WINDOW. No error is reported anyway and I suspect the problem may be related to the dynamic BUFFER reorder.

Here you can see the DATA WINDOW when I run the indicator, selecting the CANDLE type at its start (the 2nd option of DRAW MODE combobox):


... and if I change the mode for COLOR_LINE, everything stays as should.

But, if I change back to CANDLES, or even if I call the indicator in LINE mode and change to CANDLES, the reported buffers in DATA WINDOW disappear, remaining only the default ASSET info (in the above, from "Date" to "Spread".


Some definitions:

1- Here is the main header:

#property indicator_chart_window 
#property indicator_buffers 10
#property indicator_plots   6


#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_color1  C'255,0,0', C'120,0,0', C'120,120,0', C'0,120,0', C'0,255,0'
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
#property indicator_label1  "HA Open;HA High;HA Low;HA Close;HA Color;HA Color"

2- Here I select which type of draw the user selected:

//====== DRAWING MODE

    switch(Modo)
      {
       case  ColorLine:

                PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);      
                
                PlotIndexSetInteger(0,PLOT_LINE_STYLE,c_HA_Style);
                PlotIndexSetInteger(0,PLOT_LINE_WIDTH,c_HA_Width);

   
                SetIndexBuffer(0, bufferLine, INDICATOR_DATA);
                PlotIndexSetInteger(0,PLOT_SHOW_DATA,false);
                
                SetIndexBuffer(1, bufferColor,INDICATOR_COLOR_INDEX);
                PlotIndexSetInteger(1,PLOT_COLOR_INDEXES,5);

             
                SetIndexBuffer(2, bufferOpen, INDICATOR_DATA);
                PlotIndexSetString(1,PLOT_LABEL,"HA Open");
            
                SetIndexBuffer(3, bufferHigh, INDICATOR_DATA);
                PlotIndexSetString(2,PLOT_LABEL,"HA High");
            
                SetIndexBuffer(4, bufferLow, INDICATOR_DATA);
                PlotIndexSetString(3,PLOT_LABEL,"HA Low");

                SetIndexBuffer(5, bufferClose, INDICATOR_DATA);
                PlotIndexSetString(4,PLOT_LABEL,"HA Close");
            
                SetIndexBuffer(6, bufferColorData, INDICATOR_DATA);
                PlotIndexSetString(5,PLOT_LABEL,"HA Color");
               
                
             break;



       case  ColorCandles:

                PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_COLOR_CANDLES);      

                SetIndexBuffer(0, bufferOpen, INDICATOR_DATA);
                //PlotIndexSetString(0,PLOT_LABEL,"HA Open");
                
                SetIndexBuffer(1, bufferHigh, INDICATOR_DATA);
                //PlotIndexSetString(1,PLOT_LABEL,"HA High");
                
                SetIndexBuffer(2, bufferLow, INDICATOR_DATA);
                //PlotIndexSetString(2,PLOT_LABEL,"HA Low");
                
                SetIndexBuffer(3, bufferClose, INDICATOR_DATA);
                //PlotIndexSetString(3,PLOT_LABEL,"HA Close");
                
                SetIndexBuffer(4, bufferColorData, INDICATOR_DATA); 
                // PlotIndexSetString(4,PLOT_LABEL,"HA Color");
                
                SetIndexBuffer(5, bufferColor,INDICATOR_COLOR_INDEX);
                PlotIndexSetInteger(4,PLOT_COLOR_INDEXES,5);         
               
                SetIndexBuffer(6, bufferLine, INDICATOR_CALCULATIONS);          
                             
             break;

      }


So, my question is: due to have two modes fundamentally different for plotting information, would I have to separate them in two files to avoid this behavior?

I appreciate any help.

 
AliceRioBR:

Hi,

I'm making an indicator with the option to display COLOR_LINE or COLOR_CANDLES.

Everything goes 100% if I load the indicator and choose the desired mode (COLOR_LINE or COLOR_CANDLES), but if it is already loaded and running and I try to change its DRAW mode, all of the indicator buffers disappear from DATA WINDOW. No error is reported anyway and I suspect the problem may be related to the dynamic BUFFER reorder.

Here you can see the DATA WINDOW when I run the indicator, selecting the CANDLE type at its start (the 2nd option of DRAW MODE combobox):


... and if I change the mode for COLOR_LINE, everything stays as should.

But, if I change back to CANDLES, or even if I call the indicator in LINE mode and change to CANDLES, the reported buffers in DATA WINDOW disappear, remaining only the default ASSET info (in the above, from "Date" to "Spread".


Some definitions:

1- Here is the main header:

2- Here I select which type of draw the user selected:


So, my question is: due to have two modes fundamentally different for plotting information, would I have to separate them in two files to avoid this behavior?

I appreciate any help.

Your plot indexing is incorrect. You have only 1 plot at a time, so 2 max (1 for color candles, 1 for color lines), but you have indexes up to 5. Don't confuse buffers and plots.

Also you should not change the indexing of your buffers between the 2 modes, but only switch the plot draw type. As well the labels in case you want to hide them.

 
Alain Verleyen #:

Your plot indexing is incorrect. You have only 1 plot at a time, so 2 max (1 for color candles, 1 for color lines), but you have indexes up to 5. Don't confuse buffers and plots.

Also you should not change the indexing of your buffers between the 2 modes, but only switch the plot draw type. As well the labels in case you want to hide them.

Hi Alain, thanks for your help!

Let me show you why I proceed as you mentioned:

1- If I set 2 plots only, I will have only the first buffer shown in the DATA WINDOW - in my case, the "OPEN" label; if I have "Plots = 3" I'll have the two first labels, and so forth.


2- The "DRAW_CANDLES" requires the OPEN/LOW/HIGH/CLOSE as the first buffers, while the "DRAW_LINE" require the buffer that handle the line values as being the first one (Buffer 0).


So, I believe that the problem should be really the mix of both (CANDLES and LINE of the same dataset) in a single indicator code.  

I would like to avoid separate this code in two...

Again, thank you for your support and I wish you a real Happy New Year.

 
AliceRioBR #:

Hi Alain, thanks for your help!

Let me show you why I proceed as you mentioned:

1- If I set 2 plots only, I will have only the first buffer shown in the DATA WINDOW - in my case, the "OPEN" label; if I have "Plots = 3" I'll have the two first labels, and so forth.


2- The "DRAW_CANDLES" requires the OPEN/LOW/HIGH/CLOSE as the first buffers, while the "DRAW_LINE" require the buffer that handle the line values as being the first one (Buffer 0).


So, I believe that the problem should be really the mix of both (CANDLES and LINE of the same dataset) in a single indicator code.  

I would like to avoid separate this code in two...

I said you what the problem is and how to solve it :  You have 2 plots only. Don't change the buffers/plots indexing, just hide/show what you need. If you want to see all values in the Data Window, add them all in one label separated by ";".

Again, thank you for your support and I wish you a real Happy New Year.

Thanks, same for you.
 
Alain Verleyen #:
I said you what the problem is and how to solve it :  You have 2 plots only. Don't change the buffers/plots indexing, just hide/show what you need. If you want to see all values in the Data Window, add them all in one label separated by ";".

Thanks, same for you.

Hmmm... I guess that was exactly what I tried before, without success.

Anyway, I'll try what you recommend Alain. Thank you again.

 

Thanks Alain, I got the solution!

I did what you recommended, but I had to use also some tricks like putting some buffers as "calculations", and using PlotSetString too.

Have a good week.

Reason: