PureBytes Links
Trading Reference Links
|
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 --------------------~-->
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/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/
|