Bruce,

>LastValue() returns a scalar

Right you are!   Thanks for correcting what I mis-wrote.

- Progster

--- In [email protected], "Bruce" <bru...@...> wrote:
>
> Rob, Progster -
> 
> I think that you will find that LastValue() returns a scalar.  It is 
> nit-picking in this situation, but can be important in others.  The 
> "auto-promotion" of AFL scalar variables to arrays in certain situations can 
> make this confusing.
> 
> There are a couple of ways to show this.  The following Exploration is an 
> example -
> 
> 
> scalar     = 1;
> array      = C - 1;
> Lastval    = LastValue( array );
> //  Use of lastval in a function that must have a scalar value
> test       = Param( "test", Lastval, 0, 1000, 1 );
> Filter     = Status( "lastbarinrange" );
> AddTextColumn( typeof( scalar ), "TypeOf(scalar)", 1.0 );
> AddTextColumn( typeof( array ), "TypeOf(array)", 1.0 );
> AddTextColumn( typeof( Lastval ), "TypeOf(lastval)", 1.0 );
> 
> 
> 
> BTW, I agree that LastValue() could be considered looking into the future.
> 
> 
> 
> --- In [email protected], "Rob" <sidhartha70@> wrote:
> >
> > LastValue() does actually return an array... that as progster correctly 
> > says is filled with the last value of "SourceArray"... however, AFL knows 
> > this and treats it as a number... i.e. it can be passed to an If() 
> > statement...
> > 
> > Again, progster is right, LastValue() can look into the future from a 
> > backtesting perspective... because it by definition uses the 'lastvalue' of 
> > SourceArray.
> > 
> > However, this is not an issue if you are using LastValue() on the RHS of 
> > the chart in the correct context.
> > 
> > --- In [email protected], "progster01" <progster@> wrote:
> > >
> > > Consider this:
> > > 
> > >   Result = LastValue( SourceArray ) ;
> > > 
> > > Result is an array, all of the values in which are identical and equal to 
> > > the single final value of SourceArray.
> > > 
> > > Hence, at all locations in Result, there is a value that represents the 
> > > "far in the future" last value of SourceArray.
> > > 
> > > Remember, your arrays are each constructed beginning to end at their 
> > > point of definition in your AFL.   An array defined earlier in your code 
> > > is completely constructed before arrays defined later in your code even 
> > > exist yet.
> > > 
> > > In case you are thinking that all arrays are constructed in parallel on a 
> > > bar-by-bar basis, they are not.
> > > 
> > > 
> > > --- In [email protected], Rick Osborn <ricko@> wrote:
> > > >
> > > > Caveat: since this function fills an entire data array with the 
> > > > last value of another array, it allows a formula to look into the 
> > > > future.  so if there are repeated events (buy signals and sell 
> > > > signals), I'm not sure if lastvalue sees any but the last one.  Plus I 
> > > > worry about the Caveat!!
> > >
> >
>


Reply via email to