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

Notification

Icon
Error

Options
Go to last post Go to first unread
TheNovice  
#1 Posted : Sunday, March 6, 2005 12:07:57 AM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

I am trying to write a daily pivot indicator for MetaStock, However, I want the display to auto scale to the price and not the indicator (otherwise the price would be squashed considerably). I mean if the indicator is not in the price range it should not be displayed. For example a simple line indicator might be: Test :=0; Test Which will plot a 0 line even of the price is at 10000! I have noticed that if you actually draw a trend line at 0 it will not be shown until it comes within the price range. Can anybody help? Many thanks
Patrick  
#2 Posted : Monday, March 7, 2005 3:56:22 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Hi, I would love to try and help you, but I'm really confused as to what you are asking for. Would it be possible for you to post a specific example I can look at? Thank you
TheNovice  
#3 Posted : Monday, March 7, 2005 5:02:55 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Hi Thanks for getting back to me. Suppose I am looking at Dow Future. It currently stands at say 10500. The daily pivot indicator calculates the pivots for today based on yesterday prices and they are for example: 10400 10502 10550 10800 If I plot the daily pivot indicator on the price chart (Merge with scale on the left “price” to see the relation between the price and the pivot) the display will zoom to at least 10400 to 10800 (pivots) even if the price range in the displayed window is 10490-10510. What I really want is the display to show only 10502 pivot as it is the only one within the price range. The options: 1- Display New Scale 2- Overlay without scale Are not suitable, as it would distort the relative relation between the price and the indicator. If the above is still confusing please let me know. Regards
Patrick  
#4 Posted : Monday, March 7, 2005 6:38:49 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
What about something like : PivotA:={your Formula}; PivotB:={your Formula}; PivotC:={your Formula}; PivotD:={your Formula}; Min(Abs(C-PivotA), Min(Abs(C-PivotB), Min(Abs(C-PivotC),Abs(C-PivotD)))) It might useful to know how you calculate these pivots too, but that might work. Let me know.
TheNovice  
#5 Posted : Monday, March 7, 2005 8:34:05 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Hi Here is my formula for the pivots: Start:=DayOfWeek()<>Ref(DayOfWeek(),-1); Hi := ValueWhen(1,Start, Ref(HighestSince(1,Start,H),-1)); Lo := ValueWhen(1,Start, Ref(LowestSince(1,Start,L),-1)); Clse := ValueWhen(1,Start, Ref(C,-1)); Pivot := (Hi+Lo+Clse)/3; R1 := 2*Pivot -Lo; S1 := 2*Pivot -Hi; R2 := Pivot + (Hi-Lo); S2 := Pivot - (Hi - Lo); Min(Abs(C-Pivot), Min(Abs(C-R1), Min(Abs(C-S1), Min(Abs(C-R2), Abs(C-S2) )))) Your code prints the minimum difference to the close and not the actual pivot points (I suppose it can be modified to print the actual pivot). However, it is still display scale independent, I mean, if for example two pivots are within the display window (price), only the one closest to the close will print and not both of them. Also if the nearest pivot is 50 points away, the display will shrinks to show it. Regards
Patrick  
#6 Posted : Monday, March 7, 2005 8:51:21 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
I guess we could do a filter where if Pivot is % greater or lower than price then do not plot it. If you want to plot all the pivots values but do not want the chart to be shrunk, I don't think it is possible. And if it is what you want then should just quit here. ( Though someone else might have a solution ... ) Now if you only want the pivots within a reasonable % of the price we should be able to do something like that.
TheNovice  
#7 Posted : Monday, March 7, 2005 9:01:39 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

