Histogram chart from zero has zero height (obviously), was: How arrays work with plot

Hi,
in my study of understanding Amibroker and its array operations (i've read the doc) I created a code that will paint the background of the day session:

starTtime= 093000;
endTime = 160000;
timeNow = TimeNum();
isDayTime = timeNow > startTime AND timeNow < endTime;

Plot( isDayTime, "Day Session", colorGreen, styleArea | styleOwnScale | styleNoLabel | styleNoTitle, 1, 0, 0, -1, 1 );

I would like to make sure i understood how it works, so please confirm if my interpretation is correct:

"Plot" has an array of 0 and 1 corresponding to each bar.
It will use this array to plot something at each bar:
If value = 0: will do nothing
If value = 1: will plot something at 1 vertical level on chart. Because of the style used, the plot will expand vertically up the chart. The contiguous plots for each bar will create this pain like effect.
If array would contain series of 3 instead of 1, result would be the same but plot would have started at 3 vertical level.

My question is: does the plot consider 1 as boolean (do something), or a vertical value to begin plot?

array

No, your interpretation is incorrect. 0 and 1 are normal numbers. They are just plotted (line at 0 or 1 level) like any other number.

To plot "NOTHING" you have to pass Null. Null is a special number that means "nothing".

Docs:
http://www.amibroker.com/f?plot

Thanks, I read this page also.
I don't get how Plot knows not to plot anything when value is 0, but does it when value is 1.

I would have expected the same vertical expansion if it's either 0 or 1.
What's the parameter that impacts this?

Thanks for the quality of your answer.
I will take time to study it all in details. I will learn a lot.

From the first read, your exemple with volume is enlightening.

But the meaning of 0 changes when an array would contain 0 as a value (integer). For instance, consider the Volume array, it would carry the sum of number of contracts traded for each bar, and if there happens to be no transaction for a bar, then value of Volume for that bar will be 0 .

When it is 0 If I understand correctly it is simply not plotted, not because it is a boolean, but because it considers there is no quantity to plot.

I will investigate further and explore all those links.

Unfortunately post from you @Brakkar and @Cougar contain false statements.

The message that I already tried to deliver to you is that ZERO is plotted like ANY other number.

It is NOT boolean or any such nonsense. Plot does NOT care about zero or non-zero.

You just happen to be misguided by your eyes because if you plot ZERO on histogram chart then the bar height is zero so you can't see it unless you set the base of your histogram to something else than zero. But normally, with line chart, you definitely SEE the zeros, look at this sine wave, it crosses thru zero and zeros ARE plotted as any other number:

Plot( sin( BarIndex() * 0.01 ), "sine wave", colorRed );

image

As you can see all numbers from sine output (in the range of -1 to 1) are plotted just the same. Zero is NOT special.

Only if you display histogram that has BASE at the level of zero, histogram from zero to zero will give you bar with zero height.

Zero does NOT have any special meaning with regards to Plot() function.

We do NOT talk boolean logic when it comes to Plot(). Boolean values only have meaning for functions and variables that expect boolean input (such as IIF(), ValueWhen(), Buy/Sell/Short/Cover variables), but NOT with Plot() function.

3 Likes

Ok thanks for the precision.
I got it. Indeed, nothing to do with boolean logic.

In newbie words:

The styleArea or styleHistogram goes all the way up the screen when value is 1 because the Plot is set to have its own scale and is not scaled on same scale as price.

If maxValue is set to 1 with own scale, then top of screen == 1.
If maxValue is 2 then plot will halt half screen up if plot value == 1.
If maxValue is 3 then plot will stop 1/3 of screen if plot value == 1.
etc etc.

So of course if value to plot == 0 it will not take up vertical screen space.

This makes sense.

First and foremost: you should NOT use styleOwnScale.

It is totally incorrect to use it with only one Plot statement.

styleOwnScale is for advanced users only (1+ year experience with AmiBroker programming) and it can only be used when there is already another Plot() called first in given formula that does NOT use that style.

If you used Plot correctly without styleOwnScale you would immediately know what Y axis scale is. With styleOwnScale you can't see that.

Tomasz, one lesson well learned, is that, I must not post under the influence of... hmm... let's just say bud!