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

[amibroker] How is the AB UPI calculated?



PureBytes Links

Trading Reference Links

I have written a custom UPI function which needs, in my application, to give identical results as I get in the Backtester. I copied the test code below, if you want to run it copy it to the AA, run a Backtest to see AB UPI values, run an explore to see the UPI function value.s


I have been struggling with this; can anyone see why my function doesn't match the Backtester values? How nice if we had AFL functions for all the BT stats to apply on other arrays...(of course without having to run any Backtester)


btw, 

1) how does the test period figure in the AB UPI? Is it based on a fixed yearly period or is it corrected for the test period?

2) If it is based on a yearly period.... how can this be used for shorter test periods?


many thanks for any help you can give,

herman


/////////////////////////////////////// custom UPI ////////////////////////////////////

function CustomUPI( EquityArray, NumberOfBars )

{

    InitialEquity = GetOption"InitialEquity" );

    NumOfPeriods = 100;

    MaxValue = SumSq  = UI = MV = SS = 0;

    PercentProfit = ( LastValue( EquityArray ) - InitialEquity ) / InitialEquity * 100;


    for ( b = BarCount - NumberOfBars - 1; b < BarCount; b++ )

    {

        MV[b] = MV[b-1];

        SS[b] = SS[b-1];


        if ( EquityArray[b] > MaxValue )

        {

            MaxValue = EquityArray[b];

            MV[b] = MaxValue;         // test

        }

        else

        {

            SumSq = SumSq + ( 100 * ( EquityArray[b] / MaxValue - 1 ) ) ^ 2;

            SS[b] = SumSq;                 // test

        }


        UI[b] = sqrt( SumSq / NumberOfBars );

    }


    Plot( MV, "MaxValue"51 );


    Plot( SS, "SumSq"41 );

    return (PercentProfit-5.4)/UI; 

}


Firstbar         = Status"FirstBarInTest" );

NumberBars        = LastValueBarsSince( FirstBar ) );

BuyPrice         = SellPrice = ShortPrice = CoverPrice = C;

SetTradeDelays0000 );

Buy                = CrossMACD(), Signal() ); // test system

Sell                = CrossSignal(), MACD() );

Short                 = Sell;

Cover                 = Buy;

E                 = NzEquity() );

UPI                = CustomUPI( E, NumberBars );


GraphXSpace = 20;

Plot( e, ""2styleLeftAxisScale );

Plot( UPI, "UI"61 );


Filter = Status"LastbarInTest" );

SetOption"NoDefaultColumns"False );

AddColumn( UPI, "cUPI",1.2 );

//////////////////////////////////////////////////////////////////////////////////


__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html




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

__,_._,___