MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 A B C D E F G H I J K L M N O P R S T U V W Y Z #

WeekStart Up/Down Days by Jose Silva

Can anyone help me code a condition where a stock closes down on Friday
(last trading day of week) and then down the following Monday (first trading day of week)?

Thank you, Brett

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Brett, try this indicator code:

===============================
WeekEnd/Start custom conditions
===============================
---8<--------------------------------------

{ Signals custom WeekEnd/Start conditions.

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 }

{ User inputs }
plot:=Input("plot: [1]Signals, [2]Start of week",1,2,1);

{ Calendar counter engine }
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)-730484;
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();
-(Frac(Year()/100)=0 AND Frac(Year()/400)<>0);

{ Week's start signal }
WeekStart:=WkCount>Ref(WkCount,-1);

{ Price down on Week's end and start days }
signals:=WeekStart
*ValueWhen(1,WeekStart,Sum(C<Ref(C,-1),2)=2);

{ Plot in own window }
If(plot=1,signals,WeekStart)

---8<--------------------------------------

jose '-)
http://www.metastocktools.com

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

And here is a more versatile version of the same indicator:

WeekStart Up/Down Days

{ Signals WeekStart Up/Down days - v2.0

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 }

{ User inputs }
changeUp:=Input("Minimum Up daily price change %",0,100,.00001)/100;
pdsUp:=Input("Successive Up bars",1,21,2);
changeDw:=Input("Minimum Down daily price change %",0,100,.00001)/100;
pdsDw:=Input("Successive Down bars",1,21,2);
plot:=Input("signals: [1]Up/Down bars, [2]Start of week",1,2,1);

{ Calendar counter engine }
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)-730484;
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();
-(Frac(Year()/100)=0 AND Frac(Year()/400)<>0);

{ Week's start signal }
WeekStart:=WkCount>Ref(WkCount,-1);

{ Condition signals }
upCond:=
Sum(C>=Ref(C,-1)*(1+changeUp),pdsUp)=pdsUp;
up:=ValueWhen(1,WeekStart,upCond)*WeekStart;
dwCond:=
Sum(C<=Ref(C,-1)*(1-changeDw),pdsDw)=pdsDw;
dw:=ValueWhen(1,WeekStart,dwCond)*WeekStart;
signals:=up-dw;

{ Plot in own window }
0;If(plot=1,signals,WeekStart)

Source / From: TOP
equismetastock[at]yahoogroups[dot]com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.