Might be easiest to just read in a table from which to do the lookup. Otherwise 
the math for the "p-value" can be found here:

http://www.danielsoper.com/statkb/topic08.aspx

Mike

--- In [email protected], "Diz" <gro...@...> wrote:
>
> Thank you for your response.
> 
> I've already managed to calculate t-test (tstat) in a similar way. What I'm 
> trying to do now is to calculate probability itself.
> 
> Denis.
> 
> --- In [email protected], "mkecera" <mkecera@> wrote:
> >
> > Well, 
> > 
> > I have a custom backtest code with tstat as performance metric. Maybe you 
> > can use that as starting point. But check it carefully as I havent used it 
> > for a while and just copy/pasted it.
> > 
> > /* First we need to enable custom backtest procedure and 
> > ** tell AmiBroker to use current formula 
> > */ 
> > 
> > SetCustomBacktestProc(""); 
> > 
> > if( Status("action") == actionPortfolio ) 
> > { 
> > 
> > bo = GetBacktesterObject(); 
> > bo.Backtest(); // run default backtest procedure 
> > st = bo.GetPerformanceStats(0); // get stats for all trades 
> >     
> > Sumx=0;
> > smx2=0;
> > 
> > for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() ) 
> >     { 
> >     x = trade.GetProfit();
> >     sumx+=x;
> >     smx2+=x*x;
> >     }
> >     
> > xpriem=st.GetValue("AllAvgProfitLoss");
> > x2priem=smx2/st.GetValue("AllQty");
> > xpriem2=st.GetValue("AllAvgProfitLoss")^2;
> > standarddeviation=sqrt(x2priem-xpriem2);
> > 
> > tstat = 
> > (xpriem/standarddeviation)/sqrt(st.GetValue("AllQty"))*1000000;//multiplied 
> > to be seen in report 
> > //custom = st.GetValue("netprofit")*st.GetValue("kratio");
> >     
> > bo.AddCustomMetric( "tstat", tstat );
> > //bo.AddCustomMetric( "custom", custom ); 
> > } 
> > 
> > Regards,
> > 
> > MK
> > 
> > // your trading system here 
> > 
> > --- In [email protected], "diznyc@" <ground@> wrote:
> > >
> > > Hello all,
> > > 
> > > What is the best (easiest) way to calculate probability for the Student 
> > > t-distribution in AFL (analog of TDIST Excel function)?
> > > 
> > > Is it possible to call Excel function somehow from AFL or other external 
> > > statistical library?
> > > 
> > > Thank you in advance,
> > > 
> > > Denis.
> > >
> >
>


Reply via email to