Hugh,

You can just dereference the array to pull out a specific bar value.  
Just use myArray[i] where myArray is any array and i is any valid bar 
index.

e.g.

for (i = 0; i < BarCount; i++) {
  myScaler = myArray[i];
}

Your formula suggests: rtn = Close[i]/Open[i] - 1 though it is not 
clear what bar index you would be starting with.

Also, if I interpret your requirements correctly, you may find the 
following post helpful, which provides a working script to persist 
ordered ranks into composites ~Position1, ~Position2, etc. such that 
~Position1 holds the top ranked value at each bar, ~Position2 holds 
the second top ranked value at each bar, etc.

http://finance.groups.yahoo.com/group/amibroker/message/114739?
threaded=1

Mike

--- In [email protected], "Joe Landry" <[EMAIL PROTECTED]> wrote:
>
> Hugh 
> Check out the AFL function  LastValue(array,code); 
> Hope this helps
> JOE  L. 
> 
>   ----- Original Message ----- 
>   From: huandy631 
>   To: [email protected] 
>   Sent: Wednesday, February 20, 2008 10:09 AM
>   Subject: [amibroker] Staticvarset...setting last price in a loop
> 
> 
>   hello
> 
>   I am trying to find the last price in an array and set it as a 
static 
>   variable. Problem is that staticvarset(...) will only take a 
value, 
>   and not an array.
> 
>   More specifically
>   1 loop through 100 bars
>   2 loop through 40 stocks
>   3 for first bar find daily rtn (close/open-1) and set it to 
>   staticvariable for each stock
>   4 rank stocks based on daily rtn using a bubble sort loop
>   5 write the rank to a composite
>   6 loop through next 99 bars and repeat steps 3 to 5
> 
>   if anyone know how i can do this using valuewhen etc pse let me 
know 
>   before i go crazy...
> 
>   rgds
> 
>   Hugh
>


Reply via email to