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

Notification

Icon
Error

3 Pages123>
Options
Go to last post Go to first unread
oradba  
#1 Posted : Thursday, May 26, 2005 5:08:35 AM(UTC)
oradba

Rank: Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 13

Hi, can anyone share good divergence formula with me? Thank you in advance oradba
wabbit  
#2 Posted : Thursday, May 26, 2005 8:12:59 AM(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)
I have always had trouble getting my head around divergence, and how to exactly define it. I have, in the past, used simple ROC() functions to find when one indicator is moving in the same/different direction than another indicator. Then, it progressed on to using the ValueWhen() function to find the values of the most recent troughs/peaks of the two indicators and finding the directionality of the changes, identifying divergence. But then I kept tripping over the fact that when my new formula found, say troughs in one indicator they did not 'align' (with respect to time) with the peaks/troughs of the other indicator. This obviously gave false signals. Anyway, I gave up. But have a look at Jose's website http://www.metastocktools.com/ for his divergence formulas, or if you are looking specifically for MACD-Price divergence, he has a product for sale, details also at the site. Have a go at defining EXACTLY what you are looking for (you must be able to definately explain the terms peak, trough, etc) and then code it up usings Jose's excellent work as a template. Good luck. Hope this helps. wbbit :D
oradba  
#3 Posted : Thursday, May 26, 2005 8:34:53 AM(UTC)
oradba

Rank: Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 13

HI, Thanks....I have tried Jose's one already.....it seems excellent...I just try to find something different. cheers, oradba
minnamor  
#4 Posted : Thursday, May 26, 2005 9:17:28 AM(UTC)
minnamor

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 126
Location: Italy

In the April 2003 edition of Technical Analysis of Stocks and Commodities an article entitled "Detecting Breakouts" by Markos Katsanos gives five wyas of determining divergence and provides the formulae for three. These formulae are available in the internet including at Traders' Tips from TASC Magazine in www.equis.com.
oradba  
#5 Posted : Monday, May 30, 2005 1:23:06 AM(UTC)
oradba

Rank: Member

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 13

thank you guys... Have a nice trade oradba
billtrudeau  
#6 Posted : Tuesday, May 31, 2005 1:37:24 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

I have tried several divergence formulas and all do not match visual identification of divergence. I looked at Jose's formula and have not yet been able to follow all of the code. It seems as though he is using some functions that I don't find in the formula primer. Also, I don't see that there is a correlation between the time periods when the divergence occurs between the price and the indicator. Can anyone recommend a source that explains the code used in Jose's indicator?
Dan05  
#7 Posted : Friday, August 12, 2005 2:48:40 AM(UTC)
Dan05

Rank: Newbie

Groups: Registered, Registered Users
Joined: 8/12/2005(UTC)
Posts: 1

