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

Notification

Icon
Error

Options
Go to last post Go to first unread
zoomtop  
#1 Posted : Thursday, October 13, 2005 9:14:12 AM(UTC)
zoomtop

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 10/10/2005(UTC)
Posts: 3

Lost my post from the other day but thanks for you suggestions Jose. Still haven't completely solved it though. This so far has alluded me! I wish to calculate for the "lookback period" and project the result forward the same number of days. ie.lookback x days and then project the result forward x days resulting in a stepped indicator. This formula works but it is dynamic, updating daily for the lookback. lb:=Input("Enter Lookback period",3,21,3); hi:=HHV(H,lb); lo:=LLV(L,lb); pivot:=(hi+lo+C)/3; pivot Did read somewhere in my travels MS could not look forward of last data, perhaps I cannot do what I am trying to do but that being so it should work up until it runs out of data. Any help much appreciated.
Jose  
#2 Posted : Thursday, October 13, 2005 11:40:20 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)
zoomtop wrote:
I wish to calculate for the "lookback period" and project the result forward the same number of days.
Below is a MS code example where bars are counted to a past event, and then that event's value is projected forward to the current bar. [code:1:9e95edf764] { surrogate Peak() function } event:=PeakBars(1,C,5)=0; lookbackPds:=BarsSince(event)+1; projectFwd:=ValueWhen( LastValue(lookbackPds+PREV-PREV),True,H); projectFwd [/code:1:9e95edf764] The code above has no practical value other than to illustrate the lookback & extend-forward concept. Personally, I would just use ValueWhen(1,event,dataArray) to extend past values to the current bar. Also take a look at the MS code for intraday pivots. jose '-)
zoomtop  
#3 Posted : Friday, October 14, 2005 9:49:05 AM(UTC)
zoomtop

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 10/10/2005(UTC)
Posts: 3

