Peter,

 

I have used selectedvalue in a loop earlier, and I found backtesting to be
slow, and exploration gave me unexpected (and incorrect) results. I finally
got around to writing code with other functions that were much quicker on
backtest, and gave the correct calculations/signals. I am not sure if
selectedvalue is intended to be used in loops. 

 

If anyone on the forum has used selectedvalue in loops, please do correct me
on this.

 

Rgds,

 

Pankaj

 

  _____  

From: [email protected] [mailto:[email protected]] On Behalf
Of progster01
Sent: 15 December 2009 18:43
To: [email protected]
Subject: [amibroker] Re: Are all variables Array data types?

 

  

Of course this works. arg is an array. arg[0], arg[1], etc. are scalars
(numbers).

You can stuff an array and then cherry-pick numbers from it, no problem. One
thing to keep in mind though is that if you are using an index to do your
cherry picking, (e.g. arg[ndx] ) the index needs to be always defined at the
point you are using it.

Further, if you are looping over that index, then within the loop all the
unadorned array names you use will be expected to have subscripts. IOW, you
can't write "naked" array code inside a for loop (though you can pass arrays
to functions and get them back).

The way I've come to look at it is that when I have a loop in my code( any
loop, not just a 0 -> (BarCount - 1) loop ), I am in a "loop environment"
for the duration of the loop, and must alter my authorship accordingly.

--- In amibro...@yahoogrou <mailto:amibroker%40yahoogroups.com> ps.com,
"reefbreak_sd" <reefbreak...@...> wrote:
>
> Not to beat this to death, but I have used 
> arg[0] = 3.14159
> arg[1] = sqrt(2)
> arg[2] = 2.7182
> arg[3] = 1.61803
> to refer to numbers - not arrays. Then they will work in 'if' statements
like:
> 
> if(arg[2] > arg[1]) 
> arg[4]=1;
> else
> arg[4]=0;
> 
> 
> ReefBreak
> 
> 
> 
> 
> 
> --- In amibro...@yahoogrou <mailto:amibroker%40yahoogroups.com> ps.com,
"peter843" <yahoogroups@> wrote:
> >
> > I thought it over and I see now why it is good for 'iif' to return an
array.
> > 
> > The 'selectedvalue' will take care of my needs.
> > 
> > --- In amibro...@yahoogrou <mailto:amibroker%40yahoogroups.com> ps.com,
"peter843" <yahoogroups@> wrote:
> > 
> > > What puzzles me is that "x = IIf( Close > Open, 1, 0 );" seems to
create an array variable even though it is being assigned a 1 or 0.
> >
>



Reply via email to