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();
}




Reply via email to