PureBytes Links
Trading Reference Links
|
Hi JD, Thanks for replying to both of my posts. I put together a data map of the QP3 data that can be accessed from AB. I posted it on this board under "GetExtraData Map" about a week ago (I think). I like your functions below and I'll give them a shot tonight. I think I've come up with a solution to getting the EPS and Sales numbers out of the array, but the further back in time I go the more discrepencies I get between what I return and what SPP reports. Have you noticed any discrepencies between what you get and what SPP reports? I hesitate with solutions that look back in time a certain number of days, as your code seems to suggest, only because most companies don't seem to report very consistently. Then again, many of the companies in the SPP database haven't reported for several quarters, many for several years. I've coded to exclude those stocks from my exploration, but maybe your code avoids that?
Jeff
JD Fagan <jd.fagan@xxxxxxxxx> wrote: Not sure if this is useful to you, but I had written these functions awhile back which demonstrates an alternative non-looping way to look back into the array based QP data fields that should only change by quarter:
THOUSAND = 1000; MILLION = THOUSAND * THOUSAND;
function getSalesMrq() { return GetExtraData("Sales") * MILLION; } function getEPSMrq() { return GetExtraData("EPS"); } function getSalesTtm() { //Cycle through last 4 quarters and add up the getSalesMrq for TTM qtrDays = 260 / 4; salesMrq = getSalesMrq(); return salesMrq + Ref(salesMrq, -1 * qtrDays) +
Ref(salesMrq, -2 * qtrDays) + Ref(salesMrq, -3 * qtrDays); } function getEPSTtm() { //Cycle through last 4 quarters and add up the getSalesMrq for TTM qtrDays = 260 / 4; epsMrq = getEPSMrq(); return epsMrq + Ref(epsMrq, -1 * qtrDays) + Ref(epsMrq, -2 * qtrDays) + Ref(epsMrq, -3 * qtrDays); }
JD
--- In amibroker@xxxxxxxxxxxxxxx, "fatboycato" <fatboycato@xxx> wrote: > > Eureka! I think I figured it out. For those of you with QP3 data, > try this code to return the last 3 EPS reports: > > EPS=GetExtraData("EPS"); > Filter=1; > b=BarCount; > i=1; > EPS0=EPS[b-1]; > > do > { > EPS1=EPS[b-i]; > i++; > } > while (EPS1==EPS0 AND
i<BarCount); > > do > { > EPS2=EPS[b-i]; > i++; > } > while (((EPS2==EPS0) OR (EPS2==EPS1)) AND i<BarCount); > > > //EPS1=Ref(EPS,-i); > AddColumn(EPS0,"EPS0"); > AddColumn(EPS1,"EPS1"); > AddColumn(EPS2,"EPS2"); > > I really can't believe it was this simple, so something's probably > wrong. But it seems to work. It could probably be more elegant, but > I'm happy with what I've got. I imagine we could build in the Sales > array as well. Once we know the value of i, everything else should > fall out and a near-Canslim exploration could be done. > > Any suggestions would be recommended. > --- In amibroker@xxxxxxxxxxxxxxx, "fatboycato" <fatboycato@> > wrote: > > > > Well, I'm stumped. I've tried just about every way I could think > of >
> to get this accomplished, but I'm simply not smart enough to do > it. > > Hopefully, someone here is. > > > > I can't seem to iterate through an array to discover if a value is > > different from a base value. For example: suppose your array looks > > like this: > > 0,0,0,0,0,0,0,0,1,1,1,1,1 > > > > I want to look through that array and return "1" the first time it > > changes from 0 to 1. The problem is that arrays can't show up in > any > > kind of loop. I don't know the 1 is there, so I can't just look > > for "1". I need to look through the array and return the different > > value, whatever it may be. > > > > Here's an example of what the code would look like: > > > > I have an array. > > Look at the first number in the array and call it "x". > > Look at the second number in the array. If
it's the same as "x", > > then look at the third number. If it's still the same, look at the > > fourth number, etc... > > Once you get to a number that is not "x", call that number "y". > > Stop looking for something other than "x". > > > > Any ideas? The Ref() function obviously won't work because it > > returns an array. Is there another function that works like Ref(), > > but returns a single value? > > >
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
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
YAHOO! GROUPS LINKS
|