PureBytes Links
Trading Reference Links
|
Hg, the first bit of code is just an example to showcase the back-
erase concept.
The "Week's end" code deals with the holiday Friday problem - it
doesn't need to know about holidays to determine end of week signals.
Here is a more refined version:
=======================
Week's true start & end
=======================
---8<---------------------------
{ Signals true start & end of week:
confirms signal at start of following week,
and signals end of week in retrospect }
{ Signals independent of any missing chart data}
{ Plot only on daily & intraday charts }
{ ©Copyright 2002~2005 Jose Silva
The grant of this license is for personal use
only - no resale or repackaging allowed.
All code remains the property of Jose Silva.}
{ http://www.metastocktools.com }
limit:=2000; {do not change limit year}
LimLeap:=Frac(limit/4)=0 AND Frac(limit/100)<>0
OR Frac(limit/400)=0;
NoCount:=limit*365+Int(limit/4)
-Int(limit/100)+Int(limit/400)-LimLeap;
leap:=Frac(Year()/4)=0 AND Frac(Year()/100)<>0
OR Frac(Year()/400)=0;
y:=Year()*365+Int(Year()/4)
-Int(Year()/100)+Int(Year()/400)-NoCount;
m:=
If(Month()=2,31-leap,
If(Month()=3,59,
If(Month()=4,90,
If(Month()=5,120,
If(Month()=6,151,
If(Month()=7,181,
If(Month()=8,212,
If(Month()=9,243,
If(Month()=10,273,
If(Month()=11,304,
If(Month()=12,334,
-leap)))))))))));
DayNr:=y+m+DayOfMonth();
WkCount:=Int((DayNr-1)/7)+(Year()>=limit);
WeekStart:=WkCount>Ref(WkCount,-1);
WeekEnd:=PeakBars(1,-Zig(WeekStart-.5,1,$),1)=0
OR Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5;
{ Plot signals in own window }
WeekStart;-WeekEnd
---8<---------------------------
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, "hg1az" <hg1az@xxxx> wrote:
>
>
> Jose
>
> How do you handle the situation if the DayOfWeek() is
> not a trading day because of a Holiday? As I recall,
> some MS functions are very slow. I think PREV is one
> of these. What are the slow MS functions?
>
> thanks much, hg
>
>
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx>
> wrote:
>
> MetaStock generally reads and processes data from left to right.
>
> MS signals are plotted sequentially in this West-East direction,
> and once any data is plotted on a chart, there is no way to coerce
> MetaStock to go back and erase past signals.
>
> Or is there...?
>
> By nesting a couple of hindsight functions such as ZigZag() and
> Peak(), this is now possible.
>
> One of the holy grails of MetaStock coding has been to be able to
> modify past signals, such as (for pattern-recognition purposes):
> "Plot last Friday only if following Monday's Close is up".
>
> Here is some magic MS code that will do just that:
>
> ---8<-----------------
>
> { Friday signal }
> signal:=DayOfWeek()=5;
>
> { Monday up on Friday's Close }
> confirm:=DayOfWeek()=1 AND C>Ref(C,-1);
>
> { Extend signal & confirmation }
> x:=ValueWhen(1,signal OR confirm,signal-confirm);
>
> { Magic: forget last Friday if Monday is down }
> hindsight:=PeakBars(1,Zig(x,1,$),1)=0;
>
> { Plot in own window }
> hindsight
>
> ---8<-----------------
>
>
> And here is another bit of magic - detecting and plotting true
> end-of-week signals:
>
> ==========
> Week's end
> ==========
> ---8<---------------------
>
> { Signals true end of week:
> confirms signal at start of following week,
> and signals end of week in retrospect }
> { http://www.metastocktools.com }
>
> day:=DayOfWeek();
> WeekStart:=day<Ref(day,-1);
> WeekEnd:=PeakBars(1,-Zig(WeekStart-.5,1,$),1)=0;
>
> WeekEnd
>
> ---8<---------------------
>
>
> jose '-)
> http://www.metastocktools.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|