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

[amibroker] Re: Bar number of first trade in CBT


  • Date: Mon, 22 Feb 2010 00:18:07 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: Bar number of first trade in CBT

PureBytes Links

Trading Reference Links

Markus,

You might want to have someone check what you ended up with. The code that you posted below did not make much sense.

1. If you're looking for first trade *ever* (i.e. single first trade from entire portfolio of trades), then there is no reason to call FindOpenPos at all, and no need to loop through all open positions. Just call GetFirstOpenPos and check if it's not null.

2. If you're looking for first trade *per symbol*, again there is no need to to loop through all open positions, just use FindOpenPos. Also, in this scenario, you would need to use a unique name for your static variable since there would be one per symbol. And, while you're there, change it to a simple dynamic variable instead of a static variable, unless you need the values in a chart after the backtest.

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@xxx> wrote:
>
> Don´t worry guys, I GOT IT!
> 
> Markus
>   ----- Original Message ----- 
>   From: Markus Witzler 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Sunday, February 21, 2010 7:45 PM
>   Subject: Re: [amibroker] Re: Bar number of first trade in CBT
> 
> 
>     
> 
>   Hello Mike,
> 
>   ProcessTradeSignals doensn´t work since this is a mid-level method - I´m on low level.
> 
>   Instead, I did the code below and keep my head scratching why it doens´t work.
> 
>   As soon as I add these lines to my code and press Backtest, AB briefly jumps to Backtest mask and then all of a sudden back to Quote Editor window without any error message!
> 
>   I initialized "instance = 0 "at the beginning of CBT routine. So, that can´t cause the problems either.
> 
>   I must add that I inserted the loop right after the i-incremented signal loop, so that it is being checked for every time an instance of i has occured. Since I want to get the bar, the first trade of the whole system has been initiated, I only need to get i for the instance = 1.
> 
>   for (trade = bo.GetFirstOpenPos(); trade; trade = bo.GetNextOpenPos())
> 
>   { 
> 
>   trade = bo.findopenposition(sig.symbol);
> 
> 
>   if (trade)
> 
> 
>   {
> 
>   instance = instance + 1;
> 
>   }
> 
>   if (instance == 1)
> 
>   {
> 
> 
>   StaticVarSet("Bar_numer_of_first_trade_initiation", i);
> 
>   }
> 
>   }
> 
>   If you nee the whole code´, please let me know!
> 
>   Thanks
> 
>   Markus
> 
> 
>     ----- Original Message ----- 
>     From: Mike 
>     To: amibroker@xxxxxxxxxxxxxxx 
>     Sent: Saturday, February 20, 2010 10:56 PM
>     Subject: [amibroker] Re: Bar number of first trade in CBT
> 
> 
>       
>     Hi,
> 
>     If you're doing low level backtest, then either:
> 
>     - you're the one entering the trade, in which case just take note of what bar you're on when you do.
> 
>     - or you're calling ProcessTradeSignals(i) at the end of each bar, in which case just call GetFirstOpenPos(); when it returns non null that'll be the first trade bar.
> 
>     Mike
> 
>     --- In amibroker@xxxxxxxxxxxxxxx, "Markus Witzler" <funnybiz@> wrote:
>     >
>     > Hello,
>     > 
>     > I need to retrieve the bar number of first trade in CBT (low level)., i.e. when first trade was opened.
>     > 
>     > Any clue how to accomplish this?
>     > 
>     > The only thing I know is I must do this in closed trade list.
>     > 
>     > 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
> 
> 
> 
>   __________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________
> 
>   The message was checked by ESET Smart Security.
> 
>   http://www.eset.com
> 
> 
>   
> 
>   __________ Information from ESET Smart Security, version of virus signature database 4668 (20091207) __________
> 
>   The message was checked by ESET Smart Security.
> 
>   http://www.eset.com
> 
> 
> 
> 
> __________ 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/