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

Notification

Icon
Error

Options
Go to last post Go to first unread
dklugmann  
#1 Posted : Tuesday, October 11, 2005 2:19:13 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Hi I asked a question earlier in the week to do with support and resistance and was kindly helped by some people. I am now getting into the details of my formula. I basically want to create a formula that checks the closing price and sees how many times there was a peak or trough in the past at around that level (give or take a dollar) I have so far done this by setting 19 peak variables going back one peak each time and summarising a total count of how many peaks were near the close. I was just about to add trough variables and do the same thing but I have run out of variables and it doesn't seem like an elegant solution anyway. e.g peak1 := ABS(PEAK(1,C,5) - C) < 1 peak2 := ABS(PEAK(2,C,5) - C) < 1 .... peak19 := ABS(PEAK(19,C,5) - C) < 1 results := peak1 + peak2 + ... peak19 Is there a nice way to do this kind of thing, with looping or recursiveness or ref or PREV or something clever, more than the way I am doing. Hopefully where I can specify the number of peaks (or troughs) to look back at and not set a variable each time. Also I have no way of knowing how many peaks are contained in total on each chart given the percentage change I am looking for. I also eventually wanted to somehow highlight the peaks that were selected as being near the close on the actual graph itself (as returned by explorer when I do open chart) either with a short line or some kind of symbol at the relevant peak. I am unsure as to ow to go about this. Many thanks for any help. It's much appreciated. David
nobel_1101  
#2 Posted : Tuesday, October 11, 2005 4:45:59 PM(UTC)
nobel_1101

Rank: Member

Groups: Registered, Registered Users
Joined: 5/17/2005(UTC)
Posts: 24
Location: London

The Dev kit would be the tool to use here rather than the formula builder. You can use loops to search through a stock's entire date range for peaks or troughs. What you ask for sounds very much like something I want to build in the near future. I have a lot of work on at the moment, I am currently creating a trendline program but resistance and support lines are next on my list. One thing I was trying to think about was the significance of the peaks because the peak with minimum change = 20% is more significant than minimum change = 4%. Do you have a conceptual idea as to how to incorporate significance of the peaks into the forming of resistance lines? i.e. more significant peaks make a stronger buy short signal If you can come up with some ideas I don't mind creating the dll for you. My email address is nobel_1101@yahoo.co.uk
Jose  
#3 Posted : Tuesday, October 11, 2005 6:02:52 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)
No need for external formulae for this simple request. 8) Try this MS indicator: [code:1:06c76c70d6] ============================= Peak/Trough zone-strike count ============================= ---8<-------------------------- {©Copyright 2005 Jose Silva For private use only. http://www.metastocktools.com } { User inputs } level:=Input("Select price level: (0 = last Close)",0,100000,0); zone:=Input("Price strike zone, +/- % of price", .01,100,5)/100; pr:=Input("Peak/Trough %minimum change", .01,100,5); plot:=Input("[1]All Pk/Tr, [2]Zone Pk/Tr, [3]Strike count, [4]%",1,4,3); { Peaks, values } pk:=PeakBars(1,C,pr)=0; pkVal:=Peak(1,C,pr); { Troughs, values } tr:=TroughBars(1,C,pr)=0; trVal:=Trough(1,C,pr); { Price level } prLevel:=If(level=0,LastValue(C),level); { Price strike zone } ClHi:=prLevel*(1+zone); ClLo:=prLevel*(1-zone); { Peaks within price strike zone } pkZone:=pk AND pkVal>=ClLo AND pkVal<=ClHi; pkZonePer:=Cum(pkZone)/Max(Cum(pk),.00001)*100; { Troughs within price strike zone } trZone:=tr AND trVal>=ClLo AND trVal<=ClHi; trZonePer:=Cum(trZone)/Max(Cum(tr),.00001)*100; { Plot strike count in own window } If(plot=1,pk,If(plot=2,pkZone, If(plot=3,Cum(pkZone),pkZonePer))); -If(plot=1,tr,If(plot=2,trZone, If(plot=3,Cum(trZone),trZonePer))) ---8<-------------------------- [/code:1:06c76c70d6] jose '-)
dklugmann  
#4 Posted : Wednesday, October 12, 2005 2:12:54 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Many thanks for both of the replies. I'll definitely give the formula a go Jose. It looks really good. I'll try and give you some feedback Nobel. I'm also based in England so it would be nice to work on something together Nobel. Thanks for the kind offer of the DLL. I will be in touch. The Dev kit sounds interesting. As regards percentage change I hadn't though it through and had just settled on any change over 5%. Thanks again for the formula Jose. Regards David
dklugmann  
#5 Posted : Wednesday, October 12, 2005 2:19:09 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Jose One last thing. Can I use this formula in explorer or is it meant more as a plot on the graph. I saw the input function and I remember you can't use that with explorer. My original intention was to do an explorer search which returns me the shares and the number of hits close to the resistance zone if there was at least one previously Thanks again for the help. Regards David.
Jose  
#6 Posted : Wednesday, October 12, 2005 2:33:53 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)
David, it's always a good idea to visually verify how things work in MetaStock, by plotting the formula as an indicator below a chart. To use the above code in a Column exploration, just convert the user inputs into variables: [code:1:2637eaf02c] { Variables } level:=0; { Select price level: (0 = last Close) } zone:=5/100 { Price strike zone, +/- % of price } pr:=5; { Peak/Trough %minimum change } plot:=3; { [1]All Pk/Tr, [2]Zone Pk/Tr, [3]Strike count, [4]% } [/code:1:2637eaf02c] jose '-)
dklugmann  
#7 Posted : Wednesday, October 12, 2005 2:46:36 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Jose Thanks again for the formula, it's exactly what I was looking for. David
Jose  
#8 Posted : Wednesday, October 12, 2005 3:39:10 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)
You're welcome, David - it was fun putting it together. :) Say Nobel, how is it going with the MDK? Are you getting acquainted with it well enough to help Patrick & the team with the ForumDLL? jose '-)
nobel_1101  
#9 Posted : Wednesday, October 12, 2005 5:13:21 PM(UTC)
nobel_1101

