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

Notification

Icon
Error

Options
Go to last post Go to first unread
RUAGOODP  
#1 Posted : Friday, April 28, 2006 4:28:39 PM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Hi all, Please help me with this: I have 2 codes up:=h>ref(h,-1) and ref(h,-1)>ref(h,-2); down:=l<ref(l,-1) and ref(l,-1)<ref(l,-2); How do I find the highest price between up and down? Cheers Norman
StorkBite  
#2 Posted : Friday, April 28, 2006 5:12:27 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Try this: up:=if(h>ref(h,-1) and ref(h,-1)>ref(h,-2),H,0); dn:=if(l<ref(l,-1) and ref(l,-1)<ref(l,-2),L,0); if(up>dn,up,dn)
RUAGOODP  
#3 Posted : Saturday, April 29, 2006 1:11:15 AM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Hi Stockman, Unfortunately that code does not help. I am trying to use some of the code used by Jose in his metastock competition a while back where he codes the low and high of each month however try as I may I can't seem to achieve my purpose. Cheers Norman
StorkBite  
#4 Posted : Saturday, April 29, 2006 1:54:27 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Hi Norman- I don't want to waste your time. I just like trying to solve problems. Perhaps I really don't understand the problem at all in which case I'll step aside after this. See if this can help. I used the filter just as a check for me. ColA will report the high value when the condition is met; ColB will report the low value when the condition is met; ColC will report the higher of these two values. {ColA} ValueWhen(1,H<Ref(H,-1) AND Ref(H,-1)<Ref(H,-2),H); {ColB} ValueWhen(1,L<Ref(L,-1) AND Ref(L,-1)<Ref(L,-2),L); {ColC} up:=ValueWhen(1,H<Ref(H,-1) AND Ref(H,-1)<Ref(H,-2),H); dn:=ValueWhen(1,L<Ref(L,-1) AND Ref(L,-1)<Ref(L,-2),L); If(up>dn,up,dn) {Filter} colB>colA
RUAGOODP  
#5 Posted : Saturday, April 29, 2006 2:28:08 AM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Hi Stockman, Thanks for that. Basically what I am trying to do is find the peak between up {definition: h>ref(h,-1) and ref(h,-1)>ref(h,-2)} and down {definition: l<ref(l,-1) and ref(l,-1)<ref(l,-2) } The code should show binary spikes of +1 for these peaks. Then I want to create an indicator that gives a binary +1 spike when the closing price is higher than the previous peak.[color=black:ce79326c52][/color] Does that make sense? Cheers Norman
StorkBite  
#6 Posted : Saturday, April 29, 2006 4:39:13 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Ok. I think I understand better. Give me a sec... BRB. Ok... a few seconds... :) This is my final attempt. I can admit when I'm lost. Thanks for your patience. Hopefully one of the more experienced coders will fly in and save the day. { User inputs } plot:=Input("[1]Peak, [2]Signal",1,2,1); { Calculations } up:=ValueWhen(1,H<Ref(H,-1) AND Ref(H,-1)<Ref(H,-2),H); dn:=ValueWhen(1,L<Ref(L,-1) AND Ref(L,-1)<Ref(L,-2),L); pk:=Max(up,dn); { Plot } If(plot=1,pk, If(plot=2,C>pk,0));
sportrider  
#7 Posted : Saturday, April 29, 2006 4:39:57 AM(UTC)
sportrider

Rank: Advanced Member

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

RUAGOODP, Are you trying to define somthing like a peak with a pull back and then have metastock give a signal when the prior peak has been taking out??
Jose  
#8 Posted : Saturday, April 29, 2006 5:46:54 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)
Try this indicator code: [code:1:0eb8621f2d] ==================================== Highest/Lowest signals in retrospect ==================================== ---8<---------------------------------------- { Highest/Lowest signals/values in retrospect. ©Copyright 2006 Jose Silva. For personal use only. http://www.metastocktools.com } { User inputs } pds:=Input("Lookback periods",1,21,2); type:=Input("[1]Highest, [2]Lowest",1,2,1); plot:=Input("Hi/Lo [1]Signals [2]Values, [3]Orig Up/Dw signals",1,3,1); { Original signals } up:=Sum(H>Ref(H,-1),pds)=pds; down:=Sum(L<Ref(L,-1),pds)=pds; { Clean signals } init:=Cum(IsDefined(up+down))=1; bin:=ValueWhen(1,up-down<>0 OR init,up); up:=bin*(Alert(bin=0,2) OR up*Cum(up)=1); down:=(bin=0)*(Alert(bin,2) OR down*Cum(down)=1); { Hi/Lo price between original clean signals } a:=up+down; b:=Mod(Cum(a),2)*2-1; x:=Cum(1)>2; HiSignal:=x*Abs(Zig(b*(H>=HighestSince(1,a,H)),2,$))=1; HiVal:=ValueWhen(1,HiSignal,H); LoSignal:=x*Abs(Zig(b*(L<=LowestSince(1,a,L)),2,$))=1; LoVal:=ValueWhen(1,LoSignal,L); { Select Hi/Lo } signal:=If(type=1,HiSignal,LoSignal); value:=If(type=1,HiVal,LoVal); { Plot in own window } If(plot=1,signal,If(plot=2,value,up-down)) ---8<---------------------------------------- [/code:1:0eb8621f2d] jose '-)
RUAGOODP  
#9 Posted : Sunday, April 30, 2006 2:18:14 PM(UTC)
RUAGOODP

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/13/2005(UTC)
Posts: 87
Location: perth australia

Thanks all for your effort :D I think this is what I have been looking for. Please feel free to pick it apart Cheers Norman up:=H>Ref(H,-1) AND Ref(H,-1)>Ref(H,-2);{Short term uptrend} down:=L<Ref(L,-1) AND Ref(L,-1)<Ref(L,-2); {Short term downtrend} Init:=Cum(up+down>-1)=1; uptrend:=(BarsSince(Init OR up)<BarsSince(Init OR down));{In uptrend} Euptrend:=(Ref(uptrend,-1)=0 AND uptrend);{First entered uptrend} Edowntrend:=(Ref(uptrend,-1)=1 AND uptrend=0);{First entered downtrend} PPeak:=If(Edowntrend=1,HighestSince(1,Euptrend,H),PREV); {Previous Peak, highest high since uptrend began and trend reversed} Cross(C,PPeak){First close above previous peak};
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.