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

Notification

Icon
Error

Options
Go to last post Go to first unread
MarkC  
#1 Posted : Wednesday, December 14, 2005 11:18:23 PM(UTC)
MarkC

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/19/2005(UTC)
Posts: 5

I'm new to Metastock and have no programming ability, trying to write my own indicators/expert signals so I don't have to have a dozen indicator windows open on the same chart. I can have an indicator (say Williams %R) on a chart, then plot a moving average over it without any problem, using the indicator crossing the average as a signal. But when I write this: Cross( WillR(14), Mov(CLOSE, 30,E) ) A signal never shows up. Yet when when I create a Williams %R window on a chart, then drag the moving average indicator over it (so %R turns pink), that works fine. There are plenty of crossovers there. Help! :cryin:
hayseed  
#2 Posted : Wednesday, December 14, 2005 11:32:03 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey mark.... perhaps if your goal is a 30 ma of willr you should change close to willr(14).... Cross(WillR(14), Mov(WillR(14), 30,E))
MarkC  
#3 Posted : Wednesday, December 14, 2005 11:41:39 PM(UTC)
MarkC

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/19/2005(UTC)
Posts: 5

Thank you hayseed, very much appreciated. May I pick your (or someone else's brain) once more? How can I get this to generate a signal only when both values are less than, say -70? Mark
hayseed  
#4 Posted : Thursday, December 15, 2005 2:01:46 AM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey mark.... havin a heck of a time with that.... its almost like the indicators are not plotting correctly so its difficult to check.... the not ploting correctly part could be my influence.... i might be doing something wrong on the scale.... the code below should work but it appears to miss many signals.... i put in the input function so you could dabble with the values.... set the default the values you mentioned.... btw, i'm on the low end of the coding totem pole....h
periods:=Input("moving average",1,100,30); x:=Input("willr value",-100,1,-70); y:=Input("willr mov av value",-100,1,-70); WillR(14)<x AND Mov(WillR(14),periods,E)<y AND Cross(WillR(14),Mov(WillR(14),30,E)) ----------------
MarkC  
#5 Posted : Thursday, December 15, 2005 6:38:10 AM(UTC)
MarkC

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/19/2005(UTC)
Posts: 5

hayseed, Thanks for all your help -- I printed out the entire formula primer document and will attempt to learn as much as I can before making more forum postings. My brain seems to reject anything program-related but having good custom indicators will be worth the effort! Mark
johnl  
#6 Posted : Thursday, December 15, 2005 2:51:28 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Try something like this, I will let you change the hardcoded parms willr(14) to a "input". then change colors of the signals =================== periods:=Input("moving average",1,100,30); h1:=WillR(14); h2:=Mov(WillR(14),periods,E); h1s:=If(((Cross(h1,h2)=1) AND (HHV(h1,10)>-30)),0,-50); h2s:=If(((Cross(h2,h1)=1) AND (LLV(h1,10)<-70)),-100,-50); h1; h2; h1s; h2s ====================
sportrider  
#7 Posted : Friday, December 16, 2005 1:13:09 AM(UTC)
sportrider

Rank: Advanced Member

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

Hayseed , I was testing a formula yesterday that was written a little different but was looking for the same thing basically the same formula without "inputs"for about an hour yesterday in reply to Marks post but kept on getting different plots or no plots when it should have been true...it was missing some of the plots...finally I just gave up and didnt post anything.............Did you find out what was causing it?..I'm Just curious.
hayseed  
#8 Posted : Saturday, December 17, 2005 12:38:00 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey sportrider.... nope, ain't figured it out yet..... still trying..... noticed john's post on something similar, but my deal does not involve the close but rather a ma of the wilr.... had already tried jose's normalzation codes , they didn't seem to line up with the signals either.... i changed them up abit to suit the willr and mov av of willr..... kinda makes you wonder just how many other situations like this we are misreading so its worth seeing it to the end..... will holler back if i figure it out.....h
hayseed  
#9 Posted : Saturday, December 17, 2005 10:39:57 PM(UTC)
hayseed

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/7/2005(UTC)
Posts: 1,346

hey sportrider..... figured it out.... was barkin up the wrong tree..... the chart part was no problem, the ma of willr and willr will both plot perfectly with out any confusion.... and the codes were correct.... (Cross(WillR(14), Mov(WillR(14), 30,E))) and (willr(14)<-70) and (mov(willr(14),30,e)).... extra )'s intentional..... that will give you every , proper bias, cross when willr and mov of willr are both below -70 which was marks request.... my mistake was assuming some of the signals were missing..... the hitch is that often on the day of the cross, willr ends up above -70..... so then the statement above is not true and so the signal only appears missing..... the code below should fill in the crosses that occur on those days also..... h
x:=Ref(WillR(14),-1)<-70; y:=Ref(Mov(WillR(14),30,E),-1)<-70; (Cross(WillR(14),Mov(WillR(14),30,E))) AND x AND y ------------------------------------------------------------
sportrider  
#10 Posted : Monday, December 19, 2005 2:13:54 AM(UTC)
sportrider

Rank: Advanced Member

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

Thanks Hayseed, I 'm glad to hear that;I haven't had a chance to look at it again. Will try again with the new info.
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.