PureBytes Links
Trading Reference Links
|
Oops, just change
C1(1) = 0
to
C1(1) = 1
We often use
cum(1) - 1
which yields of course 0, 1, 2, ...
This makes some of the math a lot easier, especially if you use mods,
which is very useful in cyclical analysis. If you have something
like
c = mod(n,cum(1)-1)
then c will be 0, 1, 2, ... n-1. Say you want to look at a cycle of
length 10, then
mod(10,cum(1)-1)
will give 0, 1, 2 ... 9, 0, 1, 2 ... 9, 0, 1 and so on.
Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com
--- In equismetastock@xxxxxxxxxxxxxxx, "MG Ferreira" <quant@xxxx> wrote:
>
> OK, this is just on the example specifically - see Roy's reply as
> well for better examples of using the cum(1) function.
>
> > buy:=If (some boolean test),cum(1),0)
> >
> > Does this mean it's like this
> > If TRUE then
> > buy = buy + 1;
> > else
> > buy = 0;
>
> This is actually NOT what the MS statement does. It starts off
> by creating a time series that accumulates by 1 each bar. Let us
> call this C1 to clarify, say
>
> C1 = cum(1)
>
> so
>
> C1(1) = 0
>
> and
>
> C1(t) = C1(t-1) + 1
>
> or, simply,
>
> C1 = 1, 2, 3, 4 ....
>
> Note (this is sometimes useful) if you had something like
>
> C2 = cum(5)
>
> then
>
> C2 = 5, 10, 15, 20 ...
>
> Now, what that MS line of code you gave does, is to switch between
> either zero or C1. So if you are at time period 100, and previously
> the boolean test was false, but now is true, that function will return
> 100, then 101, 102 ..., and not 1, 2, 3 ... as your code implies. So
> maybe the code should be
>
> increment c1 REGARDLESS
> if true then
> result = c1
> else
> result = zero
>
> Regards
> MG Ferreira
> TsaTsa EOD Programmer and trading model builder
> http://www.ferra4models.com
> http://fun.ferra4models.com
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "dpleydel" <dpleydel@xxxx> wrote:
> >
> >
> > Hi
> >
> > I've looked at the primer but I still don't quite get what this
> > function is doing.
> >
> > for example I've seen it used in a this this regard:
> >
> > buy:=If (some boolean test),cum(1),0)
> >
> > Does this mean it's like this
> > If TRUE then
> > buy = buy + 1;
> > else
> > buy = 0;
> >
> > Thanks
> > David
------------------------ Yahoo! Groups Sponsor --------------------~-->
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/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/
|