PureBytes Links
Trading Reference Links
|
Hi David
> I've looked at the primer but I still don't quite get what this
> function is doing.
Cum(1) is simply accumulating, or counting, the number of bars in a chart, counting from left to
right.
The Cum() function is extremely versatile - it has more uses than almost any other function I can
think of.
> for example I've seen it used in a this this regard:
>
> buy:=If (some boolean test),cum(1),0)
This doesn't make a lot of sense. For each new bar the result of the Cum() function will increment
by the parameter that it contains. That parameter can be an expression, another function, or
anything you want to accumulate in fact.
Here are a few uses, taken from the September 2004 issue of MSTT
{Bar Count}
Cum(1);
{Bar One}
Cum(1)=1;
{Last Bar}
Cum(1)=LastValue(Cum(1));
{Descending Bar Count}
LastValue(Cum(1))-Cum(1);
{Count Fridays}
Cum(DayofWeek()=5);
The list goes on and on. Here's an counter that is based on the Cum() function, meaning it's
not PREV based. You just provide the signals you want to count and an appropriate reset.
{Bar or Event Counter}
{2005 rlarsen@xxxxxxxxxxxxxx}
D:=Input("Event Counter, 0=Leading Edge, 1=Bars True",0,1,0);
A:=DayOfMonth()>=28; {count this signal}
B:=Month()=12; {reset signal}
I:=Cum(A+B>-1)=1; {count / reset signals valid}
A:=If(D,A,A*Alert(A=0,2));
X:=Cum(A); {bar count}
{count signal leading edge or bars true}
Z:=X-ValueWhen(1,I+B,X); Z;
Kind regards
Roy Larsen
www.metastocktips.co.nz
Free formulas and MS links
------------------------ Yahoo! Groups Sponsor --------------------~-->
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/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/
|