How to query the indicator value

@leob

Why the "Last %K" and "Last %D" not reflect any change?

because the LastValue() function returns the LAST calculated value (a NUMBER) of the array that you are passing to it as a parameter.

Add this line to your exploration:

SetSortColumns(-2);

and you will immediately see that the "last values" will correspond to the most recent row in your exploration.

Adding the above line will sort the result by the Date/Time column from the most recent one descending - i.e. the first row has the most recent bar data where from the _d and _k arrays you are getting the _dVal and _kVal NUMBERS using the LastValue() function.

You probably need to read the AFL document again and try to write some additional explorations and code samples of your own until you get it.

And maybe this other tutorial will also help you to learn when it is appropriate to use arrays and when to use the single values of them (looping). For now, try to understand well the content of the first pages.

Then search and study other code examples here in the forum and you'll see that the buy/sell triggering conditions (and/or Filter for explorations) are actually ARRAY values that change from bar to bar, so you can have multiple signals in the range selected - both intraday or over a date range.

Finally, when you will be comfortable with the above material you can read this recent topic by @Tomasz that further explains AmiBroker data types.

1 Like