Hello all,

I intend to create a proprietary formula for "My_total_equity" to able to 
modify it later on to suit to my individual needs.

Here, I_ use "Value of cash position (bo.cash) + value (all open positions by 
their close)" as a start.

When I run backtest, I get the following message: 

"Com Variable not initialized or has invalid type" though I initialized 
"Value_open_positions=0" and also "My_total_equity=0;"

The loop to determine the aggregate value of all open positions goes like this:

for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())

{ // Loop through all open positions


Value_open_positions=Value_open_positions+ trade.getprice(i,"C")*trade.shares;

trade.addCustomMetric("Value of open positions", Value_open_positions);

} // End of for loop over trades at this bar


My_total_equity=bo.cash+Value_open_positions;

trade.AddCustomMetric("My total equity", My_total_equity);

Where is the mistake? If the whole code is required, please let me know.

Thanks

Markus

Reply via email to