[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: DMX...zero division...failure value



PureBytes Links

Trading Reference Links

Adam,

You can smooth at any point in an indicator BUT you should always 
ask at what cost and to what benefit. Let me explain. Smoothing is a 
way of taking the average over a period of time. It introduces lag 
or will slow down the responsiveness of the indicator. Try it for 
yourself...plot a close and a 5 day moving average on a daily chart. 
What happens? The close which has no lag on a daily chart and will 
always lead the moving average in direction and value.  

Your first consideration then should be whether or not you will 
benefit from the lag. In this instance as you have seen there is no 
benefit to using a weighted average. The reason is in the 
calculation of weighted versus exponential. An exponential average 
uses a percentage of recent calculations along with a percentage of 
previous calculations. Thus it is less likely to go to a zero value. 
Obviously a weighted average could have a zero value. 

The problem that you have encountered is a division by zero error 
and is one that has plagued coders for some time especially when 
dealing with a RSI type of calculation which the DMI is. There are a 
number of ways to solve the problem. In the various codes that I 
presented there were several solutions. You have just found one. 
Another is using Max(vt,.0000001). In this code you are simply 
telling metastock to use the higher value of vt or .00000001. 
Therefore you would never have a zero value. Prev, prev is another 
way to solve the problem. My preference is not to use the prev 
statement simply because prev statements tend to slow down the 
calculation process.

As far as smoothing you might want to smooth the final output value. 
Here you should be able to use any method without encountering any 
division error problems.

I did notice your request for DMI systems. Here are some helpful 
hints. The DMI trades just like the RSI so any system that uses it 
will be adaptable to the DMI. 

Normally, the RSI is useless when the up or positive values equal 
the minus or down values. Since the RSI is scaled from 0 to 100 this 
occurs around the value of 50(failure value). There is also a 
limitation of the RSI when the 0 to 100 scale is used. In other 
words it is bound by its range. To overcome this obstacle I 
introduced a bipolar version of the indicator. The bipolar version 
takes away the scaling limitations allowing the values to exceed 100 
and moves the failure value to 0. Therefore it becomes far easier to 
associate the swings beyond the plus or minus 50 with some other 
turning event such as an increase in trading volume. Some beneficial 
reading might be the books of Wilder or Chande & Kroll.


Hope you find this helpful,


Preston    


  

--- In equismetastock@xxxxxxxxxxxxxxx, "adamp_27" <adamp_27@xxx> 
wrote:
>
> Hi Preston
> 
> 
> 
> I really appreciate on your effort. I got some questions in 
regards 
> to DMX that you have code
> 
> 
> 1. could it be possible that the smoothing moving average 
> exponential argument be changed into weighted moving average
> 
> 2. if the above mentioned can be changed why at this section 
> PDX:=ExtFml("ForumDll.VarMOV",Up,pds,E);
> MDX:=ExtFml("ForumDll.VarMOV",Dw,pds,E); can not be changed. if I 
> change this into W the error message appear on the text. this 
> formula is  the second formula from 2 types of the given formula
> 
> 
> Again, thanks for your advance knowledge in coding
> 
> 
> 
> Regards
> 
> 
> Adam
> 
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@> wrote:
> >
> > Kevin,
> > 
> > Thanks! Always tickled to see someone else enjoying and using 
code 
> > that we've written.
> > 
> > The quick answer is to include this line after the original vt 
> > variable 
> > 
> > Vt:=Max(vt,.0000001);
> > 
> > So it should look like this:
> > 
> > Vt:=(Stdev(C,5)/Mov(Stdev(C,5),10,S))*10;
> > Vt:=Max(vt,.0000001);
> > 
> > The DMX discussion was a sentinel event because it introduced 
> > concepts that could be used in so many different ways. In it we 
> > introduced DLL's, the DMZ indicator, several DMI indicators and 
> > bipolar indexing. Seems that we did address the division by zero 
> > error then although it may have been in the context of the DMI 
and 
> > not the DMZ. 
> > 
> > The original DMX discussion started with a question on archived 
> post 
> > number 18862 and my answers began with archived post number 
18868. 
> > This was around August 9th of 2005. 
> > 
> > A quick review:
> > * The DMI is the same as a RSI with variable periods based on 
> > volatility
> > * The DMX is Jurik's low lag version of the DMI 
> > * The DMZ is my version of Jurik's DMX
> > * Corey Saxe and Jose originally wrote versions of the DMI 
without 
> > DLL's
> > * A DLL allows you to use variable inputs where they could not 
> > normally be used
> > 
> > I can't be certain about how close the DMZ is to Mark Jurik's 
DMX 
> > but know that Mark was once a member of this group and maybe he 
> > would be willing to verify it.
> > 
> > Here is a another version of the DMZ. It uses the variable RSI 
> DLL . 
> > 
> > Enjoy! 
> > 
> > Preston
> > 
> > 
> > {(DMZ)Dynamic Momentum Index} 
> > {similar to the Jurik DMX- a lowlag DMI} 
> > {written by Preston Umrysh} 
> > {This indicator uses Dll software developed by MetaStock Forum 
> Crew} 
> > {http://forum.equis.com)} 
> > Vt:=(Stdev(C,5)/Mov(Stdev(C,5),10,E))*10; 
> > Vt:=Max(vt,.0000001); 
> > Period:= Input("ZeroLag Period",1,250,10); 
> > EMA1:= Mov(C,Period,E); 
> > EMA2:= Mov(EMA1,Period,E); 
> > Difference:= EMA1 - EMA2; 
> > ZeroLagEMA:= EMA1 + Difference; 
> > x:=ZeroLagEMA; 
> > ExtFml( "ForumDLL.VarRSI",x ,vt) 
> > {end}
> > 
> > 
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Kevin and Heather 
Howard" 
> > <kjhoward@> wrote:
> > >
> > > Hi Preston,
> > > 
> > > You posted the codes below last August and I have only now
> > > had a chance to have a play with them. On first blush they 
seem 
> to 
> > > be very good, so thank you for sharing.
> > > 
> > > I notice however when set as indicators within a template,
> > > that when opening charts, I receive consistent error 
> > > warnings: "Division by zero errors".
> > > 
> > > Is there anyway with your metastock wizardry, that these
> > > division by zero warnings can be reduced or eliminated?
> > > 
> > > Again my thanks for posting the codes in the first instance.
> > > 
> > > 
> > > Kevin
> > > 
> > > 
> > > 
> > > There are bold mushroom pickers and there are old mushroom 
> pickers,
> > > but there are no bold old mushroom pickers.
> > > 
> > > 
> > > -----Original Message-----
> > > From: equismetastock@xxxxxxxxxxxxxxx 
> > [mailto:equismetastock@xxxxxxxxxxxxxxx]
> > > On Behalf Of pumrysh
> > > Sent: Friday, 12 August 2005 2:03 AM
> > > To: equismetastock@xxxxxxxxxxxxxxx
> > > Subject: [EquisMetaStock Group] Re: DMX
> > > 
> > > 
> > > sumamura,
> > > 
> > > 
> > > Try one of these and see which one comes the closest. Two 
> versions 
> > > here. Version A does not allow DMI periods to be set and has 
> > limited 
> > > lag periods. Version B gives more flexibility by utilizing 
some 
> of 
> > > Jose's coding techniques. You will need to compare these to 
> > Jurik's 
> > > DMX to see which one comes closer.
> > > 
> > > Preston
> > > 
> > > {Dynamic Momentum Xa (DMX)}
> > > {version A - Does not allow DMI periods to be set}
> > > {A low lag version of DMI written by Preston Umrysh}
> > > {Indicator uses Dll developed by MetaStock Forum Crew }
> > > {Available at <http://forum.equis.com> }
> > > {For personal use only }
> > > x:=Input("normal ouput=1 Biplolar index=2",1,2,1);
> > > Period:= Input("ZeroLag Period ",1,6,5);
> > > {Division errors occur with lag beyond 6}
> > > EMA1:= Mov(C,Period,E);
> > > EMA2:= Mov(EMA1,Period,E);
> > > Difference:= EMA1 - EMA2;
> > > Z:= EMA1 + Difference;
> > > Vt:=(Stdev(C,5)/Mov(Stdev(C,5),10,S))*10;
> > > Umom:=If(Z>Ref(Z,-1),Z-Ref(Z,-1),0);
> > > Dmom:=If(Z<Ref(Z,-1),Ref(Z,-1)-Z,0);
> > > UPS:= ExtFml( "ForumDll.VarSUM", Umom,Vt);
> > > DNS:= ExtFml( "ForumDll.VarSUM", Dmom,Vt);
> > > SumU:=ExtFml("ForumDll.VarMOV",UPS,Vt,e)/Vt;
> > > SumD:=ExtFml("ForumDll.VarMOV",DNS,Vt,e)/Vt;
> > > RS:=SumU/SumD;
> > > DMnm:=100-(100/(1+RS));
> > > DMIn:=(SumU-SumD)/(SumU+SumD);
> > > SDM:=If(x=1,DMnm,DMin);
> > > PLOT:=Input("[1]WMA [2]Wilders",1,2,2);
> > > SPD:= Input("Final Smoothing Periods",1,100,3);
> > > X:=Mov(SDM,SPD,W);{weighted}
> > > Y:=Wilders(SDM,SPD);{wilders}
> > > If(PLOT=1,X,Y)
> > > {end}
> > > 
> > > 
> > > {Dynamic Momentum Xb (DMX)} 
> > > {version B - Allows DMI periods to be set}
> > > {A low lag version of DMI written by Preston Umrysh}
> > > {Indicator uses Dll developed by MetaStock Forum Crew }
> > > {Available at <http://forum.equis.com> }
> > > {with coding ideas from Jose Silva }
> > > {<http://www.metastocktools.com> }
> > > {For personal use only }
> > > pds:=Input("DMI PERIODS",6,100,14);
> > > Period:= Input("Lag Period ",1,50,10);
> > > EMA1:= Mov(C,Period,E);
> > > EMA2:= Mov(EMA1,Period,E);
> > > Difference:= EMA1 - EMA2;
> > > X:= EMA1 + Difference;
> > > Vt:=Stdev(x,5)/Mov(Stdev(x,5),10,S);
> > > pds:=pds/(Vt+.14142);
> > > pds:=If(pds>Cum(IsDefined(x))-13,
> > > Cum(IsDefined(x))-13,pds);
> > > pds:=If(pds<2,2,pds);
> > > Up:=If(x>Ref(x,-1),x-Ref(x,-1),0);
> > > Dw:=If(x<Ref(x,-1),Ref(x,-1)-x,0);
> > > PDX:=ExtFml("ForumDll.VarMOV",Up,pds,e);
> > > MDX:=ExtFml("ForumDll.VarMOV",Dw,pds,e);
> > > DSPL:=Input("[1]Normal [2]Bipolar",1,2,1);
> > > PLOT:=Input("[1]WMA [2]Wilders",1,2,2);
> > > SPD:= Input("Final Smoothing Periods",1,100,3);
> > > CDM:=PDX/ MDX;
> > > NDM:=100-(100/(1+CDM));
> > > BDM:=100*(PDX - MDX)/
> > > (PDX + MDX);
> > > SDM:=If(DSPL=1,NDM,BDM);
> > > X:=Mov(SDM,SPD,W);{weighted}
> > > Y:=Wilders(SDM,SPD);{wilders}
> > > If(PLOT=1,X,Y)
> > > {end}
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > >  
> > > Yahoo! Groups Links
> > >
> >
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/