Thanks guys for all your help. What I am trying to do is to write an indicator that looks back one calendar year and gets me the price. I am using the one calendar year as an example. I actually use multiple calendar period look backs. What is critical is to get the last price exactly one year back or first available data point right before that (if a year ago calendar date falls on a holiday or a weekend).
Cam --- In [email protected], "Terry" <[EMAIL PROTECTED]> wrote: > > Steve, > > > > Thanks. This gets a price, but it always gets the same price, one year > from the TDOAY (the LAST VALUE) no matter where you click. > > > > Maybe this is what the user wants so I post that code here: > > > > SetBarsRequired(100000,0); > > x = DateNum(); > > y = x - 10000; //one year ago date > > z = ValueWhen( x <= LastValue( y ), Close ); > > firstDate = x[0]; > > > > Title = "\nfirst date: " + NumToStr(x[0],1.0) > > + "\none year ago date: " + NumToStr(y,1.0) > > + "\none year ago price: " + NumToStr(z,1.2) > > + "\ncurrent price: " + C > > + "\nfirst date in " + Name() + " is " + NumToStr (firstDate,1.0,0); > > //Note date is in DateNum format. See Help on DateNum() > > -- > > Terry > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Steve Dugas > Sent: Saturday, August 19, 2006 20:50 > To: [email protected] > Subject: Re: [amibroker] Re: Newbie questins > > > > Hi Terry, maybe this? Haven't tried it... > > > > z = ValueWhen( x <= LastValue( y ), Close ); > > > > Steve > > ----- Original Message ----- > > From: Terry <mailto:[EMAIL PROTECTED]> > > To: [email protected] > > Sent: Saturday, August 19, 2006 8:34 PM > > Subject: RE: [amibroker] Re: Newbie questins > > > > Here's some code. > > > > In the Title statement, the date of the first bar of data is x[0] > > Note that this requires the SetBarsRequired due to quickAFL. (This gets > you the actual first date of the symbol data up to ~400 years ago for > daily bars.) > > > > y is, in fact, the date for one year ago. You can see it in the chart > title. > > z "should be" the one year ago price, actually it is now looking for how > many bars since the date one year ago, but it does not work. Whenever I > try to do a compare or a ValueWhen using DateNum(), BarIndex() or > BarsSince() I get empty values for the result. If you find a way, note > to use <= rather than == in case the date one year ago is a weekend or > other non-trading date. > > > > Any wizards out there that can solve this problem? > > > > SetBarsRequired(100000,0); > > x = DateNum(); > > y = x - 10000; //one year ago date > > z = BarsSince(DateNum() <= y); > > zC = Ref(C,-z); > > > > Title = "\nfirst date: " + NumToStr(x[0],1.0) > > + "\none year ago date: " + NumToStr(y,1.0) > > + "\none year ago price: " + NumToStr(zC,1.2) > > + "\ncurrent price: " + C; > > -- > > Terry > > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of tipequity > Sent: Saturday, August 19, 2006 17:50 > To: [email protected] > Subject: [amibroker] Re: Newbie questins > > > > Thanks, Terry for quick response. I am looking for exact year ago. > > Any idea on the second question? > > > > > > --- In [email protected], "Terry" <MagicTH@> wrote: > > > > > > For approximate year ago date you can just use Ref(C,-252) > > > > > > For exact year ago date...sorry, I tried several things and can't > > make > > > it work either! > > > -- > > > Terry > > > > > > -----Original Message----- > > > From: [email protected] [mailto:[EMAIL PROTECTED] > > On > > > Behalf Of tipequity > > > Sent: Saturday, August 19, 2006 16:11 > > > To: [email protected] > > > Subject: [amibroker] Newbie questins > > > > > > 1. how can refer to a calendar year ago prices (end of the day), I > > > tried the following and it did not work: > > > > > > CloseAYearAgo = Ref(C,Year()-1); > > > > > > 2. how can I get the first date for which we have data (end of the > > day) > > > > > > thanks > > > > > > Cam > > > > > > > > > > > > > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > > 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 > > > > http://groups.yahoo.com/group/amibroker/ > > > > [EMAIL PROTECTED] > > > > http://docs.yahoo.com/info/terms/ > 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/
