Open equity plot

I'm trying to get an open equity plot (equity - closed equity). I'm not a programmer so I have little luck with CBT. I tried the following, but I understand this does not create an array at every bar. Any suggestions? Thanks in advance.

SetCustomBacktestProc( "" ); 
if ( Status( "action" ) == actionPortfolio ) { 
    bo = GetBacktesterObject(); 
  bo.Backtest(1); 
    sumprofit = 0;    
     for ( trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos() ) { 
        profit = trade.GetProfit(); 
        sumprofit=sumprofit+profit;
        Open_equity_name = "~OpenProfit";
        flag = atcFlagDeleteValues | atcFlagEnableInPortfolio;   
         AddToComposite( sumprofit, Open_equity_name, "C", flag ); 
     }
    bo.ListTrades(); 
  }

This way you only get a final profit (single number) not array. There is no such thing as open equity plot because there can be no open trades at the end and even if they are few open trades they are usually short lived therefore not really useful for anything worth plotting.

Thanks, Tomasz. Another question: How to change this code to cycle thought futures open positions, calculate the total margin used, and make a plot?

Any help here would be appreciated. Thanks.