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 ...
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