The last line variable(NumberOfBarsBetweenStartTnAndEndTn ) is not getting the number of bar count values.
Can any one please let me know where i did the mistake in the code.
Thanks @travick.. In the forum @portfoliobuilder given the idea of get the number of bars in Daily interval using LookUp function by converting values to _DT .But in my case i want to do in intraday. So can you tell me how to convert StartTn,EndTn variables(which are in DateTime format) of my code to make use of LookUp function.
Thanks in advance.
I am a beginner in AFL. My intention is to count the number of bars up to now, in a given intraday . Suppose at 11:00 AM if i run the afl, then it should display number of bars so far created from starting of the day .
Hi @travick.
Please find the attachment.
I am looking for each and every time interval how many bars existed up to present(please see the expected column in the image). But the variable "bs" gives the total count. I am going to use this count in for loop . Yes of course arrays are much faster than loops. I am not using the barcount.
I am not able to use the "barsbetween " variable in for loop because it is a array.Can you let me know how to find count .So that i can use that in for loop.
Hi @travick .
Now i am able to fetch as expected.Thanks for your support.But i am not able to use the "bs" in for loop because it is an array. How to fetch the value as a number .
price=0;
for ( i =1;i<=bs ;i++)
{
Condition =some condition;
price = price+ValueWhen(Condition,C,i);
}
bs // This is of type Array,
bs[x] // where 0 <= x < BarCount
// in this case use lastvalue
lbs = LastValue( bs );
for ( i =1; I <= lbs; i++)
// OR
bc = BarCount - 1;
for ( i =1; I <= bs[bc]; i++)
// OR bc can be some value of your interest less than BarCount
You should state what your are really trying to do,
if you have a lot of iterations, using Array functions is detrimental to performance.
See ValueWhen() in that loop, among other things like some condition.
@dav perhaps you should try implementing the suggestions you've already been given instead of asking yet another forum member to write code for you. The TimeFrameGetPrice() function will get you what you want with ONE CALL.