PureBytes Links
Trading Reference Links
|
Hi Robert,
Please, don't be so apologetic about it! You are free to ask and I
guess this forum is exactly for this - a free flow of ideas,
indicators and MSFL stuff.
You are right in changing the c-ref(c,-1) bit. Also, specify the
starting bin (this is the minimum observed percentage change in the
original) to say -5. Then the histogram will start at -5. Now, make
BinSize:=1, then the histogram starts at -5, the next bin at -4 etc.
Change these (yMin and BinSize) to whatever applies to you. If you
have a histogram with more than 20 bins, you'd have to extend the big
formula with all the lastvalue's in, but it should be more or less
obvious how to do this. And, of course, if you do this, let me have a
copy of it please.
Regards
MG Ferreira
TsaTsa EOD Programmer and trading model builder
http://www.ferra4models.com
http://fun.ferra4models.com
--- In equismetastock@xxxxxxxxxxxxxxx, "robcpettit" <robcpettit@xxxx>
wrote:
> I hate to ask, as youve spent long enough on this, Ive messed around
> with this but my lack of understanding doesnt help. Id like a
> distribution of say how many times a price changes by 1, or 2, or 3,
> or -1, or -2 etc. Which areas would I have to change. Ive altered the
> formula to c-(ref(c,-1) and played around with other parts. With the
> ref to bins is this setting up different areas to add repeated values
> to. Sorry for my lack of understanding. I have excel so I can use that.
> Regards Robert
>
>
>
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "robcpettit" <robcpettit@xxxx>
> wrote:
> > MG Ferreira, Thankyou for your reply, well beyond the kind of reply
> > was expecting. This looks like it took some time to put together so
> > its much appreciated and Ill have fun playing with it. It will take a
> > while to learn whats actually happening.
> > Regards Robert
> >
> > --- In equismetastock@xxxxxxxxxxxxxxx, mgf_za_1999 <no_reply@xxxx>
> wrote:
> > > Robert,
> > >
> > > Actually I am in so much trouble now with all the time I just
spent on
> > > this very interesting challenge. Here it is
> > >
> > > ----8<----------------------
> > > {MG Ferreira}
> > > {http://www.ferra4models.com}
> > > {Plots frequency distribution of daily returns}
> > > {and fitted normal distribution, either in values}
> > > {or percentages.}
> > > {For personal use only}
> > >
> > > {Number of bins, use log(n) if not sure}
> > > Bins:=Input("Number of bins?",5,20,10);
> > > UsePct:=Input("Actual count(0) or percentage(1)?",0,1,0);
> > >
> > > {What we want to distribute, change to your liking}
> > > Y:=100*(C/Ref(C,-1)-1); {Daily returns}
> > >
> > > {Calcs}
> > > yMax:=LastValue(Highest(Y));
> > > yMin:=LastValue(Lowest(Y));
> > > yRange:=yMax-yMin;
> > > BinSize:=yRange/Bins;
> > >
> > > {Count frequency in each bin}
> > > ii:=Cum(1);
> > > nn:=LastValue(ii);
> > > CumFreq:=0*(ii<=2)+
> > > LastValue(Cum(Y<yMin+BinSize*1))*(ii=3)+
> > > LastValue(Cum(Y<yMin+BinSize*2))*(ii=4)+
> > > LastValue(Cum(Y<yMin+BinSize*3))*(ii=5)+
> > > LastValue(Cum(Y<yMin+BinSize*4))*(ii=6)+
> > > LastValue(Cum(Y<yMin+BinSize*5))*(ii=7)+
> > > LastValue(Cum(Y<yMin+BinSize*6))*(ii=8)+
> > > LastValue(Cum(Y<yMin+BinSize*7))*(ii=9)+
> > > LastValue(Cum(Y<yMin+BinSize*8))*(ii=10)+
> > > LastValue(Cum(Y<yMin+BinSize*9))*(ii=11)+
> > > LastValue(Cum(Y<yMin+BinSize*10))*(ii=12)+
> > > LastValue(Cum(Y<yMin+BinSize*11))*(ii=13)+
> > > LastValue(Cum(Y<yMin+BinSize*12))*(ii=14)+
> > > LastValue(Cum(Y<yMin+BinSize*13))*(ii=15)+
> > > LastValue(Cum(Y<yMin+BinSize*14))*(ii=16)+
> > > LastValue(Cum(Y<yMin+BinSize*15))*(ii=17)+
> > > LastValue(Cum(Y<yMin+BinSize*16))*(ii=18)+
> > > LastValue(Cum(Y<yMin+BinSize*17))*(ii=19)+
> > > LastValue(Cum(Y<yMin+BinSize*18))*(ii=20)+
> > > LastValue(Cum(Y<yMin+BinSize*19))*(ii=21)+
> > > LastValue(Cum(Y<yMin+BinSize*20))*(ii=22)+
> > > (nn-1)*(ii>22);
> > >
> > > Freq:=(CumFreq-Ref(CumFreq,-1))/(UsePct*nn+(UsePct=0));
> > >
> > > {Now fit a normal distro to it}
> > > Mu:=LastValue(Cum(y))/(nn-1);
> > > Sigma:=LastValue(Stdev(y,nn-2));
> > > NormDistro:=Exp(-0.5*Power((yMin+BinSize*(ii-2)-Mu)/Sigma,2))/sigma;
> > > CumNorm:=LastValue(Cum(NormDistro));
> > > NormFin:=NormDistro/CumNorm*((UsePct=0)*(nn-1)+(UsePct=1));
> > >
> > > NormFin;Freq
> > > ----8<----------------------
> > >
> > > This asks you to give the number of bins, say 10. Use log(#obs) if
> > > you are not sure, and I should probably have used this somewhere as
> > > well. It then calculates the frequency distro and also fits a
normal
> > > distro to it, which it plot. If you enter say 20 bins (the max)
then
> > > the first 20 + 2 values contain the frequency and normal
distros. The
> > > rest you can basically ignore.
> > >
> > > Now, this is plotted on a date axis. To plot it on a proper
axis can
> > > not be done, but just change the last line to something like
> > >
> > > NormFin;Freq;yMin+BinSize*(ii-2)
> > >
> > > to get the values of the x axis as well. You can then copy this out
> > > to say Excel for further analysis.
> > >
> > > Regards
> > > MG Ferreira
> > > TsaTsa EOD Programmer and trading model builder
> > > http://www.ferra4models.com
> > > http://fun.ferra4models.com
> > >
> > >
> > > --- In equismetastock@xxxxxxxxxxxxxxx, mgf_za_1999 <no_reply@xxxx>
> > wrote:
> > > > Hi Robert,
> > > >
> > > > I think this is not that difficult to do actually, using a few
'Cum'
> > > > and 'LastValue' statements should do the trick. It won't be
as nice
> > > > as you'd want it to be, but will be a lot easier than copy and
paste
> > > > to Excel. If I have more time, I'll see if I can cook up
something
> > > > for this.
> > > >
> > > > Regards
> > > > MG Ferreira
> > > > TsaTsa EOD Programmer and trading model builder
> > > > http://www.ferra4models.com
> > > > http://fun.ferra4models.com
> > > >
> > > >
> > > > --- In equismetastock@xxxxxxxxxxxxxxx, "robcpettit"
> <robcpettit@xxxx>
> > > > wrote:
> > > > > Hi, I think the answer no but I have to ask. Is it possible
to do
> > > > > frequency distribution charts, in the traditional bell shape,
> > without
> > > > > purchasing tradesim.
> > > > > Regards Robert
------------------------ 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/
|