Histogram buffers

 
Can someone please confirm how histogram buffers are used when writing custom indicators?

I have already created an indicator that draws a line on the chart window.

I now want to add histogram markers above and below the line in two different colours (green above, and red below, for instance).

Can I do this by adding a single histogram, or do I need to add 2.

Does each histogram need 2 buffers?

How do I relate the buffers to the histograms?
 
I think you need 2 buffers for each hitstogram if you want them truncated above an below. Check heikenashi indicator. It's a good example of double-buffered histogram.
 
Hi,

Thanks. I looked at that indicator, but still cannot work it out.

are buffer1 and buffer2 used for the first histogram, and buffer 3 and buffer 4 used for the 2nd histogram?

Indexes are linked to buffers as 1=1, 2=2, etc.

But 1=white, 2 = red, 3 = white, 4 = red.

1 and 2 are width 1, 3 and 4 are width 3.

So I assume 1 and 2 draw the thin line, then 3 and 4 draw the fat line.

How does it decide which colour to use for each line?
 
Thanks Stringo.

I have read the documentation. It does not answer my question, or I cannot see how it does.

I have got my histograms working, but I do not really understand how. Nobody seems able to explain these properly, they just seem to hack until it works one way or another, and point off to other examples that also happen to work.

If I add another buffer, and link it to a line, then it changes the way the histograms work (the colour may change or histogram will become a line, etc). Why would that sort of thing happen?

If anyone can explain clearly how the histograms, buffers and indexes relate to each other, without referring to other code or references, I am sure many will be very grateful.

Charlie
 
From the article:

"SetIndexStyle" function controls drawing parameters of an indicator array. The drawing mode of DRAW_LINE assumes that lines between values defined in a corresponding indicator array are drawn. The drawing mode of DRAW_HISTOGRAM having been applied to the main window indicator has its special features, as well. A histogram is drawn between corresponding values of two index arrays: an even one (here: SpanA_Buffer) and an odd one (here: SpanB_Buffer). At that, the color of the index array is used the value of which is higher.


See also Heiken Ashi custom indicator as sample.
 
stringo:
From the article:

"SetIndexStyle" function controls drawing parameters of an indicator array. The drawing mode of DRAW_LINE assumes that lines between values defined in a corresponding indicator array are drawn. The drawing mode of DRAW_HISTOGRAM having been applied to the main window indicator has its special features, as well. A histogram is drawn between corresponding values of two index arrays: an even one (here: SpanA_Buffer) and an odd one (here: SpanB_Buffer). At that, the color of the index array is used the value of which is higher.


See also Heiken Ashi custom indicator as sample.

Yes, I read that, as I explained, and still do not see the direct connection. Is it any arbitrary odd and even buffer? If I say SetIndexBuffer(2, StartBuffer), is it automatic that SetIndexBuffer(3, EndBuffer) will associate with the same histogram?

If the first one is SetIndexBuffer(1, StartBuffer), will SetIndexBuffer(2, EndBuffer) be appropriate, or does it always need to be even first, then odd?

In the same example, #[roperty is used to et the colors. color3 and color4 are different, but don't they relate to the same histogram? How does it decide which color to use?
 
Histogram pairs are: 0-1, 2-3, 4-5, 6-7

Don't think about color3 and color4 - high is always greater than low. Color for high buffer used always
 
stringo:
Histogram pairs are: 0-1, 2-3, 4-5, 6-7

Don't think about color3 and color4 - high is always greater than low. Color for high buffer used always
This also confused me with Ichimoku example.

What I see in Ich. code, doesn't it look like draw hatch histogram with buffer 2-5, 3-6? I cannot find any relation setup between buffers which link the hatch. If the pairs are 2-3, 4-5, 6-7 as stated above, does that mean the Ich code should set as following:

 SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
 SetIndexStyle(3,DRAW_LINE,STYLE_DOT);


 SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_DOT);
 SetIndexStyle(5,DRAW_LINE,STYLE_DOT);

But in fact, the actual code wrote as following:

 SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
 SetIndexStyle(5,DRAW_LINE,STYLE_DOT);


 SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
 SetIndexStyle(6,DRAW_LINE,STYLE_DOT);

I am confused here: why the buffer 2 is correspond to 5, and so 3 to 6?
 
All right. Histogram buffers are 2 and 3. Buffers 5 and 6 used for clouds outlining
 

Hi chucklz,

I see your point(s)!


Today, I have wasted time to get a candle stick working.
After two hours I have found out that the Heiken-Ashi-hack (because that's what I now consider it!) does NOT work in a separate window!

The result of changing the standard Heiken-Ashi indicator to use a separate window is the following:





Please MetaQuotes Development Team consider to clean this up in a futere release and make candle sticks e.g. an extension of the DRAW_<Styles>.
And if you are at it, consider the addition of an OHLC-Style as well.

Many thanks in advance!

Max Payne