logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Jose  
#1 Posted : Monday, September 26, 2005 11:42:36 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Following on the "Week's true Start & End" code concept ... below is an accurate Weekly EMA indicator: [code:1:173dab0135] =================== Weekly EMA of Close =================== ---8<--------------------------- { True weekly Close Exponential Mov Avg v5.0 } { For daily/intraday charts } { Requires "Week's true Start & End" indicator } { Plot is independent of any missing chart data} { ©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 } { User inputs } pds:=Input("Weekly EMA periods",1,520,4); shift:=1+Input("EMA vertical shift %", -100,100,0)/100; EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,2); plot:=Input("plot: [1] EMA, [2] Crossover signals",1,2,1); { Choice of Static/Dynamic last EOW signal } EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)), Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5); { Reference EOW signals } WkEnd:=EOW OR FmlVar("Week's true Start & End","WEEKEND"); { Week's Close } WkCl:=ValueWhen(1,WkEnd,C); WkCl:=ValueWhen(1,WkCl>0,WkCl); { Reduce periodicity if insufficient periods } pds:=If(pds>Cum(WkEnd),Cum(WkEnd),pds); { Weekly EMA } WkEma:=ValueWhen(1,WkEnd,PREV) *(1-2/(pds+1))+WkCl*2/(pds+1); { Vertical shift } WkEma:=WkEma*shift; { Crossover signals } signals:=Cross(C,WkEma)-Cross(WkEma,C); { Plot on price chart } If(plot=2,signals,WkEma) ---8<--------------------------- [/code:1:173dab0135] jose '-) http://www.metastocktools.com
Jose  
#2 Posted : Monday, September 26, 2005 11:44:19 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Accurate Weekly SMA indicator: [code:1:35ba281aff] =================== Weekly SMA of Close =================== ---8<--------------------------- { True weekly Close Simple Moving Average v5.0 } { For daily/intraday charts } { Requires "Week's true Start & End" indicator } { Plot is independent of any missing chart data} { ©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 } { User inputs } pds:=Input("Weekly SMA periods",1,520,4); shift:=1+Input("SMA vertical shift %", -100,100,0)/100; EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,2); plot:=Input("plot: [1] SMA, [2] Crossover signals",1,2,1); { Choice of Static/Dynamic last EOW signal } EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)), Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5); { Reference EOW signals } WkEnd:=EOW OR FmlVar("Week's true Start & End","WEEKEND"); { Week's Close } WkCl:=ValueWhen(1,WkEnd,C); WkCl:=ValueWhen(1,WkCl>0,WkCl); { Weekly SMA } z:=Cum(WkEnd*WkCl); WkSma:=(z-ValueWhen(pds+1,WkEnd,z))/pds; { Vertical shift } WkSma:=WkSma*shift; { Crossover signals } signals:=Cross(C,WkSma)-Cross(WkSma,C); { Plot on price chart } If(plot=2,signals,WkSma) ---8<--------------------------- [/code:1:35ba281aff] jose '-) http://www.metastocktools.com
Jose  
#3 Posted : Monday, September 26, 2005 11:45:50 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Accurate Weekly MACD & MACDH indicator: [code:1:bc26423607] ==================== Weekly MACD of Close ==================== ---8<--------------------------- { Weekly Close MACD/Signal/Histogram v3.0 } { For daily/intraday charts } { Requires "Week's true Start & End" indicator } { ©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 } { User inputs } pds1:=Input("shorter weekly EMA periods", 1,520,12); pds2:=Input("longer weekly EMA periods", 2,5200,26); pds3:=Input("weekly MACD signal periods", 1,520,9); EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,2); plot:=Input("plot: [1]MACD, [2]Histogram", 1,2,1); { Choice of Static/Dynamic last EOW signal } EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)), Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5); { Reference EOW signals } WkEnd:=EOW OR FmlVar("Week's true Start & End","WEEKEND"); { Week's Close } WkCl:=ValueWhen(1,WkEnd,C); WkCl:=ValueWhen(1,WkCl>0,WkCl); { Reduce periodicity if insufficient periods } pds1:=If(pds1>Cum(WkEnd),Cum(WkEnd),pds1); { Weekly EMA1 } WkEma1:=ValueWhen(1,WkEnd,PREV) *(1-2/(pds1+1))+WkCl*2/(pds1+1); { Weekly EMA2 } pds2:=If(pds2>Cum(WkEnd),Cum(WkEnd),pds2); WkEma2:=ValueWhen(1,WkEnd,PREV) *(1-2/(pds2+1))+WkCl*2/(pds2+1); { MACD } Mac:=WkEma1-WkEma2; { Signal } pds3:=If(pds3>Cum(WkEnd),Cum(WkEnd),pds3); Signal:=ValueWhen(1,WkEnd,PREV) *(1-2/(pds3+1))+Mac*2/(pds3+1); { Histogram } Hist:=Mac-Signal; { Plot in own window } If(plot=1,Signal,Hist); If(plot=1,Mac,0) ---8<--------------------------- [/code:1:bc26423607] jose '-) http://www.metastocktools.com
Jose  
#4 Posted : Monday, September 26, 2005 11:48:32 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
And of course, you'll need the fabulous Weekly Start & End signals indicator for all of the above to work: [code:1:70be624fdf] ======================= Week's true Start & End ======================= ---8<--------------------------- { Week's true start & end of week (EOW) v2.0 } { Confirms EOW signal at start of following week, and signals EOW in retrospect.} { Signals independent of any missing chart data} { For 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 } { User input } EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,1); { Calendar Week counter } 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); { Week's start signal } WeekStart:=WkCount>Ref(WkCount,-1); { Week's end signal } { Choice of Static/Dynamic last EOW signal } EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)), Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5); { Detect other than daily/intraday charts } detect:=LastValue(Cum( WkCount=ValueWhen(2,1,WkCount)))=0; { Make EOW signal visible for weekly+ charts } WeekEnd:=PeakBars(1,-(If(detect=0, WeekStart OR Cum(IsDefined(WeekStart))=1, Cum(1)/2=Int(Cum(1)/2))),1)=0 OR EOW; WeekEnd:=If(detect=0,WeekEnd,1); { Plot signals in own window } WeekStart;-WeekEnd ---8<--------------------------- [/code:1:70be624fdf] jose '-) http://www.metastocktools.com
Jose  
#5 Posted : Thursday, September 29, 2005 7:00:13 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Ok, this is the latest (and final) version of the Weekly MACD/Histogram, which now also plots MetaStock's default MACD (0.15/0.075): [code:1:95e5177b45] ==================== Weekly MACD of Close ==================== ---8<--------------------------- { Weekly Close MACD/Signal/Histogram v4.0 } { For daily/intraday charts } { Requires either "Week's true start & end" or "Week's true start & end(2)" indicators.} { ©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 } { User inputs } pds1:=Input("shorter weekly EMA periods", 1,520,12.3); pds2:=Input("longer weekly EMA periods", 2,5200,25.7); pds3:=Input("weekly MACD signal periods", 1,520,9); EOW:=Input("Final week's end: [1]True, [2]Current (dynamic)",1,2,2); plot:=Input("plot: [1]MACD, [2]Histogram", 1,2,1); { Choice of Static/Dynamic last EOW signal } EOW:=If(EOW=2,Cum(1)=LastValue(Cum(1)), Cum(1)=LastValue(Cum(1)) AND DayOfWeek()=5); { Reference EOW signals } WkEnd:=EOW OR FmlVar("Week's true Start & End","WEEKEND"); { Week's Close } WkCl:=ValueWhen(1,WkEnd,C); WkCl:=ValueWhen(1,WkCl>0,WkCl); { Weekly EMA1 } x:=If(pds1=12.3,0.15,2/(pds1+1)); x:=If(pds1>Cum(1),2/(Cum(WkEnd)+1),x); WkEma1:=ValueWhen(1,WkEnd,PREV)*(1-x)+WkCl*x; { Weekly EMA2 } x:=If(pds2=25.7,0.075,2/(pds2+1)); x:=If(pds2>Cum(1),2/(Cum(WkEnd)+1),x); WkEma2:=ValueWhen(1,WkEnd,PREV)*(1-x)+WkCl*x; { MACD } Mac:=WkEma1-WkEma2; { Signal } pds3:=If(pds3>Cum(WkEnd),Cum(WkEnd),pds3); Signal:=ValueWhen(1,WkEnd,PREV) *(1-2/(pds3+1))+Mac*2/(pds3+1); { Histogram } Hist:=Mac-Signal; { Plot in own window } If(plot=1,Signal,Hist); If(plot=1,Mac,0) ---8<--------------------------- [/code:1:95e5177b45] jose '-) http://www.metastocktools.com
sportrider  
#6 Posted : Friday, October 28, 2005 10:51:32 PM(UTC)
sportrider

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/12/2005(UTC)
Posts: 141
Location: Brooklyn,NY

Jose, I just wanted to thank you as well as some of the other members for your generosity and contributions to this forum.You guys make it what it is.Thanks.
Jose  
#7 Posted : Saturday, October 29, 2005 3:52:55 AM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Thanks SportRider. With the exception of spam, every single post in this forum is a potentially valuable contribution to the MetaStock/trading community, whether it may be a question, answer, statement, or just a simple gaffe. 8) jose '-)
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.