Portfolio Cash Array

Hello, I currently use this code to extract the portfolio equity curve.

AddToComposite(bo.EquityArray, "~~SystemEquity", "X", atcFlagDeleteValues | atcFlagEnableInPortfolio);

Just wondering if anyone knows if I can also extract the cash array? I can find the final cash value, but cannot seem to find the cash array, which would allow me to access the cash levels across the entire backtest.


Standard field for cash array of ~~~EQUITY symbol is in "Low" field.
So for example you may access it via Foreign function from different symbol.

cash = Foreign("~~~Equity", "L");

Since you want to save to custom symbol (other than "~~~EQUITY") then you have to use bo.cash and have to create cash array yourself.

bo.EquityArray holds Equity only! It is not multi dimensional.

/// @link https://forum.amibroker.com/t/portfolio-cash-array/10864/2
/// saving equity and cash to custom symbol
SetCustomBacktestProc( "" );
if ( Status( "action" ) == actionPortfolio ) { 
    bo = GetBacktesterObject();
    bo.PreProcess(); // Initialize backtester

    cash_array = Null;
    for ( i = 0; i < BarCount; i++ ) {
        bo.ProcessTradeSignals( i );
        cash_array[ i ] = bo.cash;         
    bo.PostProcess(); // Finalize backtester
    equity_name = "~SystemEquity";
    flag = atcFlagDeleteValues | atcFlagEnableInPortfolio;
    AddToComposite( bo.EquityArray, equity_name, "C", flag );
    AddToComposite( cash_array, equity_name, "L", flag );

Thanks very much for the response!