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.
For daily & intraday charts.

©Copyright 2002~2007 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 }

{ User inputs }
plot:=Input("plot: [1]Signals, [2]Start of week",1,2,1);
adj:=Input("Week's start: [0]Sunday, [1]Monday",0,1,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();
adj:=adj+If(DayNr<1,1,2)
-(Frac(Year()/100)=0 AND Frac(Year()/400)<>0);
WkCount:=Int((DayNr-adj)/7)+(Year()>=2000);

{ 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
For daily & intraday charts.

©Copyright 2002~2007 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 }

{ 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);
adj:=Input("Week's start: [0]Sunday, [1]Monday",0,1,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();
adj:=adj+If(DayNr<1,1,2)
-(Frac(Year()/100)=0 AND Frac(Year()/400)<>0);
WkCount:=Int((DayNr-adj)/7)+(Year()>=2000);

{ 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)



WeekStart_Up-Down_Days
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.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!