PureBytes Links
Trading Reference Links
|
The Metastock code below is based on Mark Jurik's post, and in no way is
it meant to replace the original JMA available from http://
www.jurikres.com .
MetaStock -> Tools -> Indicator Builder -> New
-> copy & paste complete formula between "---8<---" lines.
==========
MA - Jurik
==========
---8<-------------------------------------------
{ Non-adaptive approximation of Mark Jurik's JMA
available from http://www.jurikres.com - v1.0
©Copyright 2007 Jose Silva.
For personal use only.
http://www.metastocktools.com }
{ User inputs }
pds:=Input("JMA periods",1,2600,21);
factor:=Input("Lag reduction scaling factor [-1 = Auto]",-1,1000,-1);
x:=Input("use [1]Open [2]High [3]Low [4]Close [5]WCl [6]Vol",1,6,4);
type:=Input("[1]EMA [2]SMA [3]TmSr [4]Tri [5]Var [6]Vol [7]Wght",1,7,2);
shift:=Input("JMA bands spread %",0,100,5)/100;
plot:=Input("[1]JMA, [2]JMA+Bands, [3]Band crossover Signals",1,3,1);
{ Data array }
x:=If(x=1,O,
If(x=2,H,
If(x=3,L,
If(x=4,C,
If(x=5,WC(),
V)))));
{ MovAvg type:
1 - Exponential MA
2 - Simple MA
3 - Time Series MA
4 - Triangular MA
5 - Variable MA
6 - Volume adjusted MA
7 - Weighted MA }
ma:=
If(type=1,Mov(x,pds,E),
If(type=2,Mov(x,pds,S),
If(type=3,Mov(x,pds,T),
If(type=4,Mov(x,pds,TRI),
If(type=5,Mov(x,pds,VAR),
If(type=6,Mov(x,pds,VOL),
Mov(x,pds,W)))))));
{ JMA approximation }
factor:=If(factor>=0,factor,pds/4);
JMA:=(ma+LinRegSlope(x,pds)*factor);
{ JMA % bands }
upper:=JMA*(1+shift);
lower:=JMA*(1-shift);
{ JMA bands crossover signals }
entry:=Cross(C,upper);
exit:=Cross(lower,C);
{ Clean signals }
init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR init,entry);
long:=bin*(Alert(bin=0,2)
OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2)
OR exit*Cum(exit)=1);
signals:=long-short;
{Plot JMA on price chart, signals in own window}
If(plot=1,JMA,If(plot=2,upper,0));
If(plot=1,JMA,If(plot=2,lower,0));
If(plot=3,signals,JMA)
---8<-------------------------------------------
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, "Mark
Jurik" <mark_yahoo_equismetastock@xxx> wrote:
>
> The code is simply a combination of a simple moving average and one
> way of approximating overall slope:
>
> Result = SMA + slope
>
> You can get the desired slope calc in MS by using the built-in linear
> regression slope function. This way, ...
>
> Result = mov( data array, periods, simple )
> +
> linregslope( data array, periods ) * scaling_factor
>
> You set the scaling factor as in input parameter, which allows you to
> adjust the amount of lag reduction. This approach to achieving low
> lag smoothing is NOT adaptive and has a significant overshoot penalty
> in proportion to the amount of lag reduction you request.
>
> This formula poorly approximates JMA, which is adaptive, non-linear
> and has better lag/overshoot tradeoff properties. If you want the
> real thing, go to http://www.jurikres.com .
>
> Mark Jurik
> Jurik Research
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/
|