Lowestsince bar number in array



I am looping through the data. In variable px0 I have bar ID from my other calculation. I would like to know what was the lowest low since the bar ID, till the current bar in the loop.

So something like this:

for( i = 0; i < LastValue( BarIndex() ); i++ )

Can you pleas hint me how to get this value in AFL?
Thank you.



BarID you mean Barindex() ?

Rewrite this:

for( i = 0; i < LastValue( BarIndex() ); i++ )

to this:

for( i = 0; i < Barcount-1; i++ )

Look at the LLV function: https://www.amibroker.com/guide/afl/llv.html
Also the BarsSince function: https://www.amibroker.com/guide/afl/barssince.html


You are calling the array function LowestSince() inside of a bar-by-bar loop. That's generally not a good idea, so you should think about whether the looping is really necessary. If it is, then just keep track of the lowest low yourself as you iterate through the loop. If not, then keep reading.

One equal sign, =, is the assignment operator. Two equal signs, ==, is the boolean equality operator. Make sure you understand the difference.

The second argument to LowestSince() should be an array, not a scalar value or a single element of an array. Therefore, if you had ALL of your "special" bar index numbers in another array, for example mySpecialBarIDArray, then you could just do something like this (no looping required):

LowestLowSinceSpecialBar = LowestSince(BarIndex() == mySpecialBarIDArray, L);

Better yet would be if your array just contained a True value for every bar where your special condition was true. If that array was called mySpecialCondition, then you could use something like this:

LowestLowSinceSpecialBar = LowestSince(mySpecialCondition, L);

If you're not yet comfortable with AmiBroker's handling of arrays, then keep reading the documentation and reviewing the tutorials until arrays make complete and total sense to you. You cannot even begin to exploit the power of AFL until you have mastered arrays.