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

[amibroker] Re: MaxBuys per bar in backtesting



PureBytes Links

Trading Reference Links

Keith, did this work for you? I love your suggestion of
      MaxBuys = 3; 
      SetOption("MaxBuys", MaxBuys);

Maybe, TJ would implement it in the next release that is coming out 
tomorrow (LOL).

--- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx> 
wrote:
>
> hi,
> 
> yes I forgot to remove that line. I usually open a file and write 
output to that file to see what is going on.
> 
> you open like: 
> 
> fh = fopen("c:\\loopTest.txt", "w" ); 
> 
> then you can write stuff to this file like:
> 
> if( fh ) fputs( "s long: " + cntLongOpen + "\n", fh );
> if( fh ) fputs( "s short: " + cntShortOpen + "\n", fh );
> 
> and at the end you close this file like:
> 
> fclose( fh );
> 
> rgds, Ed
> 
> 
> 
>   ----- Original Message ----- 
>   From: Keith McCombs 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Thursday, March 22, 2007 2:57 AM
>   Subject: Re: [amibroker] MaxBuys per bar in backtesting
> 
> 
>   Edward --
>   Thanks for your response.  I will give it a try.  Though it will 
probably take me a while.  I've been trying to get my brain around 
the Custom Backtester, and it has been slow going for me.
> 
>   BTW, I notice that you end your code with fclose( fh );  I don't 
see it mentioned in either "Portfolio Backtester Interface Reference 
Guide" or "How to add user-defined metrics to backtest/optimization 
report".  Is that something you discovered was necessary or 
just "good practice" or for some other reason?  Where was 'fh' 
defined?
>   -- Keith
> 
>   Edward Pottasch wrote: 
> 
> 
>     i believe you are supposed to do this with the custom 
backtester. I never managed to use this on any useful level but maybe 
this code will get you ahead. It looks at all bars and finds the 
signals for each bar and removes excess signals before the signals 
are processed. I did not include a ranking of the signals though ..  
(see http://www.amibroker.com/guide/a_custombacktest.html  for 
details .... ).
> 
> 
>     SetCustomBacktestProc(""); 
> 
>     MaxBuys = 3; 
> 
>     if( Status("action") == actionPortfolio ) { 
> 
>        bo = GetBacktesterObject(); 
>        bo.PreProcess(); 
>         
>        for( i = 0; i < BarCount; i++ ) { 
>         
>         
>           cntBuys = 0; 
>         
>           // look at new signals and exclude signals if they exceed 
maxBuys 
>           for( sig = bo.GetFirstSignal(i); sig; sig = 
bo.GetNextSignal(i) ) { 
>            
>              // check for entry signal and long signal 
>              if( sig.IsEntry() ) { 
>               
>                 if( cntBuys > MaxBuys ) {   
>                  
>                    sig.PosSize = 0; 
>                     
>                 } else { 
>                  
>                    cntBuys = cntBuys + 1; 
>                     
>                  
>                 } 
>                  
>                  
>              } 
>               
>            
>           } 
>            
>           bo.ProcessTradeSignals( i ); 
>        } 
> 
>        bo.PostProcess(); 
> 
>     fclose( fh ); 
>     }
> 
> 
> 
> 
> 
>       ----- Original Message ----- 
>       From: Keith McCombs 
>       To: amibroker@xxxxxxxxxxxxxxx 
>       Sent: Tuesday, March 20, 2007 8:12 PM
>       Subject: [amibroker] MaxBuys per bar in backtesting
> 
> 
>       I would like to set a maximum buys per bar.
> 
>       I know about:
>       MaxOpen = 10; 
>       SetOption("MaxOpenPositions", MaxOpen);
> 
>       But is there any way to write the 'equivalent' of:
>       MaxBuys = 3; 
>       SetOption("MaxBuys", MaxBuys);
> 
>       TIA.
>       -- Keith
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html
 
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/