Momentum Divergence-Easylanguage to Metatsock

kvhutch

Junior member
Messages
35
Likes
0
Hi. I'm trying to formulate Price Headley's Momentum Divergence indicator (as outlined in his book 'Big Trends in Trading') in Metastock. Unfortunately, in his book he only outlines the Tradestation EasyLanguage code. Although it seems reasonably straight forward the resultant plot is clearly wrong.

(1) Does anyone have, or can they point me in the direction of the Metastock version of this indicator

alternatively

(2) Are there any easylanguage to metatstock conversion specialists out there that could analyse my code for possible errors? I'd be happy to post both the Tradestation code and my attempt .

Many Thanks
 
Hi Zambuck, thanks for your reply.
In effect the formula, according to Headley, normalises momentum readings across stocks between 0 and 100 (0=weak momentum, 100= strong momentum). Two lines are drawn: the momentum line and the price line. 2 other horizontal lines are also drawn signifying the 'Buyzone' at 30, and the 'Sell Zone' at 90.

Ok here's the Tradestation code first:

Input:FastMA(12), SlowMA(26), MacdMA(9), Input2(15), Buyzone(30), SellZone(90);

Value1=IFF(Highest(MACD(Close,FastMA,SlowMA),Input2) -
Lowest(MACD(Close,FastMA,SlowMA),Input2)<>0,Highest(MACD(Close,FastMA,SlowMA),Input2)
- Lowest(MACD(Close,FastMA,SlowMA),Input2),50);

Value2=IFF(Highest(Close,Input2) - Lowest(Close,Input2)<>0,
Highest(Close,Input2) - Lowest(close,Input2),50);

Plot1(100*(close-Lowest(close,Input2))/Value2,"Close%");

Plot2(100*(MACD(Close,FastMA,SlowMA) - Lowest(MACD(Close,FastMA,SlowMA),Input2))
/Value1,"MACD%");

Plot3(BuyZone "BuyZone");

Plot4(SellZone, "SellZone");

... and now my attempt at a Metastock conversion:

BuyZone:=30;
SellZone:=90;
Periods:=15;

HighestV1:= If(MACD()> Mov(C,Periods,E),MACD(),Mov(C,Periods,E));

LowestV1:= If(MACD()> Mov(C,Periods,E),Mov(C,Periods,E),MACD());

HighestV2:= If(C>Mov(C,Periods,E),C,Mov(C,Periods,E));

LowestV2:= If(C>Mov(C,Periods,E),Mov(C,Periods,E),C);

Value1:= If((HighestV1-LowestV1)<>0,HighestV1-LowestV1,50);

Value2:= If((HighestV2-LowestV2)<>0,HighestV2-LowestV2,50);

100*(C-LowestV2/Value2);
100*(MACD() - LowestV1/Value1);

BuyZone;
SellZone;

