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

[EquisMetaStock Group] Re: Pip detector code



PureBytes Links

Trading Reference Links


As a postscript to the previous post, let me add this.  I did not test
it a lot and the formula is slightly different if the pip is 1 or
larger.  The modification is simple enough, but the version I gave is
really for pips smaller than 1.  If anybody is interested, I can
complete the back-of-envelope calcs for the 1 or larger pip size and
translate that into code and post it as well.

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 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@xxxx>
> 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/