Hi Tomasz,

Increasing the threshold merely increases the length of time I have to
wait before the same error appears. My guess is the root of the
problem is that the code needs a minimum number of quotations to
complete the drawing and generates this error when there aren't enough
quotations.

To recap, the error message is:

####################
)/LookBkPd ;
 OP = LastValue(OuterPct) ;
 X=X+sign( OP - ExternalBarPct )*deltaX ;
 deltaX = deltaX/2 ;

Error 14: Endless loop detected in DO-WHILE loop
####################

The whole code for the price chart is as below:

=============================
// Daily Bar Chart
_SECTION_BEGIN("Elder Daily Chart with Envelope");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
Plot( EMA(C,13),"EMA(13)",colorDarkBlue,styleThick);
//PlotForeign(GetBaseIndex(),IndustryID(1),colorBlack,styleLine|styleLeftAxisScale);
 LookBkPd = 100 ;
 AvgPd = 22 ;
 ExternalBarPct = 15 ;
 ConvergePct = 2 ;
 Middle = EMA( C,AvgPd ) ;
 Rng = HHV( H,LookBkPd ) - LLV( L,LookBkPd ) ;
 X = Rng ;
 deltaX = X/2 ;
 do
 {
 Over = H > Middle + X ;
 Under = L < Middle - X ;
 OuterPct = 100*( Sum( Over, LookBkPd ) + Sum( Under, LookBkPd )
 )/LookBkPd ;
 OP = LastValue(OuterPct) ;
 X=X+sign( OP - ExternalBarPct )*deltaX ;
 deltaX = deltaX/2 ;
 }while ( abs( OP - ExternalBarPct ) > ConvergePct ) ;
 Plot( Middle, "EMA(22)", colorRed, styleLine) ;
 //Plot( Middle, "MA", colorRed, styleLine|styleNoTitle ) ;

 Plot( Middle+X, "MA", colorGreen, styleDashed|styleNoTitle ) ;
 Plot( Middle-X, "MA", colorGreen, styleDashed|styleNoTitle ) ;
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g,
Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC(
C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleCandle |
styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_END();
=============================



--- In [email protected], "Tomasz Janeczko" <[EMAIL PROTECTED]> wrote:
>
> Hello,
> 
> Tools->Preferences->AFL
> increase "endless loop detection threshold".
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com


Reply via email to