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

[amibroker] Re: Min Holding Period Conundrum



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "tipequity" <l3456@xxx> 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 amibroker@xxxxxxxxxxxxxxx, "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
> >
>




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/