Rank: Member

Groups: Registered, Registered Users
Joined: 5/17/2005(UTC)
Posts: 24
Location: London

Jose wrote:
Say Nobel, how is it going with the MDK? Are you getting acquainted with it well enough to help Patrick & the team with the ForumDLL? jose '-)
Hi Jose Yeah its going quite well. I bought it last month and I have made some progress despite moving house and working like a dog in my day job! I was meant to email Patrick yesterday about what I've done so far and about pooling our resources. In summary, I have created a zigzag function which utilises high and low prices instead of just one price. I am also aiming to make the zigzag function usable in system tests, i.e. resolve the problem of "seeing into the future". I have also created trough and peak functions using the new zigzag function. The above functions are going to be used to build much better trendline, resistance and support line functions and more hopefully (chart patterns, fibonnacci lines, etc). I have created the first build of my trendline program. Its a long term up trendline and works quite well except in a few cases. I am currently building a second version of trendline using new rules which should detect almost all trends. I can cc you in the email to Patrick if you're interested. Cheers Craig :)
Jose  
#10 Posted : Wednesday, October 12, 2005 5:38:15 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)
Thanks for the offer, Craig. Keep me out of any private mail for now, but I look forward to see what ensues here on the forum.
nobel_1101 wrote:
I have created a zigzag function which utilizes high and low prices instead of just one price.
How does it compare with the same function (ZigZag - Hi/Lo) using MetaStock code? And how does your dll ZigZag version deal with bars where the ZigZag High & Low fall on the same bar? jose '-)
nobel_1101  
#11 Posted : Wednesday, October 12, 2005 11:09:23 PM(UTC)
nobel_1101

Rank: Member

Groups: Registered, Registered Users
Joined: 5/17/2005(UTC)
Posts: 24
Location: London

Jose wrote:
How does it compare with the same function (ZigZag - Hi/Lo) using MetaStock code? And how does your dll ZigZag version deal with bars where the ZigZag High & Low fall on the same bar? jose '-)
Hi Jose Just had a look at the function. It works broadly similar except I have attached more importance to identifying the highest high points and lowest low points so I can identify full extent of a trading range. For example, when in a current up trend and the next price bar makes a slightly higher high but also makes a significantly lower low, I plot the higher high in the Zigzag as I want the line to represent the whole trading range. I have ignored the fact that the same day brought a lower low since if that new low does signal a new down trend/move then the zigzag should be plotting the following day's low. Vice versa for current down trends/moves. Craig :
dklugmann  
#12 Posted : Sunday, October 16, 2005 12:13:40 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Jose Is there a way to print out the variables as columns in the explorer to show the results ? i.e trZonePer, Cum(trZone) and Cum(tr) It doesn't seem to like variable names as columns. Thanks David
Jose  
#13 Posted : Sunday, October 16, 2005 12:26:26 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)
[code:1:214f111837] { Variables reference from "Peak/Trough zone-strike count" indicator } trZonePer:=FmlVar("Peak/Trough zone-strike count","TRZONEPER"); trZone:=FmlVar("Peak/Trough zone-strike count","TRZONE") ; tr:=FmlVar("Peak/Trough zone-strike count","TR") ; { Choose from 3 outputs: } trZonePer; Cum(trZone); Cum(tr) [/code:1:214f111837] jose '-)
dklugmann  
#14 Posted : Sunday, October 16, 2005 2:00:12 PM(UTC)
dklugmann

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 10/6/2005(UTC)
Posts: 30

Jose Thanks for the quick reply. I am not having much luck with the results I am getting and I am conscious of taking up your time. Can we take this via your site metastocktools and I can pay you for the time you spend guiding me through to a solution. Thanks David
Jose  
#15 Posted : Sunday, October 16, 2005 2:20:40 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)
Sure, David - please email me at [color=green:017da48968]jose at MetaStockTools.com[/color], and we'll take it from there. Completed work is usually returned to the client in the form of self-installing MetaStock files, so you won't have to deal with the problem you have experienced so far. 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.