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

[amibroker] Re: Trade.marginloan in custom backtester


  • Date: Wed, 06 Jan 2010 01:44:11 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: Trade.marginloan in custom backtester

PureBytes Links

Trading Reference Links

Margin is stored as a *negative* value. If you want to reduce your total, then add (not subtract) the margin to the total.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@xxx> wrote:
>
> Sorry,
> 
> I meant this:
> 
> < snip>
> for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())
> 
> 
> { 
> 
> value_all_open_pos=value_all_open_pos + trade.GetPrice(i, "C") * trade.shares - trade.marginloan; // I use margin in my system
> 
> }
> 
> 
> my_equity [i] = value_all_open_pos + bo.cash;
> 
> value_all_open_pos=0; // resetting to zero for next run - necessary?
> 
> bo.UpdateStats(i, 1); 
> 
> bo.UpdateStats(i, 2);
> 
> } // End of for loop over bars
> 
> bo.PostProcess();
> 
> AddToComposite(my_equity, "~~~My_Equity","x", 1+2+8+16+32+64+128); 
> 
> }
> 
> 
>   ----- Original Message ----- 
>   From: Markus Witzler 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Tuesday, January 05, 2010 11:56 PM
>   Subject: [amibroker] Trade.marginloan in custom backtester
> 
> 
>     
> 
>   Hello,
> 
>   does anybody know if trade.marginloan also works for open positions?
> 
>   I want to use it like this
> 
>   < snip>
>   for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())
> 
> 
>   { 
> 
>   value_all_open_pos=value_all_open_pos + trade.GetPrice(i, "C") * trade.shares; 
> 
>   }
> 
> 
>   my_equity [i] = value_all_open_pos + bo.cash - trade.marginloan; // I use margin in my system
> 
>   value_all_open_pos=0; // resetting to zero for next run - necessary?
> 
>   bo.UpdateStats(i, 1); 
> 
>   bo.UpdateStats(i, 2);
> 
>   } // End of for loop over bars
> 
>   bo.PostProcess();
> 
>   AddToComposite(my_equity, "~~~My_Equity","x", 1+2+8+16+32+64+128); 
> 
>   }
> 
>   For some reason, my_equity is higher if I use " minus trade.marginloan" (see above) than if I skip it. This is awkward...
> 
>   Thanks
> 
>   Markus
> 
> 
>   
> 
>   __________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________
> 
>   The message was checked by ESET Smart Security.
> 
>   http://www.eset.com
>




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

**** 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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/