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. The value of 5 (backtest) is used also in some other contexts (like code check and profile). Therefore any new code should use ActionEx to get more detailed/precise information
- "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
- actionIndicator - when indicator is being repainted
- actionCommentary (NOTE: commentary only, not interpretaion nor tooltip)
- actionScan - when AA Scan is performed
- actionExplore - when AA exploration is performed
- actionBacktest (NOTE backtest only, no optimization)
- actionPortfolio (2nd phase of portfolio backtest (custom backtest)
- reserved for future use
- reserved for future use
- reserved for future use
- - actionExAAShowArrows - when AA "Show arrows" command is used
- actionExAAParameters - when AA "Parameters" dialog is displayed/updated
- actionExEditVerifyFormula - when AFL editor verifies syntax
- actionExOptimizeSetup - when Optimize() parameters are read (to setup optimization engine)
- actionExOptimizeBacktest - when Backtest is performed as a part of optimization process
- actionExOptimizePortfolio - when portfolio-backtest phase (CUSTOM backtester) is performed as a part of optimization process
- actionExTooltip - when tooltip for given chart is being displayed/updated
- actionExInterpret - when the Interpretation window is being updated
- 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. Visible bar may potentially include "blank" future bars (past the last bar in the array) as defined in preferences
- "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)
- "quickaflfirstdatabar", "quickafllastdatabar" - This feature is for internal use only.
These are bar indexes of actual underlying compressed quotation array that make up AFL's array[ 0 ] and array[ BarCount - 1]
|
| 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:
|