can some one repair this afl ?

#13
Hi i dint get any warning messages..if u r getting any warnings like plot()/plotOHLC() RUNNING 500 times or smthing.Then it means in u r code u placed a plot inside a loop..
either a for loop,while or some infinite if loop so..jus place the plot outside the loop... or try to figureout the limit of plot()/plotOHLC() function for which it processes..
explain me u r problem better ..i wd like to help
 

colion

Active Member
#14
Hi i dint get any warning messages..if u r getting any warnings like plot()/plotOHLC() RUNNING 500 times or smthing.Then it means in u r code u placed a plot inside a loop..
either a for loop,while or some infinite if loop so..jus place the plot outside the loop... or try to figureout the limit of plot()/plotOHLC() function for which it processes..
explain me u r problem better ..i wd like to help
Assuming that you are using the same code as listed below then I suspect that you are using an older version of AmiBroker as Warning 502 was added in version 5.41. If you are using a version above 5.41 then please post the code that you are running.
 
#17
Dears and experts;

All error are spaces just close the space gaps EXCEPT THE ANNOYING ERROR in many afls:
Till giving a Warning 502
There is a way to Combined the calculation formula, I using AB 5.50.5
Below is the solution from AB help, but I could not fix it!!
--------------------------------------------------
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/
----------------------------------
Best regards,
 

Similar threads