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

[amibroker] Re: help with custom metric



PureBytes Links

Trading Reference Links



Hi,

The following is what you have asked for. But, I don't think that it is what the article is suggesting. My interpretation of the article is that TRi is the change in equity from each bar to the next. In other words, N is supposed to be the number of bars, and TRi is supposed to be the rate of change from the previous bar.

fast = MA( Close, 5 );
slow =
MA( Close, 25 );

Buy = Cross( fast, slow );
Sell = Cross( slow, fast );

SetCustomBacktestProc( "" );

if ( Status( "action" ) == actionPortfolio )
{
    bo =
GetBacktesterObject();
    bo.Backtest();

    summation =
0;
    trades =
0;

    
for ( trade = bo.getFirstTrade(); trade; trade = bo.getNextTrade() )
    {
        summation += ( (
1 + trade.getProfit() ) ^ -3 );
        trades++;
    }

    bo.AddCustomMetric(
"AIRAP", ( ( summation / trades ) ^ ( -1 / 3 ) ) - 1 );
}

Mike


--- In amibroker@xxxxxxxxxxxxxxx, "tf28373" <tomfid@xxx> wrote:
>
> Hi again!
>
> Any ideas about following message?
>
> PS I forgot that text editor would not accept greek characters when writing first mail. Therefore every "O" symbol in the previous message means in fact greek "sigma" - a math symbol for a sum. Sorry for the inconvinience.
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "tf28373" tomfid@ wrote:
> >
> >
> > Hi!
> >
> > I've been trying to add custom metric to backtester and optimization
> > funcionalities called AIRAP
> > <http://www.futures.pl/res_tmp/Hedge%20Quest%20-%20Summer%202005.pdf>
> > (Alternative Investment Risk Adjusted Performance), which is composed as
> > follows:
> >
> > AIRAP = [ Ó (( 1 + TRi ) ^ (-3))/N ] ^ ( -1/3 ) -1, where TRi is
> > i-th trade profit and N is number of trades.
> >
> > I've come to following code:
> >
> > SetCustomBacktestProc("");//AIRAP
> >
> > if(Status("action")==actionPortfolio)
> >
> > {bo=GetBacktesterObject();
> >
> > bo.Backtest();
> >
> > st=bo.GetPerformanceStats(0);
> >
> > airap=
> >
> > ((1+st.GetValue("NetProfit")^(-3))
> >
> > /st.GetValue("AllQty")
> >
> > )^(1/(-3))-1;
> >
> > bo.AddCustomMetric("AIRAP",airap);}
> >
> > However I don't know how to include the sum of this equation part: (( 1
> > + TRi ) ^ (-3))/N , in other word I cannot implement "Ó". I've been
> > trying to achieve that using <sum()> function, without success though.
> >
> > Can you show me some way to transcript AIRAP equation into AFL? Maybe
> > there is some part of User Guide dealing with this issue which I've
> > overlooked or some papers on that in Knowledge Base?
> >
> > I will be grateful for any advice or trace :)
> >
> > Regards
> >
> > Tomasz
> >
>



__._,_.___


**** 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

__,_._,___