Hi Raine,
This is not difficult except for your definition of one year. The number of
trading days differs from market to market, however a general rule of thumb
might be 250 days. In the US, I have 253 days in this year, however one year
back it might be a bit less depending on holidays, so I generally use 250 for
convenience. If you have a different number, substitute it for the 250 below.
The exploration would look something like this (I'm not writing this in AB, but
don't think it will have errors unless introduced by line wrapping):
// =========== Exploration Code
Filter = 1;
addcolumn( c, "CLOSE", 3.2, colorwhite, colorblue);
addcolumn( ref(c, -250), "Close 1 Year Ago", 3.3, coloryellow, colordarkgreen);
addcolumn( c - ref(c,-250),"Points Delta over Year", 3.2, colorblue,
coloryellow);
addcolumn( ROC(C, 250), "% Change over year), 3.2, colorwhite, colordarkred);
// ================ End Code ==================
If you want to make a parameter for the period change the number 250 in the
above code to Per and place the following parameter at the top of the code:
Per = Param("Period to Check", 250, 1, 250, 1);
Enjoy!!
Peace and Justice --- Patrick
----- Original Message -----
From: possum51au
To: [email protected]
Sent: Tuesday, February 02, 2010 9:07 PM
Subject: [amibroker] Please help with an exploration code
I am trying to write an exploration which returns the closing price one year
ago. I know it will be simple but I seem to have a mental block.
Ideally I would like it to calculate the difference between today's close and
that 1 year previous close, and present it as a percentage gain or loss.
Thanks in advance for any help
Raine
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links