TA, I understand the difference between
Regular, Raw, and Raw2. I probably didn't state the issue very clearly the
second time around, but the issue is that in setbacktestmode Regular mode, if
the maxpositions option is set to 10 and the max buys per day is set to 10,
then theoretically, the results should match. But they don't.
--- In amibroker@xxxxxxxxxxxxxxx,
"ta" <tagroups@xxx> wrote:
>
> Well, study the difference between "RegularRaw" &
"RegularRaw2". "The common
> thing between Raw and Raw2 modes is that they both do NOT remove excess
> ENTRY signals.
>
> The difference is that Raw modes remove excess EXIT signals, while Raw2 do
> NOT." Also there was a discussion about "phantom positions"
a couple of
> years ago.
>
>
>
>
>
> From: amibroker@xxxxxxxxxxxxxxx
[mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of woodshedder_blogspot
> Sent: Wednesday, September 30, 2009 4:05 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Help Limiting number of positions added per day
>
>
>
>
>
> TA, no doubt it works in RegularRaw2. I completely agree. I'm just
confused
> now as to what is happening when I change the mode to Regular.
> Thanks!
>
> --- In amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com> , "ta"
> <tagroups@> wrote:
> >
> > Not seeing your setting it is difficult to see why your results don't
> match.
> > I know the code that I gave you works. I have tested it extensively.
TA
> >
> >
> >
> > From: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> [mailto:amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com> ] On
> Behalf
> > Of woodshedder_blogspot
> > Sent: Tuesday, September 29, 2009 7:28 PM
> > To: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> > Subject: [amibroker] Re: Help Limiting number of positions added per
day
> >
> >
> >
> >
> >
> > TA Quant, and anyone else, I figured out why the code was taking so
long
> to
> > run. It is because the setbacktestmode was set to RegularRaw2. When I
set
> it
> > to RegularRaw, it runs as normal, and removes redundant signals
(which I
> > want).
> >
> > However, if I set the code to allow 10 max buys a day, the results do
not
> > match results generated without the custom backtester code, when I
just
> use
> > a max of 10 positions. It seems that it should be the same as 10 max
buys
> a
> > day should be the same as allowing a maximum of 10 positions but not
> > limiting the number of new positions allowed at one time.
> >
> > I've included the code below, as suggested by TA. Thanks for any help
with
> > this!
> >
> > MaxBuys = 5;
> > SetBacktestMode( backtestRegular );
> > SetCustomBacktestProc("");
> > if ( Status( "action" ) == actionPortfolio )
> > {
> > bo = GetBacktesterObject();
> > bo.PreProcess();
> > for ( i = 0; i < BarCount; i++ )
> > {
> > CntBuys = 0;
> > 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 = 10);
> > CanEnter = True;
> > CntBuys++;
> > }
> > if ( ! CanEnter ) sig.Price = -1;
> > }
> > }
> > bo.ProcessTradeSignals( i );
> > }
> > bo.PostProcess();
> > }
> >
> > --- In amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com> ,
> > "woodshedder_blogspot" <woodshedder_blogspot@> wrote:
> > >
> > > Yes, you're right, it eventually finishes the report. I'm
looking back
> > about 3 years right now, which is 670 trades, and it has taken it
over 5
> > minutes, but it finishes.
> > >
> > > This is exactly what I've been looking for, so again,I really
appreciate
> > the help.
> > > --- In amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com> ,
> > "ta" <tagroups@> wrote:
> > > >
> > > > I think it has to do with number traders/signals that your
system
> > generate.
> > > > I have tested it over ten years with a system that
generates about
> 2000
> > > > trades. It takes about 3 minutes. I don't think that AA is
> unresponsive.
> > I
> > > > think it is processing the signals. Let go I am sure it
will finish.
> > > >
> > > >
> > > >
> > > > From: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > [mailto:amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com> ] On
> > Behalf
> > > > Of woodshedder_blogspot
> > > > Sent: Sunday, September 27, 2009 9:52 PM
> > > > To: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > > > Subject: [amibroker] Re: Help Limiting number of positions
added per
> day
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Yes, that code is working. Thanks TA!
> > > >
> > > > Is it normal though for it cause the AA window to go
non-responsive
> when
> > > > backtesting a range of more than 1 year?
> > > >
> > > > I can test over 9 months and it works-with about a minute
delay
> between
> > the
> > > > backtest finishing and the report being generated.
> > > >
> > > > If I test over much more than 9 months, it never generates
the report-
> > > > instead it just seems to keep processing something.
> > > >
> > > > Thanks!
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com> , "ta"
> > > > <tagroups@> wrote:
> > > > >
> > > > > Since you have not posted your code I can not debug it
for you but
> the
> > > > > following code works for me:
> > > > >
> > > > >
> > > > >
> > > > > MaxBuys = 5;
> > > > > SetBacktestMode( backtestRegularRaw2 );
> > > > > SetCustomBacktestProc("");
> > > > > if ( Status( "action" ) == actionPortfolio )
> > > > > {
> > > > > bo = GetBacktesterObject();
> > > > > bo.PreProcess();
> > > > > for ( i = 0; i < BarCount; i++ )
> > > > > {
> > > > > cntBuys = 0;
> > > > > 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: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > [mailto:amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com> ] On
> > > > Behalf
> > > > > Of woodshedder_blogspot
> > > > > Sent: Saturday, September 26, 2009 3:52 PM
> > > > > To: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > > Subject: [amibroker] Re: Help Limiting number of
positions added per
> > day
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > TA, thanks for the help.
> > > > > I'm having a problem with this line:
> > > > > bo.PostProcess();
> > > > >
> > > > > This is the error I'm getting: "Error 18 COM
object variable is not
> > > > > initialized or has invalid type (valid COM object
handle required)
> > > > >
> > > > > Wood
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx
> <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > <mailto:amibroker%40yahoogroups.com> , "ta"
> > > > > <tagroups@> 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: amibroker@xxxxxxxxxxxxxxx
> <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > <mailto:amibroker%40yahoogroups.com>
> > > > > [mailto:amibroker@xxxxxxxxxxxxxxx
> <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > <mailto:amibroker%40yahoogroups.com> ] On
> > > > > Behalf
> > > > > > Of woodshedder_blogspot
> > > > > > Sent: Thursday, September 24, 2009 8:25 PM
> > > > > > To: amibroker@xxxxxxxxxxxxxxx
<mailto:amibroker%40yahoogroups.com>
> <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> > > > <mailto:amibroker%40yahoogroups.com>
> > > > > > 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.
> > > > > >
> > > > >
> > > >
> > >
> >
>