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

[amibroker] Re: How to Force AmiBroker to Hold Buy Only for 30 days


  • Date: Sun, 28 Feb 2010 19:46:42 -0000
  • From: "bistrader" <bistrader@xxxxxxxxx>
  • Subject: [amibroker] Re: How to Force AmiBroker to Hold Buy Only for 30 days

PureBytes Links

Trading Reference Links

Ended up using SetOption("HoldMinDays", HoldMinCalDays) which works as long a signal is in state form.  Would like to figure out how to use DaysSince1900() as feel more in control.

--- In amibroker@xxxxxxxxxxxxxxx, "bistrader" <bistrader@xxx> wrote:
>
> Yes, I have a function to convert 30 calendar days to the number of market days.  This works fine, but can not figure out how to use the now available marketdays to keep on buy when get another buy while still holding.
> 
> Here is the function.
> 
> function CalendarIndex( Days ) 
> { 
>   td = DaysSince1900(); 
>   result = Null; 
> 
>   if( -Days < 0 ) 
>   { 
>      for( i = BarCount -1; i >= -(-Days); i = i - 1 ) 
>      { 
>        backday = td[ i ] + (-Days); // Days is negative 
>        for( j = -(-Days)/2; j < i; j++ ) 
>        { 
>           if( td[ i - j ] <= backday ) 
>            { 
>              result[ i ] = i - j - 0.5; 
>              break; 
>            } 
>        } 
>      } 
>   } 
>   return result; 
> }
> 
> Then I use the following but does not work correctly.  Holds too long if another impulse buy comes along while still on a forced hold buy.
> 
> //  Apply HoldMinMktDays for Buy side only 
> Sig_Buy    = ExRem(Sig_Buy, Sig_Sell);
> Sig_Sell   = ExRem(Sig_Sell, Sig_Buy);
> 
> // Starts at 0 for each Buy which is a problem if another Buy impulse prior
> // to correct HoldMin Period
> Bars   = BarsSince(Sig_Buy);
> 
> Buy    = Flip(Sig_Buy, Sig_Sell);
> Sell   = NOT Sig_Buy;
> 
> // Since Bars at 0 for each Buy, we hold for too long if another Buy impulse
> // comes along as Bars starts over again at 0.
> Buy    = IIf(Bars <= HoldMinMktDays, True, Buy);
> Sell   = IIf(Bars <= HoldMinMktDays, False, Sell);
> 
> Will keep at it.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Have a look at DaysSince1900.
> > 
> > Mike
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "bistrader" <bistrader@> wrote:
> > >
> > > I tried the ref approach but it uses market days and I need 30 calendar days.
> > > 
> > > As for subsequent buy signal, the clock would not start again as the security is still on a buy. I should have been clearer.
> > > 
> > > Thanks.  I'll continue to try to get calendar days out of this.
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > > >
> > > > Hi,
> > > > 
> > > > You are not clear enough in your description.
> > > > 
> > > > Using your example; A subsequent Buy came up before the 30 days were over. So, do you start counting to 30 again from that Buy before selling?
> > > > 
> > > > If no Sell signal came over the course of 30 days since a Buy, would you still Sell?
> > > > 
> > > > You will probably need to use ExRemSpan.
> > > > 
> > > > For the case of hold exactly 30 bars then sell, regardless of redundant Buys and regardless of whether or not a Sell occurred, you would do the following:
> > > > 
> > > > Buy = ...;
> > > > Sell = Ref(ExRemSpan(Buy, 30), -30);
> > > > 
> > > > Mike
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "bistrader" <bistrader@> wrote:
> > > > >
> > > > > Hello,
> > > > > 
> > > > > I have a regular backtest with Buy and Sell statements.  Is there a way to force the buy ONLY to stay on a buy for 30 days?
> > > > > 
> > > > > Example:
> > > > > Buy = true 20 calendar days ago;
> > > > > Sell = true 8 calendar days ago;
> > > > > Buy - true yesterday; 
> > > > > 
> > > > > Want to force Buy to stay on buy for total of 30 days and then want to sell but only if another Buy signal did not come along.  In this case, system would go on buy 20 days ago and stay on buy today since had another buy signal before 31 days was up, even though sell was true 8 days ago.
> > > > >
> > > >
> > >
> >
>




------------------------------------

**** 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/