PureBytes Links
Trading Reference Links
|
I *think* the following will improve the accuracy quite a bit. It
uses the ceil and floor function, which, unfortunately, you have to
switch between if the value is above or below zero.
rr:=Abs(C-Ref(C,-1));
ss:=Log(Lowest((rr=0)+rr))/2.302585;
Exp(if(ss>(Int(ss)-1)*2.302585)
Interestingly, I see there is a 'precision' function in MS, which one
should also be able to use for this task, something like
rr:=Abs(C-Ref(C,-1));
digits:=(precision(rr,0)=rr)+0.1*(precision(rr,1)=rr)+0.01*(precision(rr,2)=rr)+0.001*(precision(rr,3)=rr)+
0.0001*(precision(rr,4)=rr);
lowest(Exp(-digits*2.302585))
should do the trick. Note - I did *not* test this piece of code, it
may not even compile. It will be thrown off completely by something
round like 10.0000, where the pip is say 0.0001, but the code above
will pick up a pip of 1 - which is why there is now a 'lowest' in the
final line.
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:
>
> Hi Wallace,
>
> Adding that 0 may fix it..... The problem is that, if computers were
> completely accurate, even the * 1.001 was not required. Now it
> depends on how they treat a number, does 1 + 1 = 1.99999 (in which
> case * 1.0001 would do the trick) or does 1 + 1 = 2.00001 (in which
> case you need to use * 0.99999). So you need to test the formula
> quite a bit and for a variety of stuff to get it to work in all cases.
>
> This I certainly haven't done nor do I intend to do it, since the
> formula as it is, is good enough I think for most cases. You can also
> revisit the formula, use stuff like MS's floor and ceil and round, and
> try to get something that will calculate and compensate for the
> rounding and will work in all cases. Or, you can do something like
>
> if value < 0.0001 then pip = 0.0001
> else if value < 0.001 then pip = 0.001
> else if value < 0.01 then pip = 0.01
> ...
>
> which is crude I guess but works .... <tonk>
>
> Regards
> MG Ferreira
> TsaTsa EOD Programmer and trading model builder
> http://www.ferra4models.com
> http://fun.ferra4models.com
>
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, murusprimus <no_reply@xxxx>
wrote:
> >
> >
> > Missing 0 in code:*1.0001 NOT *1.001
> >
> > rr:=Abs(C-Ref(C,-1));
> > ss:=Log(Lowest((rr=0)+rr)*1.0001)/2.302585;
> > Exp((Int(ss)-1)*2.302585)
> >
> > Wallace.
------------------------ 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/
|