Need CntBuys = 0 with MaxBuys = 5? Need for( i = 0; i < BarCount; i++ )?
--- In [email protected], "ta" <tagro...@...> wrote: > > You need to use Custom Backtester as follows: > > > > MaxBuys = 5; > > SetBacktestMode( backtestRegularRaw2 ); > > SetCustomBacktestProc(""); > > if ( Status( "action" ) == actionPortfolio ) > > { > > bo = GetBacktesterObject(); > > bo.PreProcess(); > > > > for ( sig = bo.GetFirstSignal( i ); sig; sig = > bo.GetNextSignal( i ) ) > > { > > if ( sig.IsEntry() ) > > { > > // this handles limiting of number of order > per day > > CanEnter = False; > > if ( CntBuys <= MaxBuys ) > > { > > > bo.EnterTrade( i, sig.Symbol, True, sig.Price, sig.PosSize, sig.PosScore, > RoundLotSize = 1); > > CanEnter = > True; > > CntBuys++; > > } > > > > if ( ! CanEnter ) > > sig.Price = > -1; > > } > > } > > bo.ProcessTradeSignals( i ); > > } > > bo.PostProcess(); > > } > > > > From: [email protected] [mailto:[email protected]] On Behalf > Of woodshedder_blogspot > Sent: Thursday, September 24, 2009 8:25 PM > To: [email protected] > Subject: [amibroker] Help Limiting number of positions added per day > > > > > > Greetings group. > > I want to limit the number of positions a system will take on any given day. > > > For example, if a system can handle 20 max positions, I would like it to > only take on 5 new positions a day (assuming there are more than 5 valid > signals per day) until it arrives at 20 positions, rather than taking on all > available positions on day 1. > > Thanks for your help. >
