Warning 502. You are calling Plot()/PlotOHLC() function over 500 times, it is highly inefficient. Reduce number of calls.

You are calling Plot()/PlotOHLC() function over 500 times, it is highly inefficient. Reduce number of calls.

It is important to understand that Plot() function involves plotting entire chart and that is rather costly. If you want to draw segmented line generated using for example LineArray, don't call Plot() multiple times. Instead combine all LineArrays into one and use single Plot call.

for( i = 0; i < 600; i++ )
{
 x0 = ..;
 x1 = ..;
 y0 = ..;
 y1 = .. ;
 
Plot( LineArray( x0, x1, y0, y1 ), "", colorRed ); // DO NOT DO THIS !

}

Instead use single Plot():

CombinedLine = Null;
for( i = 0; i < 600; i++ )
{
 x0 = ..;
 x1 = ..;
 y0 = ..;
 y1 = .. ;
      
 La =
LineArray( x0, x1, y0, y1 );

 CombinedLine =
IIf( IsNull( la ), CombinedLine, la ); // combine lines
}

Plot( CombinedLine, "", colorRed ); // THAT IS PROPER WAY - one call to Plot that does all the plotting in one shot

For more examples see also http://www.amibroker.org/userkb/2007/04/20/plotting-trade-zigzag-lines/