PureBytes Links
Trading Reference Links
|
I've chosen -101, for the reason that this value is rare in most
indicators/oscillators that may range 0~100 or +100~-100.
Deep down, you know this makes sense!
Thanks Jose.
--- In equismetastock@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx>
wrote:
>
> Simple MFL version of adaptable periodicity:
> pds:=If(pds>Cum(1),Cum(1),pds);
>
> In English:
> If the EMA periods is greater than the number of currently
available
> bars, lower the EMA periodicity the number of currently available
> bars, otherwise don't change EMA periodicity.
>
>
> The posted version is slightly more complicated, to allow for
the "P"
> variable which may include indicators that may take a number of
bars
> before they plot:
> pds:=If(pds>Cum(x<>-101),Cum(x<>-101),pds);
>
> In English:
> If the EMA periods is greater than the number of data values that
are
> not -101, lower the EMA periodicity to the number of data values
that
> are not -101, otherwise don't change EMA periodicity.
>
> I've chosen -101, for the reason that this value is rare in most
> indicators/oscillators that may range 0~100 or +100~-100.
>
> jose '-)
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, bellamy_29m@xxxx wrote:
> > Thanks Jose,
> >
> > I did have a look at your code on your site. I was actually
trying
> > to do this more as a learning experience than anything else, so I
> > really don't care about SMA vs EMA.
> >
> > Would you be so kind to explain the reasoning behind the line:
> >
> > pds:=If(pds>Cum(x<>-101),Cum(x<>-101),pds); { <--- ! }
> >
> > which if I interpret it correctly says, "if the number of periods
is
> > greater than the cumulative sum of the indicator (but only if the
> > value indicator is not equal to -101 (???)) then make this the
> > number of periods, otherwise just use the number of periods"
> >
> > Cheers.
> >
> >
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx>
> > wrote:
> > > If you can live with an EMA instead of SMA, here is some code
that
> > > does what you want:
> > >
> > > ===
> > > EMA
> > > ===
> > > ---8<---------------------------
> > >
> > > { Exponential Moving Average v2.0 }
> > > { EMA periodicity shortens on low bar count }
> > > { ©Copyright 2003 Jose Silva }
> > > { http://users.bigpond.com/prominex/pegasus.htm }
> > >
> > > pds:=Input("EMA periods",1,2520,21);
> > > x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);
> > > shift:=1+Input("EMA vertical shift %",
> > > -100,100,0)/100;
> > > plot:=Input("EMA=1, Crossover signals=2",1,2,1);
> > >
> > > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
> > > pds:=If(pds>Cum(x<>-101),Cum(x<>-101),pds); { <--- ! }
> > > Ema:=x*2/(pds+1)+PREV*(1-2/(pds+1));
> > > Ema:=Ema*shift;
> > > signals:=Cross(x,Ema)+-Cross(Ema,x);
> > >
> > > If(plot=2,signals,Ema)
> > >
> > > ---8<---------------------------
> > >
> > >
> > > jose '-)
> > >
> > >
> > > --- In equismetastock@xxxxxxxxxxxxxxx, bellamy_29m@xxxx wrote:
> > > > I am trying to write a MS6.52 formula to handle the situation
> > where
> > > > there are less data points available than a nominated moving
> > average
> > > > period, so I want the MA to show for the available data
points
> > until
> > > > there enough data points for the MA to operate normally.
(Easily
> > > done
> > > > in VB, VBA, C, C++, just not MS!)
> > > >
> > > > Not knowing exactly how to get around MS lack of flexibility,
I
> > was
> > > > trying:
> > > >
> > > > prd:=Input("MA Periods...",1,100,5);
> > > > x:=Input("1-Open 2-High 3-Low 4-Close 5-Volume 6-P",1,6,4);
> > > > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
> > > > ma:=If(Cum(1)<prd,Sum(x,Cum(1))/Cum(1),Mov(x,prd,S));
> > > > ma;
> > > >
> > > > which didn't work, with the error message "This variable or
> > > > expression must contain only constant data"
> > > >
> > > > ... so I then tried to set the prd value using code:
> > > >
> > > > prd:=Input("MA Periods...",1,100,5);
> > > > prd:=If(Cum(1)<prd,Cum(1),prd);
> > > > x:=Input("1-Open 2-High 3-Low 4-Close 5-Volume 6-P",1,6,4);
> > > > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
> > > > ma:=Mov(x,prd,S);
> > > > ma;
> > > >
> > > > which didn't work either, with the same error message "This
> > variable
> > > > or expression must contain only constant data"
> > > >
> > > > Hopefully, someone can see what I am trying to achieve and
will
> > be
> > > > able to help. Any assistance would be greatly appreciated.
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/BefplB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> 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/
|