LastValue
|
Trading system toolbox |
SYNTAX | LastValue(ARRAY, lastmode = True ) |
RETURNS | NUMBER |
FUNCTION | Returns last calculated value of the specified ARRAY. The
result of this function can be used in place of a constant (NUMBER) in any
function argument. If last bar of the ARRAY is undefined or Null (e.g., only 100-days loaded and you request the last value of a 200-day moving average) then the lastvalue function returns zero. Caveat: since this function gets the LAST bar value of the array, it allows a formula to look into the future, if current bar is not the last one.
lastmode parameter: In pre-4.08.1 versions commentary/interpretation/tooltip code evaluation was somewhat special because LastValue returned in fact not the last but the value of array at selected point (by vertical line or by tooltip) This caused some problems in displaying indicator values that used LastValue in its construction. To address this now LastValue used in Commentaries by default returns true last value. So you should modify your existing commentary/interpretation code that used LastValue to use now SelectedValue( array ) function to maintain the same behaviour. Alternatively you can use LastValue( array, 0 ). |
EXAMPLE | |
SEE ALSO | SELECTEDVALUE() function |
The LastValue function is used in the following formulas in AFL on-line library:
See updated/extended version on-line.