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

[amibroker] Re: Calculating % change since 1/3/2006



PureBytes Links

Trading Reference Links

And of course since it's late I entered in a typo.  Change (or not)
the 12-30-06 to 12-30-05 in the column heading.  

You will notice that both of Graham's examples of ValueWhen and
BarsSince work the same.

Thanks once again Graham.

MM

--- In amibroker@xxxxxxxxxxxxxxx, "marketmonk777" <dlittner@xxx> wrote:
>
> Hi DM,
> 
> The code I posted works just fine.  Sorry if I caused the confusion by
> typing in 1-3-06 as a date in my column title. There are indeed 57
> bars since 12-30-05.
> 
> It retrieves the closing price on 12/30/05.  And from that I can
> calculate the YTD % performance.
> 
> Here is the price % calculations and some extra code to verify
> (visually) that it works.
> 
> 
> //  Price  Deltas
> 
> AddColumn( ( (C-Ref(C,-1))/Ref(C,-1))*100,"1 P %", 3.2,
> colorYellow,colorGreen);
> 
> AddColumn( ( (C-Ref(C,-5))/Ref(C,-5))*100,"5 P %", 3.2,
> colorYellow,colorGreen);
> 
> AddColumn( ( (C-Ref(C,-21))/Ref(C,-21))*100,"21 P %", 3.2,
> colorYellow,colorGreen);
> 
> AddColumn( ( (C-Ref(C,-63))/Ref(C,-63))*100,"63 P %", 3.2,
> colorYellow,colorGreen);
> 
> AddColumn( ( (C-Ref(C,-255))/Ref(C,-255))*100,"255 P %", 3.2,
> colorYellow,colorGreen);
> 
> BS = BarsSince(Year()!=Ref(Year(),1));
> 
> AddColumn(BS,"BS 12-30-06" , 3.2, colorDarkRed, colorLightGrey  );
> 
> LC = Ref( C,-BS);
> 
> AddColumn(LC,"LC" , 3.2, colorDarkRed, colorLightGrey  );
> 
> YTDP = (  (C - Ref( C,-BS)) / Ref( C, -BS)  )*100;
> 
> AddColumn(YTDP,"YTD %" , 3.2, colorDarkRed, colorLightGrey  );
> 
> LYC = ValueWhen( Year()!=Ref(Year(),1), C );
> 
> AddColumn(LYC,"L YR C" , 3.2, colorDarkRed, colorLightGrey  );
> 
> PCLY = (  (C - LYC)/ LYC )*100;
> 
> AddColumn(PCLY,"% from LY", 3.2, colorDarkRed, colorLightGrey  );
> 
> MM
> --- In amibroker@xxxxxxxxxxxxxxx, "dmcleod1981" <dmcleod1981@> wrote:
> >
> > Sorry meant to type 01/01/06 for second lines closing price not '04.
> > 
> > DM
> > --- In amibroker@xxxxxxxxxxxxxxx, "dmcleod1981" <dmcleod1981@> wrote:
> > >
> > > The two formulas appear to give different dates. The first does give
> > > the closing price for 12/30/04 but the second gives the closing
price
> > > for 01/03/04 which would be incorrect for year to date figures.
> > > 
> > > I am also confused as to the +1 and couldn't see how to correct the
> > > line to give the closing '05 price.
> > > 
> > > DM
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "MarketMonk777" <dlittner@> wrote:
> > > >
> > > > Hi Graham,
> > > > 
> > > > Thanks, the barssince works.  I have added the following lines of
> > code:
> > > > 
> > > > BS = BarsSince(Year()!=Ref(Year(),1));
> > > > AddColumn(BS,"BS 1-1-06" , 3.2, colorDarkRed, colorLightGrey  );
> > > > YTD = C - Ref( C, -BarsSince(Year()!=Ref(Year(),1))+1);
> > > > AddColumn(YTD,"YTD Net" , 3.2, colorDarkRed, colorLightGrey  );
> > > > 
> > > > Just to confirm that all works.
> > > > 
> > > > I am confused as to the purpose of the +1 that is added at the end
> > > of the
> > > > code in the YTD line.
> > > > 
> > > > I was able to research and figure out that != means not equal
> to.  And
> > > > researched how barssince works.  And that ref(year(),1) is the way
> > > to catch
> > > > the year changing from 2005 to 2006.
> > > > 
> > > > But that +1 has me confused.  What is it's purpose?
> > > > 
> > > > Dave
> > > > 
> > > > -----Original Message-----
> > > > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
> > > On Behalf
> > > > Of Graham
> > > > Sent: Saturday, March 25, 2006 3:47 PM
> > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > Subject: Re: [amibroker] Calculating % change since 1/3/2006
> > > > 
> > > > you can use valuewhen function to reference a fixed point or ref
> with
> > > > barssince
> > > > for the close price of end of previous year
> > > > 
> > > > valuewhen( year()!=ref(year(),1), C )
> > > > 
> > > > or
> > > > 
> > > > ref( c, -barssince(year()!=ref(year(),1))+1)
> > > > 
> > > > 
> > > > --
> > > > Cheers
> > > > Graham
> > > > AB-Write >< Professional AFL Writing Service
> > > > Yes, I write AFL code to your requirements
> > > > http://e-wire.net.au/~eb_kavan/ab_write.htm
> > > > 
> > > > 
> > > > On 3/26/06, marketmonk777 <dlittner@> wrote:
> > > > > Hi folks,
> > > > >
> > > > > I would like to add a value to my title line and in some of my
> > > > > explorations.  The value that I am trying to determine is the %
> > change
> > > > > since the last trading day of 2005 (or should I use 1/3/06?).
> > > > >
> > > > > How do I specify a fixed date in my calculations?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Dave
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > 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
> > > >
> > >
> >
>







------------------------ 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:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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