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

Re: [amibroker] Re: Single Value from Array



PureBytes Links

Trading Reference Links

Hi Bill,
I've figured it out, but have run into a new problem. I'm trying to get the history of EPS and Sales from the QP3 data, which are arrays. I didn't want to be this specific because I realize others don't have QP3 and I wanted to phrase my question in general terms that I think would work with all arrays. I think if you run this code on any array you should come up with the same error I got. Would you mind looking at it and giving your input?
 
EPS=GetExtraData("EPS");
b=BarCount;
i=1;
EPS0=EPS[b-1];
Sales0=Sales[b-1];
//CurrentQ-1
do
{
EPS1=EPS[b-i];
Sales1=Sales[b-i];
i++;
}
while (EPS1==EPS0 AND i<b);
//CurrentQ-2
//i=1;
do
{
EPS2=EPS[b-i];
Sales2=Sales[b-i];
i++;
}
while (((EPS2==EPS0) OR (EPS2==EPS1)) AND i<b);
//CurrentQ-3
i=1;
do
{
EPS3=EPS[b-i];
Sales3=Sales[b-i];
i++;
}
while (((EPS3==EPS2) OR (EPS3==EPS1) OR (EPS3==EPS0)) AND i<b);

There's more, but you can see the general pattern from these three. The EPS array is set up so that each bar for a quarter has the same EPS value. When a new EPS comes out, the EPS changes (ideally; since I'll only be looking at stocks where EPS increases, I don't care if the code mistakes a new EPS for an unchanged EPS). I step back through the array to search for a different EPS.
 
This code works fine, but I would prefer that "i" continues counting up rather than reseting (as I've done with the "i=1;" line before each do loop). The problem with this is that the do loop checks the condition /after/ running the "EPSx=EPS[b-i];" line. So, when it hits a stock with few bars, the code errors out with the "outside 0... (barcount-1) range" error. Is there a way to put a conditional statement in before the "EPSx=EPS[b-1];" line so that if "i" is greater than the barcount, then EPSx is null, or 0?
 
I've tried changing the "EPSx=EPS[b-i];" line to "EPSx=iif(i>b, 0, EPS[b-i];" but that still errors out. Maybe there's something more basic I'm missing.
 
Thank you, for your help.
 
Cato
Bill Barnard <wbarnard@xxxxxxx> wrote:
--- In amibroker@xxxxxxxxxxxxxxx, Jeff Springer <fatboycato@xxx> wrote:
>
> Thank you so much for replying, Bill, but I don't think that will
work for me. I was hoping to use the code in an exploration, and I
think this code will only give me the data in a debugger window,
correct? I tried assigning the _Trace calls to variables, and then
displaying that variable with AddColumn, but of course that doesn't
work. I'm too programming ignorant to know why.
>   
>   It seems to me that if Ref() calls up a specific value in the
array, then it shouldn't be returning an array, just that specific
value. I'm sure there's a good reason why it doesn't work this way, I
only wish I had some way of calling up a value from an array and
assigning that value, and only that value, to a variable.

---------------------------------------------

You are welcome. sorry it isn't what you need.

Ref() does produce an array, the original one shifted by a certain amount.

If you can describe what you are trying to do, very exactly, in
English, I am sure the code would not be too difficult.





Yahoo! Travel
Find great deals to the top 10 hottest destinations!

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 other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS