Programming Question...

 

Hi. Could anyone tell me if it's possible to have Histograms oscillating about a value other than zero or is this another MT4 limitation. The 'SetLevelValue' command only seems to effect where the center line is drawn which is not the same thing...

 
omelette:
Hi. Could anyone tell me if it's possible to have Histograms oscillating about a value other than zero or is this another MT4 limitation. The 'SetLevelValue' command only seems to effect where the center line is drawn which is not the same thing...

It is possible, but dificut too. You need to cover one histogram by another one which. Eg if you wish to have values + 10 and -10 from the 50 line, then you need to fill one histogram with value 60, second (that will cover first one) with value 40 and thirt (that will cover the 2nd histogram from 0 to 40) with background color. Dificult and compilcated, but not impossible !

 
Kalenzo:
It is possible, but dificut too. You need to cover one histogram by another one which. Eg if you wish to have values + 10 and -10 from the 50 line, then you need to fill one histogram with value 60, second (that will cover first one) with value 40 and thirt (that will cover the 2nd histogram from 0 to 40) with background color. Dificult and compilcated, but not impossible !

Kalenzo, thanks, I appreciate your insight. Your right, it is complicated. I was trying to put 2 histos in the same window, each of which uses 3 display buffers so your explanation rules that out! It's a shame there isn't a simple command like 'SetLevelValue' and it seems it should be very easy for the Metatrader programmers to include. Guess they're too busy fixing other bugs

 

A workaround would be to subtract your offset from the computed value before displaying the histogram. Say you want values above 60 to display positive, and values below 60 to display negative. Just subtract 60 from each of the values loaded into the display buffer, and they will display as you want, but you will mentally have to add 60 to each of the values when looking at the histogram.

 
SteveBrown:
A workaround would be to subtract your offset from the computed value before displaying the histogram. Say you want values above 60 to display positive, and values below 60 to display negative. Just subtract 60 from each of the values loaded into the display buffer, and they will display as you want, but you will mentally have to add 60 to each of the values when looking at the histogram.

I'm afraid that doesn't work, which is what prompted me to post the question - the histo will 'run' to the zero line irrespective of the offset. I'm pretty sure the only way to do it is as Kalenzo suggested, which is not practical in practice as the display buffer limitation will prevent you doing anything useful...

 

Omlette, perhaps I misunderstand the question? A histogram normally displays positive values above the zero line and negative values below the zero line. So you can force positive values below any arbitrary threshold to be negative. For example, if you want values below 60 to be displayed below the zero line, you can change the following line of code

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

to this:

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i) -60;

It's a workaround, because when you look at the histogram, you mentally have to add 60 to the values displayed. For example, a value displayed as -20 is really +40, but you wanted it displayed below the zero line.

 

Hi. I know what you are saying but that is not was I was referring to. What I was trying to do was place two Histos in the same separate window, each occupying half that window. What I quickly found was that MT4 forces all histos to the infernal zero line irrespective of what offsets you use - you can offset above or below the zero but the colours will still 'run' to the zero line. For a sec. I thought the solution would be provided by the 'SetLevelValue' but this just sets where the line graphic is displayed. All this would be much easier to explain graphically, unfortunately that code formed the basis of a single histo indicator. You might consider try coding one yourself so you can see this limitation first-hand. It's a pity really 'cos you would think it would be relatively easy to add this feature.

SteveBrown:
Omlette, perhaps I misunderstand the question? A histogram normally displays positive values above the zero line and negative values below the zero line. So you can force positive values below any arbitrary threshold to be negative. For example, if you want values below 60 to be displayed below the zero line, you can change the following line of code

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

to this:

MacdBuffer=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i) -60;

It's a workaround, because when you look at the histogram, you mentally have to add 60 to the values displayed. For example, a value displayed as -20 is really +40, but you wanted it displayed below the zero line.