PureBytes Links
Trading Reference Links
|
Terry, try this indicator:
====================
Up/Down bar averages
====================
---8<-------------------------
{ From: http://www.metastocktools.com }
{ User inputs }
pds:=Input("SMA periods",1,260,5);
type:=Input("plot: [1]Difference, [2]Percentage",1,2,1);
{ Difference: Momentum or RoC% }
diff:=If(type=1,C-Ref(C,-1),
(C/Ref(C,-1)-1)*100);
{ Up bars }
up:=C>Ref(C,-1);
upDiff:=up*diff;
upAvg:=Sum(upDiff,pds)/Max(Sum(up,pds),1);
{ Down bars }
dw:=C<Ref(C,-1);
dwDiff:=dw*diff;
dwAvg:=Sum(dwDiff,pds)/Max(Sum(dw,pds),1);
{ Plot in own window }
upDiff;upAvg;
dwDiff;dwAvg
---8<-------------------------
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, projosc <no_reply@xxx> wrote:
>
> Hello new friends. Perhaps someone can help me with this. I want to
> create an average true range of up days separate from down days.
> If I use the if() function, it returns the values I want
> [if(c>ref(c,-1),c-ref(c,-1),0)] but also returns zeros for the down
> bars. This causes the moving average to be miscalculated. How do I
> return only the positve values with no zeros and then devide by the
> apropriate number? Thanks
> and I hope this will help others also. Terry
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/
|