Terry, I also want to thank you for your concise explanation to Jeff's question. For those of us afflicted with thick cranium (not diagnosing anyone else, but we all know who we are), a bit of hand- holding through the explanation of these programming concepts really helps to turn the light on.
Maybe excerpts from this thread should be added to the online reference files somewhere. I know I have added them to my personal AFL notes. Tim --- In [email protected], "Terry" <[EMAIL PROTECTED]> wrote: > > Cato, > > > > Almost. > > > > EPS is an array. AB let's you access individual array elements, called > bars (bar = day in a daily database), with [brackets]. So, EPS[i] is > just one of the days in the database for the symbol in use. You were > correct in your original assumption on that count. What you're missing > is the necessity of breaking those out into separate elements since EPS > already contains the values you want. Maybe an example is in order: > > > > Buy = C > 10 AND ESP > 20; //A simple example that buys if Price is > > $10 and EPS > 20 > > > > A backtest evaluates each bar (or the range of bars you select as dates > to test) and it knows on each day (bar) what the values are. The EPS > will change quarterly as it should. You don't really need to do anything > special to make this happen. > > -- > > Terry > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Jeff Springer > Sent: Monday, March 20, 2006 18:49 > To: [email protected] > Subject: RE: [amibroker] Re: Single Value from Array > > > > Terry, > > Thank you for your excellent reply. I think you pegged me right on. I > was under the impression that the [] subscript referenced only a single > number from that array. But you're telling me that EPS[x] is an array as > well, albeit an array with the same number repeated for however many > bars. So, if I can rephrase what you wrote, I don't need EPSx, I just > need EPS with the various values for i to pull the number I want to > manipulate out? I can understand that, and see that what I really need > is to discover the values for "i" at each change. Do I understand you > correctly? > > > > If so, do you have any recommendations for discovering the values for > "i"? Would it be much like your first post? I imagine I would use > different variables for each occurrence of a change, but I probably > shouldn't start assuming again. > > > > Again, your reply was very clear and clarifies a lot of questions I had. > Thank you, again. > > > > Cato > > Terry <[EMAIL PROTECTED]> wrote: > > Cato, > > > > I don't have QP3 so I can't get too specific, but I think you have a > basic misunderstanding on how Amibroker is supposed to work. It's very > common for people with coding experience to want AB to work with single > values. If I'm way off on understanding your issue, my apologies! > > > > AB is an array processing system. For example, you shouldn't mix arrays > and single values as you have done in your Do loop. You have assigned a > single value to an array with EPS0 = EPS[b-1]. So, you have assigned the > same value to the entire EPS0 array. This array is the same size array > as the ticker you are working with. Now you have 4 arrays, all barcount > long, with the same value in each one. I think you are thinking you have > an array that is one-quarter long (about 66 days), but it is not. > Besides, you already have all the data in the original EPS array and > it's already arranged by quarter. In abbreviated form you have this: > > > > Array Values --> > > EPS 11111111111111122222222222222233333333333333334444444444444444 > > EPS0 11111111111111111111111111111111111111111111111111111111111111 > > EPS1 22222222222222222222222222222222222222222222222222222222222222 > > EPS2 33333333333333333333333333333333333333333333333333333333333333 > > EPS3 44444444444444444444444444444444444444444444444444444444444444 > > > > You need to get comfortable with data being in arrays and each bar > simply represents the status "as of that bar". It really works well this > way. Your EPS has a value everyday. If it doesn't change for an entire > quarter, you simply have the same value everyday. Then, on the day it > changes, you'll have the new value for the next 66 days. On any given > day you can simply refer to your EPS or Sales array and you will have > the correct value. AB "knows" which day you are "on". Same answer for > your original question about Ref(). It does refer to a single value -x > bars in the past, it's just an array of single references so on any > given day, the array "knows" the answer -x bars previously. > > > > Again, sorry if I am explaining something you already know. > > -- > > Terry > > -- > > Thank you very much for replying, Terry. That's pretty much what I > discovered over the weekend. Would you mind looking at my response to > Bill Barnard and providing your input? > > Terry <[EMAIL PROTECTED]> wrote: > > Try this: > > i = 0; //Start at beginning of array > do i++; while (myArray[i-1] == myArray[i]) > //After this line executes, the value of i = the first changed array > element. > -- > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Jeff Springer > Sent: Monday, March 20, 2006 10:35 > To: [email protected] > Subject: Re: [amibroker] Re: Single Value from Array > > > > 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 <[EMAIL PROTECTED]> wrote: > > --- In [email protected], Jeff Springer <fatboycato@> 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! Mail > Use > <http://us.rd.yahoo.com/mail_us/taglines/pmall2/*http:/photomail.mail. ya > hoo.com> Photomail to share photos without annoying attachments. > > 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 > <http://groups.yahoo.com/gads? t=ms&k=Investment+management+software&w1=I > nvestment+management+software&w2=Real+estate+investment+software&w3=In ve > stment+property+software&w4=Software+support&w5=Real+estate+investment +a > nalysis+software&w6=Investment+software&c=6&s=200&.sig=_XXUzbE9l5lGlZN cM > u4KNQ> management software > > Real > <http://groups.yahoo.com/gads? t=ms&k=Real+estate+investment+software&w1= > Investment+management+software&w2=Real+estate+investment+software&w3=I nv > estment+property+software&w4=Software+support&w5=Real+estate+investmen t+ > analysis+software&w6=Investment+software&c=6&s=200&.sig=5_sgDczz3ArKGM tJ > 9tFSJA> estate investment software > > Investment > <http://groups.yahoo.com/gads? t=ms&k=Investment+property+software&w1=Inv > estment+management+software&w2=Real+estate+investment+software&w3=Inve st > ment+property+software&w4=Software+support&w5=Real+estate+investment+a na > lysis+software&w6=Investment+software&c=6&s=200&.sig=_N6zcwefgp4eg5n6o X5 > WZw> property software > > > Software > <http://groups.yahoo.com/gads? t=ms&k=Software+support&w1=Investment+mana > gement+software&w2=Real+estate+investment+software&w3=Investment+prope rt > y+software&w4=Software+support&w5=Real+estate+investment+analysis+soft wa > re&w6=Investment+software&c=6&s=200&.sig=MJ2jP31F3n64RDZkDadU8w> > support > > Real > <http://groups.yahoo.com/gads? t=ms&k=Real+estate+investment+analysis+sof > tware&w1=Investment+management+software&w2=Real+estate+investment+soft wa > re&w3=Investment+property+software&w4=Software+support&w5=Real+estate+ in > vestment+analysis+software&w6=Investment+software&c=6&s=200&.sig=GmF8P lA > JASx0wrSaX5-Zlw> estate investment analysis software > > Investment > <http://groups.yahoo.com/gads? t=ms&k=Investment+software&w1=Investment+m > anagement+software&w2=Real+estate+investment+software&w3=Investment+pr op > erty+software&w4=Software+support&w5=Real+estate+investment+analysis+s of > tware&w6=Investment+software&c=6&s=200&.sig=aMgGsKT4w29dMAYUzQUKzg> > software > > > > _____ > > YAHOO! GROUPS LINKS > > > > * Visit your group "amibroker > <http://groups.yahoo.com/group/amibroker> " on the web. > > > * To unsubscribe from this group, send an email to: > [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> > > > * Your use of Yahoo! Groups is subject to the Yahoo! > <http://docs.yahoo.com/info/terms/> Terms of Service. > > > > _____ > ------------------------ Yahoo! Groups Sponsor --------------------~--> Try Online Currency Trading with GFT. Free 50K Demo. Trade 24 Hours. Commission-Free. http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM --------------------------------------------------------------------~-> 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 <*> To visit your group on the web, go to: http://groups.yahoo.com/group/amibroker/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