Thanks for suggestions again Jose. Still not there and more confused than ever. I am just a beginner at this, or I was at the start! Have learned something though, I think it may be beyond me! In desperation I put the "intraday indicator" you suggested I look at in my MS and cannot get it to work either. It gets hung up on "dCount" and "Calendar Day counter" with message "no indicator names in the indicator builder contain this text" or "not a recognised name, constant or operator". If I remove those paras then it plots the PPs Rs and Ss but no date reference. That has got me a bit baffled. I am using MS 8.01 Do I perhaps need an add on? Another suggestion would be greatly appreciated. Z
Jose  
#4 Posted : Friday, October 14, 2005 12:39:12 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)
zoomtop wrote:
It gets hung up on "dCount" and "Calendar Day counter" with message "no indicator names in the indicator builder contain this text" or "not a recognised name, constant or operator".
ZoomTop, how did you get to be Site Admin when you can't handle a simple copy & paste, hmm? :D You need to have the "Calendar Day counter" indicator within MetaStock before the intraday pivots can work. Here's some proxy pivots code that will do the trick without the auxiliary "Calendar Day counter" indicator: [code:1:cb2a1298a6]{ Plots daily pivot values on intraday charts } { Apply only to weekday data: MetaStock -> Tools -> Options -> Chart Options -> untick "Ignore weekend data" } { With thanks to Kevin Barry for pivot logic.} { ©Copyright 2004~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://metastocktools.com } { User input } pds:=Input("Use Highest/Lowest of past x days",1,260,1); { Message } message:=Input("(Plot on intraday charts)",0,0,0); { Day's true start } dStart:=DayOfMonth()<>Ref(DayOfMonth(),-1); { Previous x Days' High } Hd:=HighestSince(pds,dStart,H); Hd:=ValueWhen(1,dStart,ValueWhen(2,1,Hd)); Hd:=ValueWhen(1,Hd>0,Hd); { Previous x Days' Low } Ld:=LowestSince(pds,dStart,L); Ld:=ValueWhen(1,dStart,ValueWhen(2,1,Ld)); Ld:=ValueWhen(1,Ld>0,Ld); { Previous Day's Close } Cd:=ValueWhen(1,dStart,ValueWhen(2,1,C)); Cd:=ValueWhen(1,Cd>0,Cd); { Pivot } Pivot:=(Hd+Ld+Cd)/3; {Plot in Green bold} { Support } S1:=2*Pivot-Hd; {Blue} S2:=Pivot-(Hd-Ld); {Red} S3:=2*Pivot-(2*Hd-Ld); {dark Green} { Resistance } R1:=2*Pivot-Ld; {Blue} R2:=Pivot+(Hd-Ld); {Red} R3:=2*Pivot+(Hd-2*Ld); {dark Green} {All mid-pivot levels light Grey} M0:=(S2+S3)/2; M1:=(S1+S2)/2; M2:=(Pivot+S1)/2; M3:=(R1+Pivot)/2; M4:=(R2+R1)/2; M5:=(R3+R2)/2; { Plot on intraday price charts } R3;M5;R2;M4;R1;M3; Pivot; M2;S1;M1;S2;M0;S3 [/code:1:cb2a1298a6] jose '-)
Jose  
#5 Posted : Friday, October 14, 2005 12:43:06 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 this is the Weekly pivots equivalent: [code:1:36e274f20c]{ Plots weekly pivot values on EOD charts } { ©Copyright 2004~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://metastocktools.com } { User input } pds:=Input("Use Highest/Lowest of past x weeks",1,260,1); { Message } message:=Input("(Plot on EOD charts)",0,0,0); { Week's true start } WkStart:=DayOfWeek()<Ref(DayOfWeek(),-1); { Previous x Week' High } Hd:=HighestSince(pds,WkStart,H); Hd:=ValueWhen(1,WkStart,ValueWhen(2,1,Hd)); Hd:=ValueWhen(1,Hd>0,Hd); { Previous x Week' Low } Ld:=LowestSince(pds,WkStart,L); Ld:=ValueWhen(1,WkStart,ValueWhen(2,1,Ld)); Ld:=ValueWhen(1,Ld>0,Ld); { Previous Week's Close } Cd:=ValueWhen(1,WkStart,ValueWhen(2,1,C)); Cd:=ValueWhen(1,Cd>0,Cd); { Pivot } Pivot:=(Hd+Ld+Cd)/3; {Plot in Green bold} { Support } S1:=2*Pivot-Hd; {Blue} S2:=Pivot-(Hd-Ld); {Red} S3:=2*Pivot-(2*Hd-Ld); {dark Green} { Resistance } R1:=2*Pivot-Ld; {Blue} R2:=Pivot+(Hd-Ld); {Red} R3:=2*Pivot+(Hd-2*Ld); {dark Green} {All mid-pivot levels light Grey} M0:=(S2+S3)/2; M1:=(S1+S2)/2; M2:=(Pivot+S1)/2; M3:=(R1+Pivot)/2; M4:=(R2+R1)/2; M5:=(R3+R2)/2; { Plot on intraday price charts } R3;M5;R2;M4;R1;M3; Pivot; M2;S1;M1;S2;M0;S3 [/code:1:36e274f20c] jose '-)
zoomtop  
#6 Posted : Monday, November 7, 2005 8:17:45 AM(UTC)
zoomtop

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 10/10/2005(UTC)
Posts: 3

I know I have taken an age but I have managed to modify these formulas to do most of what I want to do. Thanks for your help Jose, perhaps you knew better what I was looking for than I! I have not been able to apply them fully though and the key has I am afraid to say eluded me. I have managed to learn how to use "copy and past" and resigned from forum administration though, now just a member! Moving forward as you can see! Next post I will see if I can use those damn little emoticons! Is it possible to apply the input "x" periods to the indicator? ie. Rather than being a weekly indicator calculating over "x periods" it becomes an "x period indicator"? Same for the daily indicator, I have been unable to make it into an "x day" indicator as oposed to a daily indicator looking back over "x" periods. Is it possible to apply the input to the indicator length? I might know more than when I started but I am still very basic I think. Any assistance greatly appreciated. Zoom
Jose  
#7 Posted : Monday, November 7, 2005 10:01:49 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)
ZoomTop, without exception, the toughest part of my job is the transferral of my client's idea, from his/her mind to my own. Often this transfer process fails at no one's fault. For this lack of communication, we can thank 6 billion distinct and very different human operating systems on this planet. It's no wonder that no one can predict the markets with 100% certainty. Anyway, perhaps some of this code can be adapted to your needs: [code:1:cb2af83adc] ========================= OHLC at variable interval ========================= ---8<------------------------------ { OHLC at variable period intervals } {©Copyright 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("End-Of-Period (EOP) bar interval", 1,2600,5); type:=Input("EOP signal: [1]Static, [2]Dynamic",1,2,1); plot:=Input("plot: [1]OHLC, [2]EOP signals", 1,2,1); { Static - count bars forward from first bar } countForward:=Cum(1); { Dynamic - count bars back from last bar } countBackward:=LastValue(Cum(1))-Cum(1)+1; { Choose Dynamic/Static } count:=If(type=1,countForward,countBackward); { Signal at x period intervals } signal:=count/pds=Int(count/pds); { OHLC values at x period intervals } Op:=ValueWhen(1,signal,Ref(O,-pds)); Op:=ValueWhen(1,Op>0,Op); Hi:=ValueWhen(1,signal,Ref(HHV(H,pds),-1)); Hi:=ValueWhen(1,Hi>0,Hi); Lo:=ValueWhen(1,signal,Ref(LLV(L,pds),-1)); Lo:=ValueWhen(1,Lo>0,Lo); Cl:=ValueWhen(1,signal,Ref(C,-1)); Cl:=ValueWhen(1,Cl>0,Cl); { Plot on price charts } If(plot=1,Op,signal); If(plot=1,Hi,signal); If(plot=1,Lo,signal); If(plot=1,Cl,signal) ---8<------------------------------ [/code:1:cb2af83adc] jose '-)
nick_s  
#8 Posted : Monday, July 20, 2009 11:44:26 PM(UTC)
nick_s

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/14/2006(UTC)
Posts: 3

Hi Jose,
I wonder if this code can be modified so the Weekly Pivot levels for next week will be plotted on charts on Friday evening. It is Monday evening now and the plots have only turned towards the levels for this week. No horizontal lines yet on my charts.
I think they should show on charts for the whole week right after the previous week ended because that's when they will be calculated and they won't change until next Friday after the close of the markets.
Also, all lines are the same color in Metastock 10.

Thanks for help.

Nick
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.