Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/11/2005(UTC) Posts: 37
Was thanked: 1 time(s) in 1 post(s)
|
Hello.
Here's a flexible/variable DLL version for the inbuild MetaStock function Wilders.
Syntax:
ExtFml( "Wilders.Smoothing", PriceDataArray, Periods)
Example:
pds:=Input("Periods",1,99,14);
ExtFml( "Wilders.Smoothing", C, pds)
If you like to use pure MetaStock Code, you can build an indicator like this:
pds:=Input("Periods",1,99,14);
Field:=Input("Price Field: O=0, H=1, L=2,C=3",0,3,3);
a:=If(Field=0,O,If(Field=1,H,If(Field=2,L,C)));
b:=1/pds;
If(Cum(1)=1,b,PREV*(1-b)+a*b);
Just unzip the file and put it into the External DLL folder.
If Patrick likes to put the function into the Forum DLL, I'll sent him the code.
Enjoy
Chris :wink:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Hello Chris,
Thanks for your efforts for creating the DLL.
The DLL is working if we use the formula as given in the example:
pds:=Input("Periods",1,99,14);
ExtFml( "Wilders.Smoothing", C, pds)
However, if we use the following formula, we get error:
pds:=If(Cum(1)<14,Cum(1),14);
ExtFml( "Wilders.Smoothing", C, pds)
ERROR received:
"This variable or expression must contain only constant data."
Thanks again for providing the DLL.
Regards
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/11/2005(UTC) Posts: 37
Was thanked: 1 time(s) in 1 post(s)
|
@smg.
The error is corrected, a function call like
pds:=If(Cum(1)<14,Cum(1),14);
ExtFml( "Wilders.Smoothing", C, pds)
works now.
But: I plot the function (like the MS Version) only for bars, where cum(1) > pds :eek:
Enjoy
Chris
P.S: Old version 1.0 is no longer available for download
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Chris,
It is good, now the DLL accepts the values returned by the formula:
pds:=If(Cum(1)<14,Cum(1),14);
Values also appear to be same as the native MS Wilder's Smoothing, In the previous version there was slight difference during the initial bars.
However, still the plot begins only after the 14th bar. Incidentally the Variable Moving Average functions in the Forum DLL also had the same problem during initial releases. My 13th August post regarding the Forum DLL mentioned the same problem in the MA functions. Although the Trangular Moving Avaerage funtion in the Forum DLL may have some other problems at the moment, however the EMA function seems to be free of the similar problem now.
Further, you may want to look into another point that the plot for the above value of 14 starts at the 15th bar; native MS plot begin on the 14th bar, although native Wilder's Smoothing function does not accept values less than 2. It will be wonderful if it is possible that the plot in the DLL version starts at the first bar if needed, just the way it does in the PREV based version.
Thanks..... again,
Regards
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
SMG
It seems to me that the PREV based version of Wilders Smoothing cannot start on the first bar. By definition PREV needs two bars for a valid plot, the previous bar and the current bar.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Roy,
PREV seems to be more mysterious than expected. Following formula for Wilder's smoothing plots from the first bar and it is same as native Wilder's Smoothing from the 15th bar:
pds:=If(Cum(1)<15,Cum(1),15);
Wldsm:= PREV+(1/pds*(C-PREV));
Wldsm;
Regards,
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Chris,
Here is something that might interest you. I was going through the Moving average function of Forum DLL and noticed that the following formula starts plot from the first bar:
ExtFml("Forum.MOV",C,14,E)
You might notice that there is no variable period in this formula, still the plot begins from the first bar. May be the Variable Functions must always have valid plots from the first bar so as to be robust.
Regards
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
SMG
Interesting stuff, you're right. Yet when the PREV variable is unnamed the plot begins on bar 2. Figure that out.
pds:=If(Cum(1)<15,Cum(1),15);
PREV+(1/pds*(C-PREV));
Another "interesting" fact is that the plot, whether starting at bar 1, bar 2 or bar 15, is the same as an SMA of 1 to 15 periods. This is what one would expect given that the amount of new data added on each bar up to bar 15 is in direct proportion to the number of bars processed at that point. It also tallies with the notion that Wilders Smoothing starts (or is seeded) at the SMA value of "pds" periods.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Roy,
Thanks for your input. Although I had tested that the plot was the same as the native Wilder's SmoothingS during the seeding/initialising period (First 15 Bars in this case), however I was not aware that it was same as the SMA also. It should certainly help Chris in ironing out the DLL. And I may hope that it should be possible to have the plot starting from the first bar itself.
Thanks again.
Chris,
One small suggestion: Space is very expensive stuff in formula editor, so please see if the syntax should be changeed to:
ExtFml( "Wilders.WSM", PriceDataArray, Periods)
Regards
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/11/2005(UTC) Posts: 37
Was thanked: 1 time(s) in 1 post(s)
|
Hi,
here's the last and I hope final Version for the DLL.
The plot starts now from bar one and the plot is identical for all bars >= periods with the original MetaStock version.
The name has change from smoothing to WSM:
ExtFml( "Wilders.WSM", PriceDataArray, Variable Period)
Old version 1.01 is no longer available for download.
Enjoy
Chris :wink:
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Chris,
Please accept my gratitude for the nice effort. Now it is working as expected.
I do hope that it is the final version. In some very rare instances some error messages are popping up. I am testing it thoroughly and will report the rare error messages once I am able to define the conditions when they occur, and able to reproduce the error again.
Thanks again...
Regards
SMG
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 8/13/2005(UTC) Posts: 90
|
Chris,
I have come across two small bugs in the DLL, Should I post the details here, if it does not intrude on your time.
Regards
SMG
|
|
|
|
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)
|
Wilders Smoothing is identical to an Exponential Moving Average, except that it uses (periods*2-1) instead of EMA's periods.
EMA:=Mov(C,periods,E);
Wilders:=Mov(C,periods*2-1,E);
Rather than add yet another variable DLL to MetaStock (every loaded external function slows down MS to some extent), try using the existing ASI or Forum variable input DLLs.
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)
|
Welles Wilder, creator of countless useful T/A indicators, now reduced to selling "the secret of the perfect order underlying all markets" for "not for its original price of $3500, but for $1200".
Extract:
Quote:
It's Hard to Believe
Suddenly, it hit me that I could do this for any date in the past or the future. I could pick a year - then pick a commodity - for example, T-Bonds 2015. I can chart every Intermediate turning point and every major turning point that T-Bonds will make in 2015.
Or better yet, pick a date - any date - say March 22, 2030. I can determine the previous turning point, the next turning point and the following turning point - for every commodity I choose on any Delta time frame I choose.
There you have it. :)
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.