Hi all,

In previous beta versions the following custom metrics were working fine.  Now 
I get message Error 10...it also is below.  If anyone sees a problem with the 
code I would greatly appreciate the help.  I pieced it together from several 
examples but still have difficulty understanding it.  Thanks

SetCustomBacktestProc("");
        function FindEquityAtDateTime( eq, dt, Value )
{
        found = -1;
        for( i = 0; i < BarCount AND found == -1; i++ )
{
        if( dt[ i ] == Value ) found = i;
}
        return IIf( found != -1, eq[ found - 0 ], Null );
}
        if( Status("action") == actionPortfolio )
{
        bo = GetBacktesterObject();
        bo.Backtest(1);
        dt = DateTime();
        eq = Ref(Foreign("~~~EQUITY", "C" ),-1);

        for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
        EquityAtEntry = FindEquityAtDateTime( eq,dt,trade.EntryDateTime );
        PctLossGain = (trade.GetProfit()/EquityAtEntry)*100;
        trade.AddCustomMetric("Equity at Entry", EquityAtEntry );
        trade.AddCustomMetric("% Gain/Loss of Equity", PctLossGain );
        st = bo.GetPerformanceStats(0);
        pratio=(st.GetValue("WinnersPercent" )/100)*st.GetValue("PayoffRatio");

}
        bo.ListTrades();
        bo.AddCustomMetric( "Performance Ratio", pratio ); 

}


Error 10 Message/////////////////////////////////////////////////////
{

 if( dt[ i ] == Value ) found = i;

}

 return IIf( found != -1, eq[ found - 0
--------------------------------------^

Error 10.
Subscript out of range.
You must not access array elements outside 0..(BarCount-1) range.

Reply via email to