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

Re: [amibroker] Re: Probability for the Student t-distribution (TDIST Excel function)


  • Date: Thu, 14 Jan 2010 16:42:56 -0500
  • From: Ted Byers <r.ted.byers@xxxxxxxxx>
  • Subject: Re: [amibroker] Re: Probability for the Student t-distribution (TDIST Excel function)

PureBytes Links

Trading Reference Links



I haven't seen something for this in AFL, but that may be a reflection of experience with it.  However, if it doesn't have native support, why not take advantage of the support it provides for writing plugins in, e.g, C++. 

There is an outstanding, flexible, open source stats product called R (which does just about everything that the commercial Splus supports).  Of course, it allows you to do everything you can imagine doing with almost any probabilistic distribution. 

You could therefore save yourself having to reimplement the wheel just by passing your data to R and have it do your t-test.  To do it transparently, you could use on the the R packages that lets you write C++ code that passes data to R, execute the required R code, and then passes the data back to the C++ calling code.  If you embed that into a C++ plug-in written for use in AmiBroker, you're set. 

Or, if you know the math involved in integrating one or both of the tails of a distribution function, you could write that yourself  in AFL. 

I would poin tout that there exist many R packages that support almost the entire range of statistical analyses that can be done in econometrics, so it would be worth the effort for someone to write a plugin that facilitates passing data between R and AmiBroker and executes whatever analyses R can do that Amibroker does not natively support.

I used to write stats code to do analyses not supported by the commercial products I had at my disposal.  Now, there is little need to do that because products like R support so much.  I therefore find ways to use it rather than being masochistic enough to write it in C++ and test it and test it and then test it some more (yes, I tend to be paranoid about the quality of code that I write).  And as a software developer, I HATE reinventing the wheel.

Cheers,

Ted

On Thu, Jan 14, 2010 at 4:10 PM, Diz <ground@xxxxxxx> 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 amibroker@xxxxxxxxxxxxxxx, "mkecera" <mkecera@xxx> 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 amibroker@xxxxxxxxxxxxxxx, "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.
> >
>




--
R.E.(Ted) Byers, Ph.D.,Ed.D.
TED@xxxxxxxxxxxxxxxxxxxxxxx
CTO
Merchant Services Corp.
350 Harry Walker Parkway North, Suite 8
Newmarket, Ontario
L3Y 8L3


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___