User not reading docs, was: I am not seeing correct values in watch window

i can see right values for the lastvisiblebar but not for the firstvisiblebar in the debugger.

i had set initialized the values properly as you can see from screenshot.
the entire code is here.

_SECTION_BEGIN( "Price" );
SetChartOptions( 0, chartShowArrows | chartShowDates );
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );

// mark hh7
rang = High - Low;
hr = IIf( rang == HHV( rang, 7 ), shapeDigit7 , shapeNone );
PlotShapes( hr, colorBlue, 0, L, -20 );
nr = IIf( rang == LLV( rang, 7 ), shapeDigit7 , shapeNone );
PlotShapes( nr, colorGreen, 0, L, -20 );

//}


Plot( ema50 = MA( C, 50 ), "50 ma" , colorBlue, ParamStyle( "Style" ) );
Periods_9 = 9;
Plot( ema9 = MA( C, Periods_9 ), "9 ma" , colorGreen, ParamStyle( "Style" ) );

Plot( C, "Close", colorDefault, styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
crosseddown = Cross( ema50, ema9 );

lowestsincecross = LowestSince( crosseddown, L, 1 );
lowerlows = L == lowestsincecross;
PlotShapes( lowerlows*shapeCircle, colorGreen, 0, L, -20 );
lvb = Status( "lastvisiblebarindex" )-1;
fvb = Status( "firstvisiblebarindex" )-1;

for( i = fvb - 1 ; i <= lvb && i<BarCount-1 && i>100 ; i++ )
{
    if( crosseddown[i] )
    {
        moveback=pulledback = False;
        movebackbar=pullbackbar = -1;

        // time to start looking for short reversals.
        if( lowerlows[i] )
        {
            // watch bars for pullback.
            if( H[i] > H[i - 1] &&   !pulledback )
            {
            pulledback=True;
            pullbackbar=i;
            PlotText( "pullback",  L[i], i,coloryellow, colorblue ) ;
            
            }
            if(pulledback && i > pullbackbar && !moveback)// move back started
            {
				if(L[i]<L[i-1])
				{
				moveback=True;
				movebackbar=i;
				
				}
				
            }
            

        }

    }

}





_SECTION_END();

The values ARE correct. If you checked the the documentation prior to posting http://www.amibroker.com/guide/afl/status.html you would see this:

‚Äúfirstvisiblebar‚ÄĚ, ‚Äúlastvisiblebar‚ÄĚ, ‚Äúfirstvisiblebarindex‚ÄĚ, ‚Äúlastvisiblebarindex‚ÄĚ - return bar number or bar index of first/last visible bar. Available in indicator mode only.

When you run the code under debugger it is run in the context of actionBacktest. ‚Äúfirstvisiblebarindex‚ÄĚ is ONLY available in the actionIndicator and can only be seen in the actual CHART pane using _TRACE, see How do I debug my formula?

1 Like