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

[amibroker] Re: Help Limiting number of positions added per day



PureBytes Links

Trading Reference Links

Any ideas guys ? ;-) I'm stuck on it :|


Ok, hear we've got situation:

CondBuy=..;
CondShort=..;
Buy= CondBuy ;
Short=Sell;
Cover=Buy;

CurrentPos[0]=0;
MaxBuys = 1;
dnB = DateNum();
newDayB=Ref(dn,-1)!= dnB;
SetBacktestMode( backtestRegularRaw );
SetCustomBacktestProc("");
if ( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();
bo.PreProcess();
cntBuys =0;
for ( i = 0; i < BarCount; i++ )
{
if(newDayB[i]==1)
{cntBuys = 0;}
CanEnter=False;
for ( sig = bo.GetFirstSignal( i ); sig; sig = bo.GetNextSignal( i ) )
{
if ( CntBuys < MaxBuys AND sig.IsLong()AND CurrentPos[0]!=1)
{

CanEnter = True;
CntBuys++;
CurrentPos[0]=1;
}
else if ( CntBuys < MaxBuys AND NOT sig.IsLong()AND CurrentPos[0]!=-1)//if
signal short
{
CanEnter = True;
CntBuys++;
CurrentPos[0]=-1;

}
if ( ! CanEnter ) sig.Price = -1;

}
bo.ProcessTradeSignals( i );
}
bo.PostProcess();
}

Still program misses some signals. Why is that?
Someone can check it ? I will be greatfull :-)

--
Best regards
raskoks

--- In amibroker@xxxxxxxxxxxxxxx, £ukasz Bigos <raskoks@xxx> wrote:
>
> you are right Tomasz
> thank you - i will change it.
> 
> On Tue, Oct 6, 2009 at 1:44 AM, Tomasz Janeczko <groups@xxx>wrote:
> 
> >
> >
> > Hello,
> >
> > If you want raw signals, whenever possible use backtestRegularRaw, instead
> > of Raw2.
> > As explained in the manual,
> > "Raw2 modes are "special" for advanced users of custom backtester. They are
> > only useful if you do custom processing of exit signals
> > in custom backtester procedure. They should NOT be used otherwise, because
> > of performance hit and memory consumption Raw2 modes
> > cause"
> >
> > Custom processing of exit signals means that you DO NOT EXIT your position
> > on first exit signal that occurs when position is open,
> > but you *ignore* one or more exit signals and act upon some late signal.
> >
> > If you do not do the above, you should NOT use Raw2 mode because it is much
> > slower.
> >
> > The code below DOES NOT do this, therefore should NOT use Raw2 mode.
> >
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> >
> > ----- Original Message -----
> > From: "woodshedder_blogspot" <woodshedder_blogspot@xxx<woodshedder_blogspot%40yahoo.com>
> > >
> > To: <amibroker@xxxxxxxxxxxxxxx <amibroker%40yahoogroups.com>>
> > Sent: Tuesday, October 06, 2009 1:36 AM
> > Subject: [amibroker] Re: Help Limiting number of positions added per day
> >
> > > Raskoks, I am not very good at this yet, but I can see a few things that
> > might be causing problems.
> > >
> > > 1. SetBacktestMode( backtestRegularRaw2 ); Make sure that you want
> > RegularRaw2. Raw2 does allow redundant signals.
> > >
> > > 2. newDayB=Ref(dn,-1)!= dn; I don't see where you have defined dn.
> > >
> > > 3. if ( CntBuys <= MaxBuys.....I had to take out the = sign so that it
> > reads CntBuys<MaxBuys.
> > >
> > > Hope this helps,
> > > Wood
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%40yahoogroups.com>,
> > "raskoks" <raskoks@> wrote:
> > >>
> > >> Hi,maybe someone can tell me what i do wrong. I have smth like that
> > (code below) and i need to have max only one transaction per
> > >> day. Morover every transacion is simply reversing position (always on
> > market). But for this code signals which aren't use ( for
> > >> example buy signal when i already have long position) are count to daily
> > limit. I really don't know why :).
> > >> Thanks for any help.
> > >>
> > >>
> > >> CondBuy=..;
> > >> CondShort=..;
> > >> Buy= CondBuy ;
> > >> Sell= CondShort ;
> > >> Short=Sell;
> > >> Cover=Buy;
> > >>
> > >> CurrentPos[0]=0;
> > >> MaxBuys = 1;
> > >> dnB = DateNum();
> > >> newDayB=Ref(dn,-1)!= dn;
> > >> SetBacktestMode( backtestRegularRaw2 );
> > >> SetCustomBacktestProc("");
> > >> if ( Status( "action" ) == actionPortfolio )
> > >> {
> > >> bo = GetBacktesterObject();
> > >> bo.PreProcess();
> > >> cntBuys =0;
> > >> for ( i = 0; i < BarCount; i++ )
> > >> {
> > >> if(newDayB[i]==1)
> > >> cntBuys = 0;
> > >>
> > >> for ( sig = bo.GetFirstSignal( i ); sig; sig =bo.GetNextSignal( i ) )
> > >> {
> > >>
> > >>
> > >> if ( CntBuys <= MaxBuys AND sig.IsLong()AND CurrentPos[0]!=1)
> > >> {
> > >> CanEnter = True;
> > >> CntBuys++;
> > >> CurrentPos[0]=1;
> > >> }
> > >> else if ( CntBuys <= MaxBuys AND NOT sig.IsLong()AND CurrentPos[0]!=-1)
> > {
> > >> CanEnter = True;
> > >> CntBuys++;
> > >> CurrentPos[0]=-1;
> > >>
> > >> }
> > >> if ( ! CanEnter ) sig.Price = -1;
> > >>
> > >> }
> > >> bo.ProcessTradeSignals( i );
> > >> }
> > >> bo.PostProcess();
> > >> }
> > >>
> > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > **** 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
> > >
> > >
> > >
> >
> >  
> >
> 
> 
> 
> -- 
> Nawet woda czasem Å&#65533;pi ...
>




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

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