PureBytes Links
Trading Reference Links
|
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/
|