[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Re: Are all variables Array data types?


  • Date: Tue, 15 Dec 2009 21:00:53 +0530
  • From: "Pankaj Sharma" <psharma@xxxxxxxxxxxxxx>
  • Subject: RE: [amibroker] Re: Are all variables Array data types?

PureBytes Links

Trading Reference Links



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: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of progster01
Sent: 15 December 2009 18:43
To: amibroker@xxxxxxxxxxxxxxx
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 amibroker@xxxxxxxxxps.com, "reefbreak_sd" <reefbreak_sd@...> 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 amibroker@xxxxxxxxxps.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 amibroker@xxxxxxxxxps.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.
> >
>



__._,_.___


**** 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/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___