LineArray and Drawing Line from High to Low on Same Bar

Hoping someone can point me in the right direction. I'm using a slightly modified version of the following code found here ...

http://www.amibroker.org/userkb/2007/04/20/plotting-trade-zigzag-lines/

This is the code I'm currently using to plot ZigZag type lines ...

y0 = 0;
y1 = C[0];
combinedLine = Null;

for( i = 1; i < BarCount; i++ ) 
{
	if( spikeHighType[ i ] == 2 )
	{
		spikePrice[ i ] = High[ i ];
	}
	else
	{
		if( spikeLowType[ i ] == 2 )
		{
			spikePrice[ i ] = Low[ i ];
		}
	}
	
	if( spikeHighType[ i ] == 2 OR spikeLowType[ i ] == 2 )	
	{
	
		x0 = y0;
		x1 = y1;
		y0 = i;
		y1 = spikePrice[ i ];
		La = LineArray( x0, x1, y0, y1 );
		combinedLine = IIf( IsNull( La ), combinedLine, La );
	}
}

Plot( combinedLine, "", colorRed, styleDashed );

And this is an image of what it looks like ...

image

It's working pretty well except for Outside Periods. On July 22nd I'd like the line to go from the High of the 22nd to the Low of the 22nd and then proceed to the High of July 27th.

I'm not sure I can use LineArray to achieve what I'd like to do as the manual for LineArray says x0 must be smaller than x1. Can anyone offer any suggestions as to the best way to accomplish what I'm trying to achieve. I know I can manually plot a ZigZag line from the High to the Low of the same bar. Just not sure how to do it in AFL.

Many thanks

Craig

LineArray as name says generates an array. Now if x0 is the same as x1 you got just one element of the array. Like this:

array[ x0 ] = y0; // just one point

And that means a single point (not line). For this reason you won’t see the lines. To draw strictly VERTICAL line, you need to use GfxMoveTo/GfxLineTo.

Thanks Tomasz

I’ll look into those functions.

Cheers

Craig