Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

A-Z Index | Category Index |

STATUS
- get run-time AFL status information

Miscellaneous functions
(AFL 1.65)


SYNTAX status( ''statuscode'' )
RETURNS ARRAY
FUNCTION Returns run-time status of the analysis engine. Supported status codes:
  • "stocknum" - gives you the ordinal number of currently analysed symbol
  • "action" - gives information in what context given formula is run: 1 - INDICATOR, 2 - COMMENTARY, 3 - SCAN, 4 - EXPLORATION, 5 - BACKTEST / OPTIMIZE, 6 - portfolio backtest
  • "ActionEx" (new in 5.20) - more detailed information about action that triggered AFL execution. Note that 5 first codes are the same as Status("action") but scope is limited to 'core' meaning (see notes below).
    Possible values
    1. actionIndicator - when indicator is being repainted
    2. actionCommentary (NOTE: commentary only, not interpretaion nor tooltip)
    3. actionScan - when AA Scan is performed
    4. actionExplore - when AA exploration is performed
    5. actionBacktest (NOTE backtest only, no optimization)
    6. actionPortfolio (2nd phase of portfolio backtest (custom backtest)
    7. reserved for future use
    8. reserved for future use
    9. reserved for future use
    10. - actionExAAShowArrows - when AA "Show arrows" command is used
    11. actionExAAParameters - when AA "Parameters" dialog is displayed/updated
    12. actionExEditVerifyFormula - when AFL editor verifies syntax
    13. actionExOptimizeSetup - when Optimize() parameters are read (to setup optimization engine)
    14. actionExOptimizeBacktest - when Backtest is performed as a part of optimization process
    15. actionExOptimizePortfolio - when portfolio-backtest phase (CUSTOM backtester) is performed as a part of optimization process
    16. actionExTooltip - when tooltip for given chart is being displayed/updated
    17. actionExInterpret - when the Interpretation window is being updated
    18. actionExInit - when AA needs to initialize QuickAFL bars required information and/or formula contains functions changing general AA options

    NOTE: for backward compatiblity with all formulas you have written already, the codes for Status("action") did NOT change .
  • "rangefromdate", "rangetodate" - return current auto-analysis From-To range as DateNums
  • "rangefromtime", "rangetotime" - return current auto-analysis From-To range as DateNums
  • "barinrange" - returns 1 when current bar is within current auto-analysis From-To range
  • "barvisible" - (custom indicators only) returns 1 when current bar is visible in current view
  • "firstbarinrange" and "lastbarinrange". They return 1 (or True) on the first/last bar of analysis range.
  • "buydelay", "selldelay", "shortdelay", "coverdelay" - return delays set in the Settings window
  • "firstbarintest" and "lastbarintest" - similar to "firstbarinrange" and "lastbarinrange" but they return the settings of last BACKTEST/OPTIMIZATION and intermediate scans/explorations do not affect them
  • "firstvisiblebar", "lastvisiblebar", "firstvisiblebarindex", "lastvisiblebarindex" - return bar number or bar index of first/last visible bar. Available in indicator mode only.
  • "redrawaction" - returns 0 (zero) for regular refreshes, and 1 for refreshes triggered via RequestTimedRefresh().
  • "pxwidth" - returns pixel width of chart window pane (indicators only, low-level gfx) (AmiBroker 4.94 or higher)
  • "pxheight" - returns pixel height of chart window pane (indicators only, low-level gfx) (AmiBroker 4.94 or higher)
  • "axisminy" - retrieves the minimum (bottom) value of Y axis (indicators only, low-level gfx)
  • "axismaxy" - retrieves the maximum (top) value of Y axis (indicators only, low-level gfx)
  • "pxchartleft" - returns x-coordinate of top-left corner of chart area
  • "pxcharttop" - returns y-coordinate of top-left corner of chart area
  • "pxchartright" - returns x-coordinate of bottom-right corner of chart area
  • "pxchartbottom" - returns y-coordinate of bottom-right corner of chart area
  • "pxchartwidth" - returns width chart area (right-left)
  • "pxchartheight" - returns width chart area (bottom-top)
EXAMPLE Example 1:

if( Status("redrawaction") ==1 )
{
_TRACE("nTIMED REFRESH"+Now());
}
RequestTimedRefresh(1);

Example 2 (low-level graphic overlay + pixel co-ordinate conversion):

_SECTION_BEGIN("GfxOverlaySampleNew");

function GetVisibleBarCount()
{
 lvb =
Status("lastvisiblebar");
 fvb =
Status("firstvisiblebar");

 return Min( Lvb - fvb, BarCount - fvb );
}

function GfxConvertBarToPixelX( bar )
{
 lvb =
Status("lastvisiblebar");
 fvb =
Status("firstvisiblebar");
 pxchartleft =
Status("pxchartleft");
 pxchartwidth =
Status("pxchartwidth");

 return pxchartleft + bar  * pxchartwidth / ( Lvb - fvb + 1 );
}

function GfxConvertValueToPixelY( Value )
{
 local Miny, Maxy, pxchartbottom, pxchartheight;

 Miny =
Status("axisminy");
 Maxy =
Status("axismaxy");

 pxchartbottom =
Status("pxchartbottom");
 pxchartheight =
Status("pxchartheight");

 return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy - Miny ) );
}



Plot(C, "Price", colorBlack, styleHistogram );

GfxSetOverlayMode(0);
GfxSelectSolidBrush( colorRed );
GfxSelectPen( colorRed );

AllVisibleBars = GetVisibleBarCount();
fvb =
Status("firstvisiblebar");

for( i = 0; i < AllVisibleBars ; i++ )
{
   x = GfxConvertBarToPixelX( i );
   y = GfxConvertValueToPixelY(
C[ i + fvb ] );

  
GfxRectangle( x-1, y-1, x + 2, y+1 );
}

//SetChartBkGradientFill( ColorRGB(200,200,200), ColorRGB( 255,255,255) );
_SECTION_END();

SEE ALSO RequestTimedRefresh() function

References:

The STATUS function is used in the following formulas in AFL on-line library:


 


About | Privacy | Terms of Use | Contact information
Copyright © 2003 AMIBROKER.COM