PureBytes Links
Trading Reference Links
|
How can I resist such excellent advice - I am stepping down from my
math box immediately <tonk> OK, I am down now....
I think the error in that spread's pip is due to rounding, which I see
you overcame by adding a small amount to the log. Computers are quite
inaccurate with logs of small numbers and one normally calculate log(
1 + x ) if x is small, and adjust the answer to get log ( x ), but
this complicates the math even further <tonk> I am down again, sorry
about that.
Anyhow, if you have the time, try my original version on that spread
with the + 0.00001 in stead of * 1.001 rounding adjustment and see if
it still gives the pip incorrectly - if not, you have very simple
version. In case you need to calculate pips of 1 or above, you have
to NOT subtract the 1 in the final equation if I remember correctly, I
did not complete nor test that part of the equation.... Ooops <tonk>
OK, I am down again.
Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com
--- In equismetastock@xxxxxxxxxxxxxxx, "Jose Silva" <josesilva22@xxxx>
wrote:
>
> Congratulations MG, that would have to be the first genuinely useful
> post from you. Now, if only you could step down a little from your
> maths soapbox, there may be some hope for you yet... ;)
>
> Anyway, looking at some forex EOD charts, your code reports pip size
> on some $ pairs as 0.00001 when in actual fact it should be 0.0001 .
> Probably not so important with models, but critical if trading.
>
> Here is an improved version of the MS Pip detector code:
>
> ============
> Pip detector
> ============
> ---8<---------------
>
> { Detects lowest historical Pip on chart }
> { Use on any periodicity }
>
> { ©Copyright 2005 Jose Silva }
> { For personal use only }
> { http://www.metastocktools.com }
>
> noPip:=100;
> p1:=If(H-O=0,noPip,H-O);
> p2:=If(O-L=0,noPip,O-L);
> p3:=Abs(If(O-C=0,noPip,O-C));
> p4:=If(H-C=0,noPip,H-C);
> p5:=If(C-L=0,noPip,C-L);
> p6:=If(H-L=0,noPip,H-L);
> p7:=Abs(If(O-Ref(C,-1)=0,noPip,O-Ref(C,-1)));
> minPip:=Min(p1,Min(p2,Min(p3,Min(p4,Min(p5,
> Min(p6,p7))))));
>
> { With thanks to MG Ferreira }
> Lin2Log:=Log(Lowest(minPip)+.000001)/Log(10);
> pip:=Exp((Int(Lin2Log)-1)*Log(10));
>
> pip
>
> ---8<---------------
>
>
> jose '-)
> http://www.metastocktools.com
>
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "MG Ferreira" <quant@xxxx>
> wrote:
> >
> > Hi Jose,
> >
> > This is neat but a bit bulky for such a simple task. Here is an
> > alternative pip detector, that uses some mathemagics, and does the
> > same thing. It should also be more accurate than the original as it
> > is not based on the smallest change, but on the decimal in which
> > this change occurs, as described below.
> >
> > ----8<--------------------------------------------
> > {Calculates pip value
> > For personal use only
> > MG Ferreira
> > http://www.ferra4models.com}
> >
> > rr:=Abs(C-Ref(C,-1));
> > ss:=Log(Lowest((rr=0)+rr)*1.001)/2.302585;
> > Exp((Int(ss)-1)*2.302585)
> > ----8<--------------------------------------------
> >
> > This works by looking at the smallest digit that changes between
> > consequetive closes. So if yesterday's close was 10.56, and today's
> > is 10.87, then the difference is 0.31. The smallest digit visible
> > in the change is the 1 in 0.31, so it assumes the smallest change
> > possible is 0.01 and gives this as the pip. A change of say 0.1234
> > will yield a pip of 0.0001 and so on.
> >
> > Note the assumption! If you have an actual pip of say 0.25, then
> > this code will pick up a second decimal change and report the pip
> > size as 0.01. It assumes pip changes occur in powers of 10, so 10,
> > 1, 0.1, 0.01, 0.001 and so on are tested. It is very easy to change
> > this to anything else, but 10 makes most sense.
> >
> > Anyhow, let me know if this works - one drawback of the mathemagics
> > is that the formula has to deal with rounding of results. As they
> > say, to a computer, 1 + 1 = 1.99999999....
> >
> > Regards
> > MG Ferreira
> > TsaTsa EOD Programmer and trading model builder
> > http://www.ferra4models.com
> > http://fun.ferra4models.com
> >
> >
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Jose Silva" <josesilva22@xxx
> .> wrote:
> >
> > This MS code attempts to detect the smallest traded price movement
> > (pip) on a chart. Useful when adding slippage/spread to a trading
> > strategy.
> >
> > ============
> > Pip detector
> > ============
> > ---8<---------------
> >
> > { Detects lowest historical Pip on chart }
> > { Use on any periodicity }
> >
> > { ©Copyright 2005 Jose Silva }
> > { For personal use only }
> > { http://www.metastocktools.com }
> >
> > noPip:=1000;
> > p1:=If(H-O=0,noPip,H-O);
> > p2:=If(O-L=0,noPip,O-L);
> > p3:=Abs(If(O-C=0,noPip,O-C));
> > p4:=If(H-C=0,noPip,H-C);
> > p5:=If(C-L=0,noPip,C-L);
> > p6:=If(H-L=0,noPip,H-L);
> > p7:=Abs(If(O-Ref(C,-1)=0,noPip,O-Ref(C,-1)));
> > minPip:=Min(p1,Min(p2,Min(p3,Min(p4,Min(p5,
> > Min(p6,p7))))));
> > pip:=Lowest(minPip);
> >
> > pip
> >
> > ---8<---------------
> >
> >
> > jose '-)
> > http://www.metastocktools.com
------------------------ 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/
|