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 [email protected], "woodshedder_blogspot"
<woodshedder_blogs...@...> wrote:
>
> 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 [email protected], "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();
> > }
> >
>