Can't see lines on chart

 

Hello.

I have  to caode indicator with 15  color lines on chart. In attachment screenshot and code.

Why I can read data buffers in Data Window and can't see all  line on chart?  Is there any limitation for draw color lines or I'm coded something wrong.

In Data window values for all 15 lines and on chart only 10 lines.

Thanks you

Files:
MultiMA.mq5  15 kb
windowchart.jpg  305 kb
 
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Piotr Storozenko: I have  to caode indicator with 15  color lines on chart. In attachment screenshot and code. Why I can read data buffers in Data Window and can't see all  line on chart?  Is there any limitation for draw color lines or I'm coded something wrong. In Data window values for all 15 lines and on chart only 10 lines. 

Please note, that in your code, you are indexing your plot's incorrectly, for example when using PlotIndexSet???() functions.

The plot index and buffer index are not the same and are independent of each other.

For example, if a plot requires 2 buffers (ex. one for data and another for colour), then plot #0 has buffer #0 and #1, plot #1 has buffer #2 and #3, and plot #2 has buffer #4 and #5, etc.

 
Fernando Carreiro #:

Please note, that in your code, you are indexing your plot's incorrectly, for example when using PlotIndexSet???() functions.

The plot index and buffer index are not the same and are independent of each other.

For example, if a plot requires 2 buffers (ex. one for data and another for colour), then plot #0 has buffer #0 and #1, plot #1 has buffer #2 and #3, and plot #2 has buffer #4 and #5, etc.

Thanks, I have change number in  PlotIndexSetInteger  functions, but still can see only 10 lines on chart.  

Files:
MultiMA.mq5  15 kb
 

For your primary question about a plot limit, I am not sure. I have never seen such a low limit of only 10 plots. Given that the documentation lists a maximum of 512 buffers, I doubt there is such a small limit on the number of plots.

However after doing some tests, it does seems there is a limit on the number of "#property indicator_???" declarations. I did not know about this and the documentation does not mention it. At least I could not find it.

To solve the problem, you can use the "PlotIndexSet???()" functions to set the details explicitly in the OnInit() handler ...

   for( int i = 2; i < 17; i++ ) {
      PlotIndexSetInteger( i, PLOT_DRAW_TYPE,     DRAW_COLOR_LINE   );
      PlotIndexSetInteger( i, PLOT_LINE_STYLE,    STYLE_SOLID       );
      PlotIndexSetInteger( i, PLOT_LINE_WIDTH,    2                 );
      PlotIndexSetInteger( i, PLOT_COLOR_INDEXES, 3                 );
      PlotIndexSetInteger( i, PLOT_LINE_COLOR,    0, clrYellowGreen );
      PlotIndexSetInteger( i, PLOT_LINE_COLOR,    1, clrBlue        );
      PlotIndexSetInteger( i, PLOT_LINE_COLOR,    2, clrRed         );
   };

Regarding the rest of your code, it is a very ad hoc and "stringy" style, which is prone to bugs, and there are probably more than the ones I spotted.

For example, you are missing buffers when setting the initial colours—you are missing "maColor6" and "maColor13":

     if(prev_calculated==0)
     {
       limit=MAPer15+Step;
       for(int i=0; i<limit; i++)
       {
         maColor1[i]=0.0; maColor2[i]=0.0; maColor3[i]=0.0; maColor4[i]=0.0; maColor5[i]=0.0; maColor7[i]=0.0; maColor8[i]=0.0; maColor9[i]=0.0; maColor10[i]=0.0; maColor11[i]=0.0; maColor12[i]=0.0;
         maColor14[i]=0.0; maColor15[i]=0.0;
       } 
     }

Another example bug for the moving averages, is that you are using an empty value of "0.0" but you are missing the code to declare that explicitly for those plots.

       ArrayInitialize(maValue1,0);
       ArrayInitialize(maValue2,0); 
...
       ArrayInitialize(maValue14,0);
       ArrayInitialize(maValue15,0);

You are missing something like this ...

PlotIndexSetDouble(  i, PLOT_EMPTY_VALUE, 0.0 );

You can however use the default EMPTY_VALUE instead of 0.

In general, your coding needs to be better structured to prevent such bugs and for easier debugging.

Consider creating a class for the moving average an instantiating an array of class objects to better manipulate them in a more elegant and cleaner way.

 
Fernando Carreiro #:

For your primary question about a plot limit, I am not sure. I have never seen such a low limit of only 10 plots. Given that the documentation lists a maximum of 512 buffers, I doubt there is such a small limit on the number of plots.

However after doing some tests, it does seems there is a limit on the number of "#property indicator_???" declarations. I did not know about this and the documentation does not mention it. At least I could not find it.

To solve the problem, you can use the "PlotIndexSet???()" functions to set the details explicitly in the OnInit() handler ...

Regarding the rest of your code, it is a very ad hoc and "stringy" style, which is prone to bugs, and there are probably more than the ones I spotted.

For example, you are missing buffers when setting the initial colours—you are missing "maColor6" and "maColor13":

Another example bug for the moving averages, is that you are using an empty value of "0.0" but you are missing the code to declare that explicitly for those plots.

You are missing something like this ...

You can however use the default EMPTY_VALUE instead of 0.

In general, your coding needs to be better structured to prevent such bugs and for easier debugging.

Consider creating a class for the moving average an instantiating an array of class objects to better manipulate them in a more elegant and cleaner way.

Thanks a lot! Will try.