Thanks for the reply. I will post my problem directly. I am trying to find
the highest 5-min volume bar
for the last n days excluding today. To that end, I wrote this code:
---------------------------------------------------------------------------------------------------------------------------
// to count number of bars since morning open. example NbarsSinceOpen(5)
gives 12 at end of 1st
// 1 hour of trading. timeframe parameter is in minutes.
function NbarsSinceOpen(timeframe)
{
Currentbar = 0; Openbar = 0; //initializing local variables
n = 60/timeframe; //60 min/ timeframein min
Openbar = 9 * n;
Currentbar = round(Hour()*n + (Minute()/timeframe));
return (Currentbar-Openbar);
}
// gives highest volume bar for the last 'Lookbackperiodindays' days;
//highestvolume(3,5) gives highest 5-min volume for the last 3 days
excluding today.
function Highestvolume(Lookbackperiodindays,intradaytimeframe)
{
units = 60/intradaytimeframe;
startbar =
(Lookbackperiodindays*6.5*units)+nbarssinceopen(intradaytimeframe);
endbar = nbarssinceopen(intradaytimeframe) +1;
Highestvol = 0;
i=O;
for (i=startbar;i<endbar;i++)
{
startbar-=1;
Highestvol = Max(Ref(Volume,-startbar),Ref(Volume,-startbar+1));
}
return Highestvol;
}
printf("highestvolume is:"+Highestvolume(2,5));
--------------------------------------------------------------------------------------
when i run this i get error 6 saying in line 21 column 6.
"Error 6. Condition in IF, WHILE, FOR statements has to be Numeric or
Boolean type. You can not use array here, please use [] (array subscript
operator) to access array elements"
Thanks in advance,
Regards,
M D KUMAR
On Sat, Aug 7, 2010 at 6:55 PM, reinsley <[email protected]> wrote:
>
>
>
> Hi,
>
> Many topic about that. I kept these lines in my AB bible.
>
> Best regards
>
> Barcount vs BarIndex()
> BarCount is a numeric variable that holds just one number (the count of
> elements in array). On the other hand BarIndex() is a function that
> returns ARRAY representing consecutive index of each bar.
> BarCount IS DYNAMIC, DEPENDENT on ZOOM.
> Short advice: DO NOT use BarCount for ANYTHING else than building a for
> loop that iterates through array elements like this: for( i = 0 ; i <
> BarCount; i++ ) { array[ i ] = H[ i ] + L[ i ]; }
> Visible Bars Count
> VisibleBars = Status( "LastVisibleBarIndex" ) -
> Status("FirstVisibleBarIndex" );// gives a wrong count
> With the function GetVisibleBarCount result is correct
> function GetVisibleBarCount() { lvb = Status("lastvisiblebar"); fvb
> = Status("firstvisiblebar");
> return Min( Lvb - fvb, BarCount - fvb ); }
> VisibleBars = GetVisibleBarCount(); _TRACE("VisibleBars = "+
> VisibleBars );
>
>
> Le 07/08/2010 14:13, mdkumarz a écrit :
>
>
>
> Hi,
> my understanding is this:
> barcount counts all the bars in the chart (not just visible);
> so, i have written
> printf("bars in the chart:"+barcount);
> it's giving different number of bars when zoomed in and zoomed out.
> Does barcount look at visible bars only?
>
> Regards,
> M D KUMAR
>
>
>
>
--
Yours sincerely,
M D KUMAR
7666686533
Mumbai