Further research showed me that the value of SellNow is not carried outside CustomBackTest object to the Sell line. Does anybody see how I can achieve my objective without having to use low level CBI and ExitTrade?
--- In [email protected], "tipequity" <[EMAIL PROTECTED]> wrote: > > To solve this problem I decided to use CBI, however I am not getting > the results that I was expecting. Any help would be appreciated. > > SetBacktestMode( backtestRegularRaw ); > SetCustomBacktestProc(""); > > MinHoldingPer = 2; > > if( Status("action") == actionPortfolio ) > { > bo = GetBacktesterObject(); > bo.PreProcess(); > for( i = 0; i < BarCount; i++ ) > { > for( OP = bo.GetFirstOpenPos(); OP; OP = bo.GetNextOpenPos() ) > { > if ( OP.BarsInTrade >= MinHoldingPer) > Sellnow = 1; > } > bo.ProcessTradeSignals( i ); > } > bo.PostProcess(); > } > > Sell = ExitLong OR SellNow == 1; > > > > --- In [email protected], "tipequity" <l3456@> wrote: > > > > How can I limit the minimum holding period from the time a position > is > > opened not from time the buy signal was issued? The situation that > I > > facing is that I get two buy signals, I buy after the first buy > signal > > and I want to hold for at least two bars (including the entry bar). > > If I use Buy = ExRem(Buy, Sell); > > then if I use Sell = (ExitLong AND BarsSince(Buy)>=2); > > works fine. However then when I backtest and I have two consecutive > buy > > signals and on the first buy siganl I don't have enough cash to buy > but > > on the second buy siganl I have enough cash, it would not buy > because > > the second signal is removed. > > Any suggestions are appreciated. > > > > TIA > > >
