Equity Moving average in custom backtester

Hello,
here is how I calculate the current equity average in custom backtester. Is there a better, more AFL way of doing?

NumTrades = 0;
currentEquityMatrix = Matrix( totalTrades, 1 );
 for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
    {
        currentEquity += trade.GetProfit();
        currentEquityMatrix[ NumTrades ][ 0 ] = currentEquity;
        averageLength = 10;
        equityCumulative = 0;

        for( i = NumTrades; i > NumTrades - averageLength; i-- )
            {
                equityCumulative += currentEquityMatrix[ i ][ 0 ];
            }

            equityAverage = equityCumulative / averageLength;
            _TRACE( "Current Equity Average: " + equityAverage );


       NumTrades++;

    {

Have you considered looping through the bars and using bo.Equity to calculate the average?