How to determine if the last 10 or 15 values of an array (say Close) is descending or ascending please?

I just need a way to find if the last 10 or 15 period Close values are actually in ascending or descending order, if say the values are ascending I'm looking for a function to return a boolean of True (for ascending values) or False (for descending values).

I have referred the two flavours of Sort() methods available on the above query of mine, but this does not solve my requirement. I have also referred the MxSort() and its usage means a Matrix from a String is to be created and MxSort() method is to be applied on the string. This also does not solve my requirement.

I'm not expecting these values in Exploration through SetSortColumns() methods either, for displaying these in Columns.

As I'm learning AFL, I could have possibly missed out to refer some AB methods or forum topics which could be already there.. Please help.

Thanks,
S Srikanth

That is super simple and does not need sorting at all.

You need to detect if one bar is ascending and then detect if sum over last period of bars is all ascending:

Ascending = Close > Ref( Close, -1 );
AscendingInLast10Bars = Sum( Ascending, 10 ) == 10;
8 Likes

OMG !! Totally a big surprise and these 02 lines of code is just a piece of miniature.
I have a way way far to go in AFL programming.
Thank you so much !
S Srikanth

1 Like