OK Suppose we want to include a filter that only print pivots that are a maximum of 30 points away from the close price how do we do it?(I mean if a pivot is not found within +-30 points of the close, no pivots is printed). I did do a code which I can post that does what you suggest but I could not turn off the indicator and had to default to the closest pivot to the close.
Patrick  
#8 Posted : Monday, March 7, 2005 9:04:35 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Do you mind posting that code? I will take a look at it and see what I can do. Thanks
TheNovice  
#9 Posted : Monday, March 7, 2005 9:52:22 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Here is my code: Period := Input("Period " ,2 ,150 ,60 ); Distance := Input("Distance " ,5 ,100 ,30 ); Start:= DayOfWeek()<>Ref(DayOfWeek(),-1); Hi := ValueWhen(1,Start, Ref(HighestSince(1,Start,H),-1)); Lo := ValueWhen(1,Start, Ref(LowestSince(1,Start,L),-1)); Clse := ValueWhen(1,Start,Ref(C,-1)); Pivot := (Hi+Lo+Clse)/3; R1 := 2*Pivot -Lo; S1 := 2*Pivot -Hi; R2 := Pivot + (Hi-Lo); S2 := Pivot - (Hi - Lo); HiPeriod := HHV(H,Period)+Distance; LoPeriod := LLV(L,Period)-Distance; Default := If(R1<HiPeriod AND R1>LoPeriod,R1, If(R2<HiPeriod AND R2>LoPeriod,R2, If(S1<HiPeriod AND S1>LoPeriod,S1, If(S2<HiPeriod AND S2>LoPeriod,S2, Pivot ) ) ) ); HiPeriod := HiPeriod-Distance; LoPeriod := LoPeriod+Distance; If(Abs(Pivot- HiPeriod)<Distance,Pivot,Default); If(Abs(R1- HiPeriod)<Distance OR Abs(R1- LoPeriod)<Distance,R1,Default); If(Abs(R2- HiPeriod)<Distance OR Abs(R2- LoPeriod)<Distance,R2,Default); If(Abs(S1- HiPeriod)<Distance OR Abs(S1- LoPeriod)<Distance,S1 ,Default); If(Abs(S2- HiPeriod)<Distance OR Abs(S2- LoPeriod)<Distance,S2 ,Default); It is a bit more complicated. Since I do not know what is the current display price range is I ask for a loopback period (variable Period). And I try to find at least a pivot within that range to use as default, If I do not find any and since I can not turn the indicator off I have chosen Pivot as my default value. The above code is by no means elegant. It is much better to see what is the range of prices currently being displayed and show only relevant pivots. Disadvantages of the above code so far are: 1- The default pivot could be far off from the current price if the price has been rising or falling significantly compare to yesterday range. 2- As the price moves, the default pivot position might change and you could see lines joining the Pivots gone out of range to the default value. 3- Any other things that you might come up or I can not remember now!
TheNovice  
#10 Posted : Monday, March 7, 2005 10:29:35 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Also, is there any command or external program allowing Metastock to replay tick data (like Sierra charts or trade station)? I need that to practice my realtime chart reading skill.
Patrick  
#11 Posted : Tuesday, March 8, 2005 5:47:15 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
This formula here is the same as the one you posted : ( Just less confusing and it will be easier to fix this one ) Pivot :=(Ref(H,-1)+Ref(L,-1)+Ref(C,-1))/3; R1:=2*Pivot-Ref(L,-1); S1:=2*Pivot-Ref(H,-1); R2:=Pivot+(Ref(H,-1)-Ref(L,-1)); S2:=Pivot-(Ref(H,-1)-Ref(L,-1)); R1;S1;R2;S2;Pivot I unfortunately have to go right now but I will try to give an answer on this by the end of the day. Patrick
TheNovice  
#12 Posted : Tuesday, March 8, 2005 5:57:05 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Hi Patrick Perhaps I did not explain this but, I look at intraday data i.e. 3 or 5 minutes charts (day trading) and not dailys. The pivots are calculated based on the previous day Hi, Low and Close. Perhaps that’s why it become complicated.
Patrick  
#13 Posted : Tuesday, March 8, 2005 9:32:50 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Ah I see, now I feel extra dumb :lol: In any case, let see what we can do :)
Patrick  
#14 Posted : Tuesday, March 8, 2005 10:07:33 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Alright, hopefully I'm not making a fool of myself again ... I don't have realtime here at homeso I could not test it but I believe this should work or something similar. Period:=Input("Period",2,150,60); Distance:=Input("Distance",5,100,30); Start:= DayOfWeek()<>Ref(DayOfWeek(),-1); Hi:=ValueWhen(1,Start,Ref(HighestSince(1,Start,H),-1)); Lo:=ValueWhen(1,Start,Ref(LowestSince(1,Start,L),-1)); Clse:=ValueWhen(1,Start,Ref(C,-1)); Pivot:=(Hi+Lo+Clse)/3; R1 := 2*Pivot -Lo; S1 := 2*Pivot -Hi; R2 := Pivot + (Hi-Lo); S2 := Pivot - (Hi - Lo); HiPeriod:=HHV(H,Period)+Distance; LoPeriod:=LLV(L,Period)-Distance; R1Fix:=ValueWhen(1,R1>=LoPeriod AND R1<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(R1)); R2Fix:=ValueWhen(1,R2>=LoPeriod AND R2<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(R2)); S1Fix:=ValueWhen(1,S1>=LoPeriod AND S1<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(S1)); S2Fix:=ValueWhen(1,S2>=LoPeriod AND S2<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(S2)); PivotFix:=ValueWhen(1,Pivot>=LoPeriod AND Pivot<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(Pivot)); R1Fix; R2Fix; S1Fix; S2Fix; PivotFix; Let me know what you think.
TheNovice  
#15 Posted : Wednesday, March 9, 2005 10:34:40 PM(UTC)
TheNovice

Rank: Member

Groups: Registered, Registered Users
Joined: 3/5/2005(UTC)
Posts: 17

Hi Patrick Sorry I could not get back to you before, as I am travelling now and don't have an access to my computer, I will let you know next week. First impression, it seems that it displays the pivot for the current day only, we might have to modify it to work on all days to test strategies and etc. Jhon
ronaldjeremy  
#16 Posted : Tuesday, March 31, 2009 11:15:21 PM(UTC)
ronaldjeremy

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/19/2009(UTC)
Posts: 6

I am trying to do the exact same thing, and having the exact same problem.

How I get an indicator to behave like a trendline and not re-scale the y axis?

wabbit  
#17 Posted : Thursday, April 2, 2009 11:31:41 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
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.