PureBytes Links
Trading Reference Links
|
Hi Mike,
Thanks for the tips,
Below are my changes (weekly) to your (yearly) code. Assuming it is correct
than why on a chart with 50 days I can get a plot of average solid area on
all days except the very first 2 days? Seems to me if one, two weeks are
selected then the first one to two weeks should not have any plots?
Or does something need to be change in the section just after Avgroc = 0?
Regards,
JG
///////////////////////////////////////////////////////////////////
weeks = Param("Weeks",3,1,15,1);
newweek = DayOfWeek();
Avgroc = 0;
// Create dynamic variables for each year (excluding current)
for (y = 1; y <= weeks; y++) {
initialValue = IIf(newweek, ValueWhen(newweek, Close, y),
ValueWhen(newweek, Close, y + 1));
barValue = Ref(Close, -5 * y);
runningroc = (barValue / initialValue) - 1;
VarSet("Week" + y, runningroc);
Avgroc += runningroc;
}
Avgroc /= weeks;
// Plot previous years with incrementing colors
for (y = 1; y <= weeks; y++) {
Plot(VarGet("Week" + y), "" + y + "Weeks Ago", colorDarkRed + y );
}
// Plot average as solid area
Plot(Avgroc, "Avg.", colorDarkRed + y, styleArea | styleNoLabel);
///////////////////////////////////////////////////////////////////
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Mike
Sent: Wednesday, December 23, 2009 2:56 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Winter project, Correlation Trading
Jerry,
Sorry, sent you the link to the poor formatted version. The better version
is here: http://finance.groups.yahoo.com/group/amibroker/message/144970
And, yes, if you want every Tuesday to be your criteria for a new period,
then what you have done should work. But, you must also change the constant
used in the calculations. Instead of 252 (i.e. trading days in a year), you
would need to use 5 (i.e. trading days in a week).
Note also that when dealing with a year, minor errors in the alignment don't
make much difference. But, when using just a week, as you are doing, the
alignment will likely be more important and you will probably have to work
out some more precise code than simply using multiples of 5 bars/week. For
example, when the markets were closed due to holidays, using a hard coded
multiple of 5 days will misalign the data.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "Jerry Gress" <pleasenospamplease@xxx>
wrote:
>
> Thanks Mike,
>
> Will work on changing Year() to week???
>
>
> In fact when I change the one line as below I get something that may
work!!
>
>
> newYear = DayOfWeek()==2;//Year() != Ref(Year(), -1);
>
> JG
>
>
> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
Behalf
> Of Mike
> Sent: Wednesday, December 23, 2009 11:10 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Winter project, Correlation Trading
>
> Jerry,
>
> I was involved in a similar thread recently, excecpt covering 1 year at a
> time. Perhaps you can alter the code for your needs.
>
> http://finance.groups.yahoo.com/group/amibroker/message/144969
>
> Mike
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Jerry Gress" <pleasenospamplease@>
> wrote:
> >
> > Hello All,
> >
> > Would like to take the 1 minute data from three weeks ago and two weeks
> ago
> > then super impose it on the following week. For example: Monday 7 Dec,
> > Monday 14 all on Monday Dec 21.
> >
> >
> > My feeble attempt that does not work for one week:
> >
> > yut = DayOfWeek()==2;
> > ytr = Ref(yut,-1);
> > Plot(ytr,"",colorGreen,styleBar);
> >
> >
> > So do I have to do the timeframe stuff?
> >
> > Any help will be appreciated.
> >
> > JG
> >
>
>
>
>
> ------------------------------------
>
> **** 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
>
------------------------------------
**** 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
------------------------------------
**** 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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|