[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: cum(1) function and using mod in cyclical analysis



PureBytes Links

Trading Reference Links



Thanks for the replies.  The example of cum(5) = 5 helps as I see 
the parameter is the increment?  

This is the full code I was trying to understand: (it's Linda 
Bradfords - Anti Indicator)

{long} 
setbars:=3; 
entryadd:=1; 
ff:=Mov(Stoch(7,1),3,E); 
ss:=Mov(Mov(Stoch(16,1),3,E),3,E); 
cbuy:=If(ff<=Ref(ff,-1) AND ss>=Ref(ss,-1),Cum(1),0); 
bbuy:=If(cbuy>=setbars,H+entryadd, 99999); 
bbuy<99999 

Hence why I didn't understand why you would want to just accumlate 
the periods, like if it was period 100, 101, 103 etc as the test 
where cbuy >=3(setbar) seems strange as cum(1) will always be 
greater once we have more than 3 days (so the setbar seems 
unnecessary) unless as per your example where a mod functions was 
used to reset the sequence.

David

--- In equismetastock@xxxxxxxxxxxxxxx, "MG Ferreira" <quant@xxxx> 
wrote:
> 
> Again, there is a bug in the code I posted previously.  I have to
> sincerely apologise - it seems each time I reread a posting I pick 
up
> some errors in it!  Please do accept my apologies.
> 
> The mod function's arguments have to be swapped around, as follows:
> 
>     c = mod(cum(1)-1,n)
> 
> to create a cycle of length 'n' and the example becomes
> 
>     c = mod(cum(1)-1,10)
> 
> to create a cycle of length 10.
> 
> 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:
> > 
> > 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/