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

Re: [amibroker] Re: YTD



PureBytes Links

Trading Reference Links

Here is another version I use:

//Yearly and Monthly Percentage Gain or loss

Yearly = Year() != Ref( Year(), 1 );

Monthly=Month() != Ref( Month(),1);

//Yearly

StartValueYearly = ValueWhen( Yearly, Close, 2 );

EndValueYearly = ValueWhen( Yearly, Close, 1 );

/*******************************************/

//Monthly

startvalueMonth= ValueWhen( Monthly,Close,2);

EndValueMonth= ValueWhen( Monthly,Close,1);

/********************************************/

Filter = Yearly OR Monthly;

AddColumn(Month(),"Month",1.0);

AddColumn(Year(), "Year", 1.0 );

AddColumn(IIf(Month()==12,100*( EndValueYearly -
StartValueYearly )/StartValueYearly,Null), "Yearly_% change" );

AddColumn(100*( EndValueMonth - StartValueMonth)/StartValueMonth,
"Monthly_%change" );

----- Original Message ----- 
From: "Brian" <cadvantag@xxxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, December 09, 2003 10:09 PM
Subject: [amibroker] Re: YTD


> Thanks Joe & Mr. Valley!
>
> I like them both..
>
> Brian
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Joseph Landry" <jelandry@xxxx>
> wrote:
> > Brian - Here's a code fragment that seems to work for me
> > // ---------------------------YTD Performance Calculation
> > EndV = ValueWhen(DateNum()==DateNum(),Close);     // Today's Close
> > BegV = ValueWhen(DateNum()==1030102,Close);   // Jan/02/03 Close
> > YTD = 100*(EndV-BegV)/BegV;
> >
> > You'll have to start with a trading day, in this case it was Jan
> > 2,2003.
> >
> > Hope this helps. Seems to work for me.
> >
> > JOE
> > --- In amibroker@xxxxxxxxxxxxxxx, "Brian" <cadvantag@xxxx> wrote:
> > > I am trying to get a exploration that calculates the stocks total
> > or
> > > loss year to date (YTD)
> > >
> > > I am using this formula
> > >
> > > YTD = ((EndValue(Close) - BeginValue(Close) * 100) / BeginValue
> > > (Close);
> > >
> > > But I get an error and I don't know how to set it to start on
> > January
> > > 1 and calculate YTD.
> > >
> > > Can someone help me.
> > >
> > > Thanks,
> > > Brian
>
>
>
> 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/
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.548 / Virus Database: 341 - Release Date: 12/5/2003


------------------------ 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/mOAaAA/3exGAA/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/