[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Using CBI the first time



PureBytes Links

Trading Reference Links

Hi,

I believe that your code says it all ;)

> } // End of for loop over trades at this bar
> 
> ...
> trade.AddCustomMetric("My total equity", My_total_equity);

"trade" is null after the loop.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@xxx> wrote:
>
> 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
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/