Questions from Beginners MQL5 MT5 MetaTrader 5 - page 751

 
Vitaly Muzichenko:
The documentation covers this very well, and there is even a ready and working example

the documentation for DRAW_HISTOGRAM2 does not have this
 
igorbel:

There is no such thing in the DRAW_HISTOGRAM2 documentation

Yes, a little differently

https://www.mql5.com/en/docs/customind/indicators_examples/draw_color_histogram2

Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_COLOR_HISTOGRAM2
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_COLOR_HISTOGRAM2
  • www.mql5.com
Custom Indicators / Indicator Styles in Examples / DRAW_COLOR_HISTOGRAM2 - Reference on algorithmic/automated trading language for MetaTrader 5
 

What am I supposed to store in the colour buffer anyway? The example there is a bit complicated.
 

Figured it out.

Awesome_Oscillator from the examples is easier.

 

I did this, but now the other indicator buffers are not displayed :(

There are just lines.

//--- indicator buffers mapping
   SetIndexBuffer(0,buf0,INDICATOR_DATA);
   PlotIndexSetString(0,PLOT_LABEL,"buf0");
   //---
   SetIndexBuffer(1,buf1,INDICATOR_DATA);
   PlotIndexSetString(1,PLOT_LABEL,"buf1");
   //---
   SetIndexBuffer(2,buf_colors,INDICATOR_COLOR_INDEX);
   //---
   SetIndexBuffer(3,buf2,INDICATOR_DATA);
   PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(3,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(3,PLOT_LINE_COLOR,clrRoyalBlue);
   PlotIndexSetString(3,PLOT_LABEL,"buf2");
   //---
   SetIndexBuffer(4,buf3,INDICATOR_DATA);
   PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(4,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(4,PLOT_LINE_COLOR,clrRed);
   PlotIndexSetString(4,PLOT_LABEL,"buf3");

buf0, buf1, buf_colors are histograms.

buf2, buf3 are lines and are not displayed, although the values are there.

 
igorbel:

I did this, but now the other indicator buffers are not displayed :(

There are just lines.

buf0, buf1, buf_colors are histograms.

buf2, buf3 are lines, they are not displayed, although the values are there.

Are the values correct?

#property indicator_buffers 
#property indicator_plots   
 
Vitaly Muzichenko:

Are your values correct?


#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots 3
#property  indicator_type1   DRAW_COLOR_HISTOGRAM2
#property  indicator_color1 clrRed,clrRoyalBlue
#property  indicator_style1  STYLE_SOLID 
#property  indicator_width1  3
These are all directives.
 
igorbel:

These are all directives.
Have you set a colour on the other buffers?
 
Vitaly Muzichenko:
Have you set a colour on the other buffers?


Yes, there is one in the previous post.

   SetIndexBuffer(3,buf2,INDICATOR_DATA);
   PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(3,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(3,PLOT_LINE_COLOR,clrRoyalBlue);
   PlotIndexSetString(3,PLOT_LABEL,"buf2");
   //---
   SetIndexBuffer(4,buf3,INDICATOR_DATA);
   PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_LINE);
   PlotIndexSetInteger(4,PLOT_LINE_STYLE,STYLE_SOLID);
   PlotIndexSetInteger(4,PLOT_LINE_COLOR,clrRed);
   PlotIndexSetString(4,PLOT_LABEL,"buf3");
 
#property  indicator_type2   DRAW_LINE
#property  indicator_type3   DRAW_LINE
That helped. That's weird.
Reason: