I have my data (which is a csv file from excel) it has all the usual info OPEN, HIGH, LOW, CLOSE ..etc.
The last column is a calculated value (done in excel) that I want to plot - not every entry (date) has a value. When importing the database I call this column AUX1.
When i try to plot AUX1 all the non entries plot as 0.
Looking at the posted images, I think @smedlex needs to do something similar to what is covered by this article.
Here is a snippet to compare the different suggested ways (with a fake array to be replaced by his Aux1 values):
// Code derived from this article:
// http://www.amibroker.org/userkb/2007/04/20/plotting-trade-zigzag-lines/
// Let's fill a fake array with some values every 50 bars in a zig-zag (others bars are null)
SetBarsRequired( sbrAll, sbrAll );
a = Null;
for( i = 0; i < BarCount; i+=50 )
{
if( ( i % 100) == 0 )
a[i] = i;
else
a[i] = i + 100;
}
// Uncomment the next line and delete all the above to test with your Aux1 data
// a = Aux1;
// Comparing other ways to plot the array that has multiple null values
// -- plot only the values as histogram (no bar is displayed for null values)
// Plot(a, "a", colorWhite, styleHistogram);
// -- plot only the existing values (will be displayed as dots)
Plot(Iif( a > 0, a, Null ), "Array", colorYellow, styleLine, Null, Null, 0, 0, -100); // to see this you need to zoom in....
// -- plot a line with last value on zero value
Plot( ValueWhen( a > 0, a ), "Array", colorBrightGreen, styleDashed );
// Plot as a zig-Zag line using lineArray()
fvb = Status( "firstvisiblebar" );
lvb = Status( "lastvisiblebar" );
combinedLine = Null;
x1 = 0;
y1 = a[0];
// Find the firstnon zero value before first visible bar
for( i = fvb - 1; i >= 0; i-- )
{
if( a[i] > 0 )
{
x1 = i;
y1 = a[i];
break;
}
}
// Use LineArray to join the NON-ZERO values and
// then combine all the segments in a sngle line
lastValidBar = -1;
lastValidValue = Null;
for( i = fvb; ( i <= lvb ) AND( i < BarCount ); i++ )
{
if( a[i] > 0 )
{
lastValidBar = i;
lastValidValue = a[i];
x2 = i;
y2 = a[i];
segment = LineArray( x1, y1, x2, y2 );
combinedLine = IIf( IsNull( segment ), combinedLine, segment );
x1 = x2;
y1 = y2;
}
}
// optional - use the last known value to plot if the rest of bars are null
if( ( lastValidBar >= 0 ) AND( lastValidBar < BarCount) )
{
x2 = BarCount - 1;
y2 = lastValidValue;
segment = LineArray( x1, y1, x2, y2 );
combinedLine = IIf( IsNull( segment ), combinedLine, segment );
}
Plot( combinedLine, "Array", colorRed, styleLine | styleThick );
The small advantage of the "old" lineArray() method is that the plotted combinedLine values could be used with functions like SelectedValue() (for instance in the Title) to get theoretical intermediate values for the Null bars.