N.B.
(1) As I couldn't find a 'Highest' and 'Lowest' formula in the
context as used in Tradestation I used the result of an 'if' statement
and assigned the value to a valriable
(2) Within the formula I tried both the macd(), i.e. the indicator, and
the signal line (mov(macd(),9,E) neither of which appeear to work

Hope you can help
 
I think the TS code is as follows....

UpperBand:
Average((high*(1+2 * ((((high-low) / ((high+low) / 2)) * 1000) *. 0001))), 20)

LowerBand:
Average((low*(1-2 * ((((high-low) / ((high+low) / 2)) * 1000) *. 0001))), 20)

Perhps we can try the following.....I am not sure if it will be the same as TS code....but anyway here goes....you can try to see if you change the values....etc..

{For upper band}

Upperband:=(H*(1+2*((((H-L)/((H+L)/2))*1000)*0.001)));
Mov(Upperband, 20, S );

{For lower band}
Lowerband:=(L*(1-2*((((H-L)/((H+L)/2))*1000)*0.001)));
Mov(Lowerband, 20, S );

However the 'essence' of the code according to Paul Headly is as follows:

[font=Times New Roman, Times, serif]"Trading the VIX," by Price Headley: This is the system code (written in EasyLanguage for TradeStation), where Data1 is the OEX and Data2 is the VIX index.[/font]
[font=Arial, Helvetica, sans-serif]{Code by Price Headley, BigTrends.com}[/font]
[font=Arial, Helvetica, sans-serif]If Close of Data1 > Average(Close of Data1, 10) and Close of Data2[5] < BollingerBand(Close of Data2, 21, 2)[5] and Close of Data2[6] > BollingerBand(Close of Data2, 21, 2)[6] Then
Buy on Close of Data1;
[/font]
[font=Arial, Helvetica, sans-serif]If BarsSinceEntry = 5 and Close of Data1 < Close of Data1[5] Then
ExitLong on Close of Data1;
[/font]
[font=Arial, Helvetica, sans-serif]If Close of Data1 < Average(Close of Data1, 10) and Close of Data2[10] > BollingerBand(Close of Data2, 21, -2)[10] and Close of Data2[11] < BollingerBand(Close of Data2, 21, -2)[11] Then
Sell on Close of Data1;
[/font]
[font=Arial, Helvetica, sans-serif]If BarsSinceEntry = 5 and Close of Data1 > Close of Data1[5] Then
ExitShort on Close of Data1;
[/font]​
For metastock the two data must be reference to the 'correct' directory where it resides.....​
I will try something over the weekend....​
 
Hi Zambuck

The TS code you've formulated above is Price's 'Acceleration Bands' where he places two bands equidistant from the 20 day moving average. I've actually managed to progam that one into my system and it seems to work well. The system I'm curious about above is his 'Momentum Divergence' indicator (formulated in Tradestation as above in his book 'Big Trends in Trading') where the MACD is normalised over a range between 0 and 100. Just didn't seem to come out well when I tried to progam it. Can't figure it out.
 
Hi Zambuck

By trying to figure what the formula was trying to do 'in English' (always useful) I was able to figure it out. By 'normalising' I (eventually) realised the formula was simply charting a percentage movement over a given time frame. By finding the highest and lowest move within that period, the current position of the macd and price line could be plotted relative to these extremes. Thanks for your help
 
Hi kvhutch

I have been so busy with my business interests that my real interest in trading has taken a back step....and I am not happy about that as it takes ALL of my time....leaving me with no time at all to play with....formulae, explorations etc etc....

I intend to set wifey on business issues full time and devote my time on TA and other issues that are dear to me shortly....Hopefully that will work out ok...

So did you manage to create an indicator and a exploration?.....if so how did it work out?...

regards
 
zambuck

I did manage to create the indicator. In truth, I've been the owner of Metastock for about a week so I'm still working my way through the software. Thus far I'm very impressed (though the data download does take a while). Coming from a TC2000 background the concept of creating 'securities' took some getting used to. The one thing I think TC2000 does have over Metastock is the look and feel of the environment. Metastock strikes me as being a little clunky. TC2000 has a much smoother intrface. That said Metatstock is clearly orders of magnitude more sophisticated than TC2000. TC2000 does what it does very well without pretending to be anything else. However, wanting custom formulas and other necessities. Metastock was a natural choice for me.

Cheers
 
Hi kvhutch

I agree that MS is a very good value for money...and it's programming language is resonably well set up...although it could be better...

Metatstock is far ahead of other software suppliers who do not supply the coding facility, and the users have to rely on the 'Company' to provide them a indicator if they wish to use one....I....It is very impoortant for a TA software that a user has a facility to be able to programme an indicator and a exploration.....

Have you used Aroon and CMO.....??...These are the best ones to establish or filter out trending securities....
 
No, I've not tried Aroon or CMO. I may get around to it evetually. Currently trying to get the stock symbol to remain on the title bar as I scroll from one chart to the next in my 'results of last exploration' folder. Saves ok for the current security once you set it, but reverts to a default value when you scroll to the next. Hmmmmm.
 
If I have understood what you are trying to do then as follows....

Save exploration under favourites....and give it a unique name.....

On chart window, right click while your cursor is on title bar and select 'chart window properties and see options avilable....and set what yoy prefer....

If you have scroll wheel mouse then press ALT and scroll key to flick the securities list in a chart...
 
Momentum Divergences

hey kvhutch,

I am trying to figure out the momentum divergence code as described in Headley's book and would appreciate your help with this. I am a relatively small trader and do not have any of the tools like TS or MS, so I use MS excel. Could you please help me decipher this code?

Best..
ramraika
 
Top