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

Re: [amibroker] Re: Converting DateNum() to a string...



PureBytes Links

Trading Reference Links

Hello,

WriteVal gives "selected" date. In "AA" selected is a last bar of analysis period.
More discussion on this is included in the guide:
http://www.amibroker.com/guide/afl/afl_view.php?name=SELECTEDVALUE

As I wrote before I suggest using
AddColumn( DateTime(),"End Date", formatDateTime );

This uses Windows Regional settings format (see Windows Control Panel).
You can change the settings to produce output in any format.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Andrew" <ae_perrin@xxxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, September 11, 2003 11:56 PM
Subject: [amibroker] Re: Converting DateNum() to a string...


> TJ
> Can you explain why this only gives the "End Date" of the range set 
> in the AA window.  Does the WriteVal function only take the last 
> value of an array?  
> 
> AddTextColumn(WriteVal( DateNum(), 1.0, False ),"End Date");
> 
> Andrew
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Hello,
> > 
> > Sorry there was one typo, should be AddColumn instead of 
> Addtextcolumn, 
> > as below:
> > 
> > function RangeBarLast()
> >  {
> >  Result = LastValue( ValueWhen( Status("lastbarinrange"), 
> >  BarIndex() ) );
> >  return Result;
> > }
> >  
> >  EndBar = RangeBarLast();
> >  dt = DateTime();
> >  
> >  Filter = 1;
> > AddColumn(dt[ EndBar ] , "End Date", formatDateTime);
> > 
> > Hope this helps.
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "jtelang" <jtelang@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Thursday, September 11, 2003 7:05 PM
> > Subject: [amibroker] Re: Converting DateNum() to a string...
> > 
> > 
> > > TJ,
> > > 
> > > Doc says that AddTextColumn takes a String as first parameter... 
> Is 
> > > that not an array of strings? I see that AddColumn does state 
> that it 
> > > takes array as a parameter. I'm a bit confused because when I 
> run 
> > > following -
> > > 
> > > Filter = True;
> > > dn1 = DateNum();
> > > dn2 = WriteVal(dn1, 1.0, False);
> > > AddColumn(dn1, "dn1");
> > > AddTextColumn(dn2, "dn2");
> > > 
> > > - I get correct increasing number in the dn1 column, but only 
> the 
> > > last value of dn1 in the entire dn2 column. Wondering if its 
> because 
> > > of the way WriteVal or AddTextColumn supposed to behave or 
> something 
> > > else that I'm not understanding. I noticed that WriteVal doc 
> says 
> > > that it can take in both, a number or an array. I'm expecting 
> that in 
> > > this case, it's an array.
> > > 
> > > What am I missing here?
> > > 
> > > TIA,
> > > 
> > > Jitu
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> <amibroker@xxxx> 
> > > wrote:
> > > > Andrew,
> > > > 
> > > > You could also use simpler approach:
> > > > 
> > > > function RangeBarLast()
> > > > {
> > > > Result = LastValue( ValueWhen( Status("lastbarinrange"), 
> > > > BarIndex() ) );
> > > > return Result;
> > > > }
> > > > 
> > > > EndBar = RangeBarLast();
> > > > dt = DateTime();
> > > > 
> > > > Filter = 1;
> > > > AddTextColumn(dt[ EndBar ] , "End Date", formatDateTime);
> > > > 
> > > > Hope this helps.
> > > > 
> > > > Best regards,
> > > > Tomasz Janeczko
> > > > amibroker.com
> > > > ----- Original Message ----- 
> > > > From: "Andrew" <ae_perrin@xxxx>
> > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > Sent: Thursday, September 11, 2003 4:39 AM
> > > > Subject: [amibroker] Re: Converting DateNum() to a string...
> > > > 
> > > > 
> > > > > Jitu
> > > > > Re: "Third thing: all floating point arithmetic is IEEE 
> single 
> > > > > precision 32 bit floating point that has 7 (seven) 
> significant 
> > > > > digits." This is the reason I had to write that YYYYMMDD 
> > > function.  
> > > > > This function pads date out to 8 digits.  This is 
> essentially how 
> > > I 
> > > > > use these functions, I want to export a file with a 8 digit 
> date 
> > > tag 
> > > > > attached.  The Date will be the end date of the range you 
> select 
> > > in 
> > > > > the AA window.
> > > > > 
> > > > > Andrew
> > > > > 
> > > > > function YYYYMMDD( indexofBar )
> > > > > {
> > > > > tYear = Year();
> > > > >    tDate   = DateNum();
> > > > > Daystr = StrRight(WriteVal(tdate[indexofBar],1.0),2);
> > > > > Monthstr = StrLeft(StrRight(WriteVal(tdate[indexofBar]
> > > > > *10,1.0),6),2);
> > > > > Yearstr = StrLeft(WriteVal(tYear[indexofBar],1.0),1)+StrRight
> > > > > (WriteVal(tYear[indexofBar],1.0),3); 
> > > > > result = YearStr + Monthstr + DayStr;
> > > > > return result;
> > > > > }
> > > > > 
> > > > > function RangeBarLast()
> > > > > {
> > > > > Result = LastValue( ValueWhen( Status("lastbarinrange"), 
> > > > > BarIndex() ) );
> > > > > return Result;
> > > > > }
> > > > > 
> > > > > EndBar = RangeBarLast();
> > > > > finishbar = YYYYMMDD(EndBar);
> > > > > /* 
> > > > > ReportExport = "C:/Documents and Settings/Owner/My 
> > > > > Documents/Investment docs/ROR System daily 
> > > > > Scans/ROR_Report_"+YYYYMMDD(finishbar)+".TXT";
> > > > > xxTableExport(ReportExport," ",Report);
> > > > > */
> > > > > Filter = 1;
> > > > > AddTextColumn(finishbar, "End Date");
> > > > > 
> > > > > 
> > > > > 
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "jtelang" <jtelang@xxxx> 
> wrote:
> > > > > > Ha! Yes I did read your post carefully, but you're right, 
> what 
> > > I 
> > > > > > didn't read carefully is that doc you pointed to. The 
> reason is 
> > > > > that 
> > > > > > I had already carefully read DateNum documentation that I 
> have 
> > > > > > installed (with the latest beta), and it does not have 
> that 
> > > last 
> > > > > > crucial "Separator" parameter that I was desparately 
> looking 
> > > > > for. :-)
> > > > > > 
> > > > > > > Third thing: all floating point arithmetic is IEEE 
> single 
> > > > > precision 
> > > > > > 32 bit
> > > > > > > floating point that has 7 (seven) significant digits.
> > > > > > 
> > > > > > Gotcha!
> > > > > > 
> > > > > > Jitu
> > > > > > 
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> > > > > <amibroker@xxxx> 
> > > > > > wrote:
> > > > > > > Read carefully.
> > > > > > > 
> > > > > > > I wrote:
> > > > > > > Use ******formatDateTime******* in conjunction with 
> WriteVal
> > > > > > >  http://www.amibroker.com/guide/afl/afl_view.php?
> name=WRITEVAL
> > > > > > > 
> > > > > > > Quote
> > > > > > > 
> > > > > > > "Display date/time according to regional settings 
> > > > > > > 
> > > > > > > WriteVal( DateTime(), formatDateTime ); 
> > > > > > > 
> > > > > > > "
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Also If you don't want to display thousand separator 
> simply
> > > > > > > 
> > > > > > > specify Separator = False as below
> > > > > > > 
> > > > > > > 
> > > > > > > WriteVal( DateNum(), 1.0, False );
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Third thing: all floating point arithmetic is IEEE 
> single 
> > > > > precision 
> > > > > > 32 bit
> > > > > > > 
> > > > > > > floating point that has 7 (seven) significant digits.
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Best regards,
> > > > > > > Tomasz Janeczko
> > > > > > > amibroker.com
> > > > > > > 
> > > > > > > ----- Original Message ----- 
> > > > > > > From: "jtelang" <jtelang@xxxx>
> > > > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > > > Sent: Thursday, September 11, 2003 2:18 AM
> > > > > > > Subject: [amibroker] Re: Converting DateNum() to a 
> string...
> > > > > > > 
> > > > > > > 
> > > > > > > > Tomasz,
> > > > > > > > 
> > > > > > > > I did try WriteVal. The problem I ran into was that 
> integer 
> > > > > value 
> > > > > > > > such as 20021010 came back with commas, like 
> 200,210,10 
> > > which 
> > > > > I 
> > > > > > could 
> > > > > > > > not get rid of. And I'm quite puzzled that passing the 
> > > number 
> > > > > > > > returned by DateNum didn't work for me in the way I 
> tried 
> > > it 
> > > > > (as 
> > > > > > > > mentioned in my original post). Do you have any idea 
> if its 
> > > a 
> > > > > bug 
> > > > > > or 
> > > > > > > > if its something that I did wrong?
> > > > > > > > 
> > > > > > > > Andrew, thanks for your suggestion. I'll try it. I 
> have it 
> > > now 
> > > > > > > > working as follows (which gives me a 8 digit number, 
> with 
> > > > > leading 
> > > > > > 0's 
> > > > > > > > when warranted). Couldn't think of any other way to 
> get it 
> > > to 
> > > > > > work. 
> > > > > > > > By leading 0's, I mean that I want the string to be 
> > > 20020310 
> > > > > when 
> > > > > > the 
> > > > > > > > date is 10/3/2002, instead of 2002310.
> > > > > > > > 
> > > > > > > > ------------------
> > > > > > > > 
> > > > > > > > EnableScript("vbscript");
> > > > > > > > 
> > > > > > > > gYstr = "" + Year();
> > > > > > > > gMstr = "" + Month();
> > > > > > > > gDstr = "" + Day();
> > > > > > > > <%
> > > > > > > >   Dim mstr
> > > > > > > >   Dim dstr
> > > > > > > >   mstr = AFL("gMstr")
> > > > > > > >   if( Len(mstr) < 2 ) then mstr = "0" + mstr
> > > > > > > >   dstr = AFL("gDstr")
> > > > > > > >   if( Len(dstr) < 2 ) then dstr = "0" + dstr
> > > > > > > >   AFL("gMstr") = mstr
> > > > > > > >   AFL("gDstr") = dstr
> > > > > > > > %>
> > > > > > > > gDateNumStr = gYstr + gMstr + gDstr;
> > > > > > > > 
> > > > > > > > -----------------
> > > > > > > > 
> > > > > > > > Jitu
> > > > > > > > 
> > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> > > > > > <amibroker@xxxx> 
> > > > > > > > wrote:
> > > > > > > > > Hello,
> > > > > > > > > 
> > > > > > > > > Use formatDateTime in conjunction with WriteVal
> > > > > > > > > http://www.amibroker.com/guide/afl/afl_view.php?
> > > name=WRITEVAL
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > Best regards,
> > > > > > > > > Tomasz Janeczko
> > > > > > > > > amibroker.com
> > > > > > > > > ----- Original Message ----- 
> > > > > > > > > From: "jtelang" <jtelang@xxxx>
> > > > > > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > > > > > Sent: Wednesday, September 10, 2003 11:54 PM
> > > > > > > > > Subject: [amibroker] Converting DateNum() to a 
> string...
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > > I'm trying to use the number returned by DateNum() 
> in a 
> > > > > > string 
> > > > > > > > > > that'll designate a unique filename for each day, 
> and 
> > > for 
> > > > > > some 
> > > > > > > > reason 
> > > > > > > > > > am unable to use the value returned. Here's a 
> > > simplified 
> > > > > > example, 
> > > > > > > > > > when trying to set it as a string to title. Does 
> anyone 
> > > > > know 
> > > > > > why 
> > > > > > > > this 
> > > > > > > > > > wouldn't work? I get a syntax error on this -
> > > > > > > > > > 
> > > > > > > > > > EnableScript("vbscript");
> > > > > > > > > > dn = DateNum();
> > > > > > > > > > <%
> > > > > > > > > >  AFL("Title") = CStr(AFL("dn"))
> > > > > > > > > > %>
> > > > > > > > > > 
> > > > > > > > > > Following does work -
> > > > > > > > > > 
> > > > > > > > > > EnableScript("vbscript");
> > > > > > > > > > dn = 9999999;
> > > > > > > > > > <%
> > > > > > > > > >  AFL("Title") = CStr(AFL("dn"))
> > > > > > > > > > %>
> > > > > > > > > > 
> > > > > > > > > > What's the difference in assigning a constant vs a 
> > > value 
> > > > > > returned 
> > > > > > > > by 
> > > > > > > > > > DateNum to variable dn? FWIW, I tried ABTool's 
> > > xxToString
> > > > > () 
> > > > > > > > function 
> > > > > > > > > > as well. Similar problem...
> > > > > > > > > > 
> > > > > > > > > > TIA,
> > > > > > > > > > 
> > > > > > > > > > Jitu
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > Send BUG REPORTS to bugs@xxxx
> > > > > > > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > > > > > > -----------------------------------------
> > > > > > > > > > Post AmiQuote-related messages ONLY to: 
> > > > > > amiquote@xxxxxxxxxxxxxxx 
> > > > > > > > > > (Web page: 
> > > > > http://groups.yahoo.com/group/amiquote/messages/)
> > > > > > > > > > --------------------------------------------
> > > > > > > > > > Check group FAQ at: 
> > > > > > > > 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > > > > > > > > 
> > > > > > > > > > Your use of Yahoo! Groups is subject to 
> > > > > > > > http://docs.yahoo.com/info/terms/ 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > >
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > Send BUG REPORTS to bugs@xxxx
> > > > > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > > > > -----------------------------------------
> > > > > > > > Post AmiQuote-related messages ONLY to: 
> > > > > amiquote@xxxxxxxxxxxxxxx 
> > > > > > > > (Web page: 
> http://groups.yahoo.com/group/amiquote/messages/)
> > > > > > > > --------------------------------------------
> > > > > > > > Check group FAQ at: 
> > > > > > 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > > > > > > 
> > > > > > > > Your use of Yahoo! Groups is subject to 
> > > > > > http://docs.yahoo.com/info/terms/ 
> > > > > > > > 
> > > > > > > > 
> > > > > > > >
> > > > > 
> > > > > 
> > > > > 
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to: 
> amiquote@xxxxxxxxxxxxxxx 
> > > > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at: 
> > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > > > 
> > > > > Your use of Yahoo! Groups is subject to 
> > > http://docs.yahoo.com/info/terms/ 
> > > > > 
> > > > > 
> > > > >
> > > 
> > > 
> > > 
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > --------------------------------------------
> > > Check group FAQ at: 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > 
> > > Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> > > 
> > > 
> > >
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
> 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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