Hello, is there a straight way to retrieve the bar index of the first bar used into an exploration?
I've tried using "BeginValue(array)" to workaround, but this work only after manual setting the range into the AA window.
My Idea:
I need to setup an exploration that performs some price calculations relative to the close of the day I start the exploration. To achieve this I'm considering to setup a loop from the bar that the exploration starts and then showing the result using
Filter = Status("LastBarInRange");
as filter to show only the results of the calculation.
For anyone else that could need to do the same:
I've tried this as it is but the Valuewhen function returns an array instead of an integer or a boolean values. Unfortunately the For loop - I'm gonna use - doesn't accept arrays as part of the statement.
I've tried to force the casting but it doesn't work.
Finally I've managed to give my answer pointing the last element of the array so:
bi = BarIndex();
fbr = Status("FirstBarInRange");
first_bar = Valuewhen(fbr, bi)[BarCount-1];
Really I was wondering the same because the calculations are not complex at all. But I'm not very skilled with vectorization yet... For example: how can I calculate the maximum and the minimum value of the closes between the beginning and the ending of the exploration?
I've managed doing this:
bi = BarIndex();
fbr = Status("FirstBarInRange");
lbr = Status("LastBarInRange");
firstBarArray = ValueWhen(fbr, bi);
lastBarArray = ValueWhen(lbr, bi);
firstBar = LastValue(firstBarArray);
lastBar = LastValue(lastBarArray);
top = 0;
bottom = 10^8;
for (i=firstBar; i <= lastBar; i++)
{
if (C[i] > top){top = C[i];}
if (C[i] < bottom){bottom = C[i];}
}