Well, I wonder why U think its contrary to Your expectations :).

Take any function, as periods having 2nd argument.

HHV(Close, BarsSince(TimeNum()<093000)) ;
HHVBars(Close, BarsSince(TimeNum()<093000)) ;
LLV(Close, BarsSince(TimeNum()<093000)) ;
LLVBars(Close, BarsSince(TimeNum()<093000)) ;

TEMA , EMA and ................... 

i have almost executed all of them .And yeah , u can replace BarsSince with any 
other array returning function. 

I think , it should be always the case that a function with a "periods" 
argument Should accept an array, It's not about the array , its about AMIBROKER 
behaviour. 

Whenever we define array anywhere in afl, amibroker automatically points it to 
current barindex element while displaying the result for that current bar. 

Infact i was wondering even , why we dont have array in the Loop statements as 
well, just like , 
For(i=0; i < BarsSince(TimeNum()<093000) , i++) is still invalid for amibroker.
while the same BarIndex() function , when we put in other AFL statements, will 
surely give a scalar value at that particular bar.
Like , 

TEMA(Close, BarIndex()) ;
or 
MA(Close, BarIndex()) ;

I guess this issue must have come into picture earlier, its pretty obvious.
I hope tomaz is reading this thread.

Regards.....


--- In [email protected], "Mike" <sfclimb...@...> wrote:
>
> Interesting. I ran a quick test and it seems to suggest that Sum does in fact 
> take an array as second argument, contrary to expectations.
> 
> It would appear that you are correct, with respect to Sum. Though it is not 
> always the case that a function with a "periods" argument will accept an 
> array. For those that don't, you will have to find another approach.
> 
> Here's my test:
> 
> Test = Sum(1, Cum(1));
> Fixed = Sum(1, 5);
> 
> Plot(Test, "Test", colorRed, styleLine);
> Plot(Fixed, "Fixed", colorBlue, styleLine);
> Title = "Bar: " + BarIndex() + ", Test: " + Test + ", Fixed: " + Fixed;
> 
> If Sum did not accept an array, but was instead substituting some fixed 
> number (e.g. last element of the array), then both Plots should result in 
> flat lines. However, the test clearly shows that the Test plot rises at a 45 
> degree angle indicating that the period is different at each bar. Compare 
> that to the Fixed plot which is constant at a level of 5.
> 
> Mike
> 
> --- In [email protected], "aaryan111" <aaryan111@> wrote:
> >
> > I guess, sum() is behaving the ideal way :), 
> > 
> > The most important thing here is, 
> > AMIBROKER being an array processing language, calculates all the elements 
> > of array , but at any given active bar, it fetches the current value from 
> > the whole arry index and shows it to us,Presumably using some barindex kind 
> > of mechanism internally.
> > 
> > When we put close, open or any array in any afl , like ((close + open + 
> > High  + Low )/4= MAVG),amibroker produces output based on the current value 
> > of that array, we dont need to specify current index of that array (scalar 
> > value) to get output at any current bar,it manages it intenally.
> > 
> > Here its impotant to not that, its IRRELEVANT if we use array in a Function 
> > or simply put it in any statement in afl, it fetches a scalar value out of 
> > that produced array to show it to us.
> >  
> > when I put SUm(close,Barssince()) It ideally fetches the current element of 
> > BarsSince array and place it over ther. 
> > 
> > This is the ideal way. Sum() is behaving the IDEAL way. 
> > infact every other function,
> > let it be , 
> > MA(Close,BarsSince(TimeNum() < 093000)); 
> > or any other function, having Periods, as a second argument.
> > 
> > While in Stdev(),it simply goes against the normal behaviour. 
> > it should infact, in MUST , point to the current active element of the 
> > Barssince(), let it be a 0 or any other value, its irrelevant, its still a 
> > scalar.
> > and it simply doesnt do that!.
> > 
> > i think i have made my point clear now.
> > 
> > Wave : Lastvalue() will surely fetch the last element of the array, but i 
> > cant use it while testing it offline, i will get all future values of that 
> > array, its all fine if i have to use it while online updation.
> > 
> > 
> > 
> > Regards...
> > 
> > 
> > --- In [email protected], "wavemechanic" <olesmithy@> wrote:
> > >
> > > I'm fairly sure that the only way you will get StDev() to accept 
> > > BarsSince() in the 2nd argument without complaining is to force the 
> > > return of a number by use of LastValue() or SelectedValue().  I don't 
> > > know why Sum() is not complaining when BarsSince() is used.  
> > > 
> > > In the Sum() case, I think that BarsSince( TimeNum ... ) is returning a 
> > > constant array based on the bar you select, including the last bar if no 
> > > bar is selected.  If so, that would work OK but does not explain why 
> > > StDev() does not work.
> > > 
> > > For Sum(), if you replace TimeNum() with another array generator, for 
> > > example, MA( C, 13 ) == ...., Sum() still does not complain but 
> > > BarsSince() returns 0 (I believe) and, hence, Sum() is 0.
> > > 
> > > You might have stumbled onto a unique situation but I would not assume 
> > > that it can be generalized and would always go for ensuring the return of 
> > > a number from the 2nd argument whether or not the above is correct.
> > > 
> > > Bill
> > >   ----- Original Message ----- 
> > >   From: aaryan111 
> > >   To: [email protected] 
> > >   Sent: July 14, 2010 3:08 PM
> > >   Subject: [amibroker] Re: Sum and Stdev , wierd behaviour of stdev
> > > 
> > > 
> > >   Hi , thanx for the feedback wave.
> > >   its Syntax is basically to put Period as 2nd argument.
> > >   When u put an array in SUM() as 2nd argument, it will take the 
> > > corresponding scalar frm that array and apply it as a filter.
> > > 
> > >   i have successfully executed this 
> > > 
> > >   Sum(Close,BarsSince(TimeNum()>092400));
> > > 
> > >   regards
> > > 
> > > 
> > >   --- In [email protected], "wavemechanic" <olesmithy@> wrote:
> > >   >
> > >   > Neither takes array as 2nd.  See syntax in Users Guide.
> > >   >   ----- Original Message ----- 
> > >   >   From: aaryan111 
> > >   >   To: [email protected] 
> > >   >   Sent: July 12, 2010 3:41 PM
> > >   >   Subject: [amibroker] Sum and Stdev , wierd behaviour of stdev
> > >   > 
> > >   > 
> > >   >   Hi Everybody, 
> > >   > 
> > >   >   Both Sum() and Stdev() Functions Have same Arguments Structure.but 
> > > when i put 
> > >   >   Sum(Close,BarsSince(TimeNum()>092400))
> > >   >   it executes successfully,while 
> > >   >   Stdev(Close,BarsSince(TimeNum()>092400))
> > >   >   gives a warning " Function Expects Different type of argument here 
> > > " . 
> > >   > 
> > >   >   as far as i understand , both can take array as 2nd argument and 
> > > amibroker will automatically fetch the current running index value of 
> > > that array as the 2nd argument, same as it does with other functions. 
> > >   > 
> > >   >   one can put any other function returning array like barindex() in 
> > > 2nd argument , result will be same. 
> > >   > 
> > >   >   Any suggestions??
> > >   > 
> > >   >   Regards,
> > >   > 
> > >   > 
> > >   > 
> > >   >   ------------------------------------
> > >   > 
> > >   >   **** IMPORTANT PLEASE READ ****
> > >   >   This group is for the discussion between users only.
> > >   >   This is *NOT* technical support channel.
> > >   > 
> > >   >   TO GET TECHNICAL SUPPORT send an e-mail directly to 
> > >   >   SUPPORT {at} amibroker.com
> > >   > 
> > >   >   TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > >   >   http://www.amibroker.com/feedback/
> > >   >   (submissions sent via other channels won't be considered)
> > >   > 
> > >   >   For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > >   >   http://www.amibroker.com/devlog/
> > >   > 
> > >   >   Yahoo! Groups Links
> > >   >
> > > 
> > > 
> > > 
> > > 
> > >   ------------------------------------
> > > 
> > >   **** IMPORTANT PLEASE READ ****
> > >   This group is for the discussion between users only.
> > >   This is *NOT* technical support channel.
> > > 
> > >   TO GET TECHNICAL SUPPORT send an e-mail directly to 
> > >   SUPPORT {at} amibroker.com
> > > 
> > >   TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > >   http://www.amibroker.com/feedback/
> > >   (submissions sent via other channels won't be considered)
> > > 
> > >   For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > >   http://www.amibroker.com/devlog/
> > > 
> > >   Yahoo! Groups Links
> > >
> >
>


Reply via email to