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

[amibroker] Re: Staticvarset...setting last price in a loop



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "Joe Landry" <jelandry@xxx> wrote:
>
> Hugh 
> Check out the AFL function  LastValue(array,code); 
> Hope this helps
> JOE  L. 
> 
>   ----- Original Message ----- 
>   From: huandy631 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   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
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/