Hi Oradha, How have u find Jose's Divergence Kit? The charts on his website shows gd signal but personally I think performance depends much on the characteristic of the stock. Pls kindly reply to lhonara@yahoo.com.au. Tks. Dan
Jose  
#8 Posted : Friday, August 12, 2005 8:54:58 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)
billtrudeau wrote:
I have tried several divergence formulas and all do not match visual identification of divergence. I looked at Jose's formula and have not yet been able to follow all of the code. It seems as though he is using some functions that I don't find in the formula primer. Also, I don't see that there is a correlation between the time periods when the divergence occurs between the price and the indicator. Can anyone recommend a source that explains the code used in Jose's indicator?
Perhaps Bill may be talking about the free divergence formula at http://metastocktools.com/MetaStock/Divergence.txt , as the MACDH Divergence kit comes complete with a thorough explanation of the logic used in the kit. Anyway, this particular free indicator looks at divergence between price and indicator peaks/troughs - useful, but not that great in my experience. As with all Technical Analysis, there is no "correct" way to code specific strategies - it all comes down to what suits the trader personally. There are probably an infinite number of ways to define divergence between price and indicators (or price and other markets). The MACDH Divergence kit offers four very promising methods to detect divergence, and I have settled on only these four after researching & developing just about every imaginable combination. It should also be mentioned that when a divergence occurs in the market, it is not necessarily a signal that the chart is about to reverse. Divergence signals are contrarian by nature, and thus their failure rate can be high. The trick is in finding a method that has a reasonably good ratio of successful to failed signals, and to have an exit strategy in place when these signals fail, which they have to eventually at some point in time in the future. Furthermore, divergence is all about entering a market (long or short) at a particular value point. When this occurs, and the signal proves to be a good one (as with oil long at US$50/barrel in May this year - http://metastocktools.com/#contrarian ), the windfall from entering at a value price can be phenomenal. jose '-) http://metastocktools.com/MACDH/MACDHdiverg.htm .
billtrudeau  
#9 Posted : Saturday, August 13, 2005 1:39:16 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Jose, The attached indicator is the approach that I have taken thus far. It would be nice to have a loop function to simplify the formula. I started this over at Patrick’s Formula Tutorial 3. I use the Ultimate Oscillator for illustration purposes only. I am trying to add filters to eliminate some of the poor signals, but this works fine to draw my attention to potential trades which I can screen visually. Bill Ultimate Oscillator Divergence Buy H/L [code:1:d3c135e066]If(( Ult(7,14,28) <50 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(2,Ult(7,14,28),15) AND (Trough(2,Ult(7,14,28),15) <> Ref(Trough(2,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(2,Trough(2,Ult(7,14,28),15)<>Ref(Trough(2,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(3,Ult(7,14,28),15) AND (Trough(3,Ult(7,14,28),15) <> Ref(Trough(3,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(3,Trough(3,Ult(7,14,28),15)<>Ref(Trough(3,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(4,Ult(7,14,28),15) AND (Trough(4,Ult(7,14,28),15) <> Ref(Trough(4,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(4,Trough(4,Ult(7,14,28),15)<>Ref(Trough(4,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(5,Ult(7,14,28),15) AND (Trough(5,Ult(7,14,28),15) <> Ref(Trough(5,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(5,Trough(5,Ult(7,14,28),15)<>Ref(Trough(5,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(6,Ult(7,14,28),15) AND (Trough(6,Ult(7,14,28),15) <> Ref(Trough(6,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(6,Trough(6,Ult(7,14,28),15)<>Ref(Trough(6,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(7,Ult(7,14,28),15) AND (Trough(7,Ult(7,14,28),15) <> Ref(Trough(7,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(7,Trough(7,Ult(7,14,28),15)<>Ref(Trough(7,Ult(7,14,28),15),-1),L))) OR (Ult(7,14,28)<0 AND Ult(7,14,28)<1.0*Mov(Ult(7,14,28),9,E) AND (Trough(1,Ult(7,14,28),15)>Trough(8,Ult(7,14,28),15) AND (Trough(8,Ult(7,14,28),15) <> Ref(Trough(8,Ult(7,14,28),15),-1)) AND ValueWhen(1,Trough(1,Ult(7,14,28),15)<>Ref(Trough(1,Ult(7,14,28),15),-1),L)<ValueWhen(8,Trough(8,Ult(7,14,28),15)<>Ref(Trough(8,Ult(7,14,28),15),-1),L))),-1,0)[/code:1:d3c135e066]
Jose  
#10 Posted : Saturday, August 13, 2005 9:07:58 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)
That's a lot of MS code in there, Bill - I'm sure it can be simplified. :) I don't have MetaStock with me here, but perhaps this simpler code below using variables will plot the same as the original, and make the author's intention clearer: [code:1:55b3e5b65b]{Ultimate Oscillator Divergence Buy H/L } { Variables } x:=Ult(7,14,28); tr1:=Trough(1,x,15); tr2:=Trough(2,x,15); tr3:=Trough(3,x,15); tr4:=Trough(4,x,15); tr5:=Trough(5,x,15); tr6:=Trough(6,x,15); tr7:=Trough(7,x,15); tr8:=Trough(8,x,15); trLo:=ValueWhen(1,tr1<>Ref(tr1,-1),L); { Condition } condition:=x<Mov(x,9,E) AND (x<50 AND tr1>tr2 AND tr2<>Ref(tr2 ,-1) AND trLo<ValueWhen(2,tr2<>Ref(tr2,-1),L) OR x<0 AND tr1>tr3 AND tr3<>Ref(tr3,-1) AND trLo<ValueWhen(3,tr3<>Ref(tr3,-1),L) OR x<0 AND tr1>tr4 AND tr4<>Ref(tr4,-1) AND trLo<ValueWhen(4,tr4<>Ref(tr4,-1),L) OR x<0 AND tr1>tr5 AND tr5<>Ref(tr5,-1) AND trLo<ValueWhen(5,tr5<>Ref(tr5,-1),L) OR x<0 AND tr1>tr6 AND tr6<>Ref(tr6,-1) AND trLo<ValueWhen(6,tr6<>Ref(tr6,-1),L) OR x<0 AND tr1>tr7 AND tr7<>Ref(tr7,-1) AND trLo<ValueWhen(7,tr7<>Ref(tr7,-1),L) OR x<0 AND tr1>tr8 AND tr8<>Ref(tr8,-1) AND trLo<ValueWhen(8,tr8<>Ref(tr8,-1),L)); { Plot on price chart } -condition[/code:1:55b3e5b65b] Two points stand out immediately with the code above: [code:1:55b3e5b65b]1) ValueWhen([b]Y[/b],trY<>Ref(trY,-1),L) (where "Y" = 2~8), may not be correct, as trough "Y" automatically finds the correct trough value "Y" troughs ago. Try replacing code in loops 2~8 with: ValueWhen([b]1[/b],trY<>Ref(trY,-1),L) {where "Y" = 2~8 in the loop series} 2) Avoid wherever possible the use of MetaStock's Peak & Trough functions, as these use the hindsight-based ZigZag funtion - not good for current signals.[/code:1:55b3e5b65b] jose '-) http://metastocktools.com/MACDH/MACDHdiverg.htm .
billtrudeau  
#11 Posted : Saturday, August 13, 2005 10:52:01 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Y" = 2~8), may not be correct, as trough "Y" automatically finds the correct trough value "Y" troughs ago. [/quote wrote:
I did not have this written the way it is now and had written it as you suggest but it did not work. I changed it to its present form and it seems to work properly, though I do not understand why. It is a lot of work to plot all components separately to see what is really happening, but I tried to do that. It would be a nice feature if MetaStock allowed plotting the individual components in separate windows during development without having to create a host of separate indicators based upon the components.
Quote:
2) Avoid wherever possible the use of MetaStock's Peak & Trough functions, as these use the hindsight-based ZigZag funtion - not good for current signals.
I understand this, and the arrows shown only occur when the bar after the arrow has been painted. The trade is entered on the next bar. This does not bother me because, though we don't get in at the absolute bottom, we still get into the trade near the bottom. Thanks for your input. It will take me a while to digest what you have suggested, but I appreciate your input.
billtrudeau  
#12 Posted : Saturday, August 13, 2005 1:24:12 PM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Jose, I pasted the code into MetaStock. The indicator did not plot. I will have to study your code to try to figure out what may be wrong. Hopefully this weekend I can devote sufficient time and will let you know. I looked at your website today, been there many times before, and while I agree that the divergence is no guarantee, I find that if the visual confirmation on the chart matches the indicator, the signal is likely to be good. You need something else to trigger an exit because not all turns result from divergence signals. Bill
billtrudeau  
#13 Posted : Sunday, August 14, 2005 2:03:43 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Jose, The formula that you posted lost the 50 value check after the first condition. For instance, "OR x<0" should be "OR x<50" at each instance. The formula did not plot for me because I omitted the last line "-condition" which plots the indicator. After making the changes, the indicator plotted fine. In fact, you actually obtained more signals than I did. Will have to try to find out why. Something for me to do while watching the PGA tomorrow. You solution is very elegant. Which planet did you come from? This will allow me to look back in time even further because the way I wrote the formula, I ran out of space and had to break the formula up into a buy formula and a sell formula. Perhaps with your method I can get everything into one formula. I also want to add a filter that determines if there has been an intermediate trough that falls below the line connecting the two troughs that generate the signal. This would eliminate some faulty signals. There may be other filters that will work. I had included a factor of 1 in the moving average check because I played around with increasing this value to see if it weeded out some bad signals. I also played around with the length of time used in the moving average, but the formula was not particularly sensitive to values different from the value of 9 periods. Once again, thanks for your help. Seems to be a lot more that you can do with the metastock formula language if you are creative.
Jose  
#14 Posted : Sunday, August 14, 2005 9:48:09 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)
-condition" which plots the indicator. [/quote wrote:
This is a common error when copying and pasting in Windows using the mouse cursor - it often fails to capture the last line of code. Ctrl-A (highlight all) & Ctrl-C (copy) avoids this problem.
Originally Posted by: OR (Ult(7,14,28)< Go to Quoted Post
{Ultimate Oscillator Divergence Buy Low } { Variables } x:=Ult(7,14,28); tr1:=Trough(1,x,15); tr2:=Trough(2,x,15); tr3:=Trough(3,x,15); tr4:=Trough(4,x,15); tr5:=Trough(5,x,15); tr6:=Trough(6,x,15); tr7:=Trough(7,x,15); tr8:=Trough(8,x,15); trLo:=ValueWhen(1,tr1<>Ref(tr1,-1),L); { Condition } condition:= x<Mov(x,9,E) AND x<50 AND (tr1>tr2 AND tr2<>Ref(tr2,-1) AND trLo<ValueWhen(2,tr2<>Ref(tr2,-1),L) OR tr1>tr3 AND tr3<>Ref(tr3,-1) AND trLo<ValueWhen(3,tr3<>Ref(tr3,-1),L) OR tr1>tr4 AND tr4<>Ref(tr4,-1) AND trLo<ValueWhen(4,tr4<>Ref(tr4,-1),L) OR tr1>tr5 AND tr5<>Ref(tr5,-1) AND trLo<ValueWhen(5,tr5<>Ref(tr5,-1),L) OR tr1>tr6 AND tr6<>Ref(tr6,-1) AND trLo<ValueWhen(6,tr6<>Ref(tr6,-1),L) OR tr1>tr7 AND tr7<>Ref(tr7,-1) AND trLo<ValueWhen(7,tr7<>Ref(tr7,-1),L) OR tr1>tr8 AND tr8<>Ref(tr8,-1) AND trLo<ValueWhen(8,tr8<>Ref(tr8,-1),L)); { Plot Long divergence signals in own window } condition[/code:1:734599fd17] jose '-) http://metastocktools.com/#metastock
billtrudeau  
#15 Posted : Sunday, August 14, 2005 10:04:20 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Originally Posted by: OR (Ult(7,14,28)< Go to Quoted Post
Jose, your are correct. I have been playing around with this with so many different indicators that when I applied it to the Ultimate Oscillator I failed to change 0 to 50. Some of the other indicators have positive and negative values and 0 was a good value to use to weed out buy and sell levels. The Ultimate Oscillator is bound between 0 and 100 with 50 being a good filter. The point of all this is that with the organization of the formula that you presented, it is much easier to check the formula and make changes, in addition to the formula involving many fewer lines. Once again, thanks. :
billtrudeau  
#16 Posted : Sunday, August 14, 2005 10:19:35 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Jose, One final note. For those following this discussion, the last formula that you posted omitted the negative sign on condition. This only matters if you develop the similar formula for sell signals. I have used the convention that -1 is buy and +1 is sell. I made the changes to my formula, 0 to 50, and added the negative sign to yours and the formulas produce identical results. So, I am one happy camper. :D
maxwells  
#17 Posted : Monday, August 15, 2005 4:19:38 AM(UTC)
maxwells

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 1

Hi Can you post you version wich include the sell signal. Tkx Maxime Chartrand maxime_chartrand@hotmail.com
Jose  
#18 Posted : Monday, August 15, 2005 8:43:33 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)
billtrudeau wrote:
The point of all this is that with the organization of the formula that you presented, it is much easier to check the formula and make changes, in addition to the formula involving many fewer lines.
Excellent. 8:-) You could also try adding some user inputs (or set variables in Experts/Explorations), which allows for much easier/faster experimenting. [code:1:b8a06eb86e] { Ultimate Oscillator Divergence Buy Low } { Note: first trough is dynamic } { User inputs } TrPer:=Input("Trough %",0,100,15); pds1:=Input("Ultimate periods 1",1,260,7); pds2:=Input("Ultimate periods 2",1,260,14); pds3:=Input("Ultimate periods 3",1,260,28); { Variables } x:=Ult(pds1,pds2,pds3); tr1:=Trough(1,x,TrPer); tr2:=Trough(2,x,TrPer); tr3:=Trough(3,x,TrPer); tr4:=Trough(4,x,TrPer); tr5:=Trough(5,x,TrPer); tr6:=Trough(6,x,TrPer); tr7:=Trough(7,x,TrPer); tr8:=Trough(8,x,TrPer); trLo:=ValueWhen(1,tr1<>Ref(tr1,-1),L); { Entry Long condition } buy:= x<Mov(x,9,E) AND x<50 AND (tr1>tr2 AND tr2<>Ref(tr2,-1) AND trLo<ValueWhen(2,tr2<>Ref(tr2,-1),L) OR tr1>tr3 AND tr3<>Ref(tr3,-1) AND trLo<ValueWhen(3,tr3<>Ref(tr3,-1),L) OR tr1>tr4 AND tr4<>Ref(tr4,-1) AND trLo<ValueWhen(4,tr4<>Ref(tr4,-1),L) OR tr1>tr5 AND tr5<>Ref(tr5,-1) AND trLo<ValueWhen(5,tr5<>Ref(tr5,-1),L) OR tr1>tr6 AND tr6<>Ref(tr6,-1) AND trLo<ValueWhen(6,tr6<>Ref(tr6,-1),L) OR tr1>tr7 AND tr7<>Ref(tr7,-1) AND trLo<ValueWhen(7,tr7<>Ref(tr7,-1),L) OR tr1>tr8 AND tr8<>Ref(tr8,-1) AND trLo<ValueWhen(8,tr8<>Ref(tr8,-1),L)); { Plot Long divergence signals in own window } buy [/code:1:b8a06eb86e] The sell side of this indicator would look something like this (code needs verification - I don't have MetaStock with me here): [code:1:b8a06eb86e] { Ultimate Oscillator Divergence Sell High } { Note: first peak is dynamic } { User inputs } PkPer:=Input("Peak %",0,100,15); pds1:=Input("Ultimate periods 1",1,260,7); pds2:=Input("Ultimate periods 2",1,260,14); pds3:=Input("Ultimate periods 3",1,260,28); { Variables } x:=Ult(pds1,pds2,pds3); pk1:=Peak(1,x,PkPer); pk2:=Peak(2,x,PkPer); pk3:=Peak(3,x,PkPer); pk4:=Peak(4,x,PkPer); pk5:=Peak(5,x,PkPer); pk6:=Peak(6,x,PkPer); pk7:=Peak(7,x,PkPer); pk8:=Peak(8,x,PkPer); pkHi:=ValueWhen(1,pk1<>Ref(pk1,-1),H); { Exit Long condition } sell:= x>Mov(x,9,E) AND x>50 AND (pk1<pk2 AND pk2<>Ref(pk2,-1) AND pkHi>ValueWhen(2,pk2<>Ref(pk2,-1),H) OR pk1<pk3 AND pk3<>Ref(pk3,-1) AND pkHi>ValueWhen(3,pk3<>Ref(pk3,-1),H) OR pk1<pk4 AND pk4<>Ref(pk4,-1) AND pkHi>ValueWhen(4,pk4<>Ref(pk4,-1),H) OR pk1<pk5 AND pk5<>Ref(pk5,-1) AND pkHi>ValueWhen(5,pk5<>Ref(pk5,-1),H) OR pk1<pk6 AND pk6<>Ref(pk6,-1) AND pkHi>ValueWhen(6,pk6<>Ref(pk6,-1),H) OR pk1<pk7 AND pk7<>Ref(pk7,-1) AND pkHi>ValueWhen(7,pk7<>Ref(pk7,-1),H) OR pk1<pk8 AND pk8<>Ref(pk8,-1) AND pkHi>ValueWhen(8,pk8<>Ref(pk8,-1),H)); { Plot Long divergence signals in own window } -sell [/code:1:b8a06eb86e]
Quote:
I have used the convention that -1 is buy and +1 is sell.
I usually use +1 for entries, -1 for exits. Use whatever works best for you personally. :) jose '-) http://metastocktools.com .
billtrudeau  
#19 Posted : Monday, August 15, 2005 4:29:17 PM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Before Jose streamlined my formula, I had tried to include the buy and sell into one formula but the formula was too long to be accepted by MetaStock. Prior to Jose's last post, I re-wrote my sell formula along the lines of Jose's code for the buy formula and tried to incorporate both buy and sell into one formula. This resulted in a MetaStock error saying that the number of defined variables had been exceeded. So, unless there is another trick it may be necessary to have a buy signal formula and a sell signal formula and plot them in the same window.
billtrudeau  
#20 Posted : Sunday, August 28, 2005 10:36:37 AM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Refinements to the formula that I would like to add include a check to see if the values, indicator and price, used to define a divergence make sense. For example, say the fifth look back instance defined a buy. The formula does not tell you which comparison defined the buy, but lets say you looked at the chart and determined that it was the fifth. Let us assume that you draw the trendlines representing the fifth look back and either there were significantly lower indicator values between the current indicator value and the value five occurences ago or the price contained significantly lower values. This would seem to indicate a situation where I would not want to consider this a valid divergence. If you were checking for a double bottom it would be possible to check if there were values below the defined double bottom for the values in between the last and fifth occurence. With a slopped trendline, this would be a more complicated task. Has anyone seen an approach for this type of test or would there be a way to plot the trendlines from the values resulting in a buy so that you could visually see if the resulting buy/sell made sense from a true divergence point of view? Thanks for any thoughts.
Users browsing this topic
Guest (Hidden)
3 Pages123>
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.