When I run the CBT code listed below the trace statement return 
something like the following:

[864] Can Enter bar = LUK Pos: {EMPTY} isEntry: -1
[864] Pos already exists LUK Pos: <IDispatch> isEntry: -1
[864] Can Enter bar = LUK Pos: {EMPTY} isEntry: -1

Why is it that "pos" returns null and isEntry returns -1. Also I can 
not explain "pos" returning  <IDispatch>. I thought these variables 
were supposed to return 1 and 0 for true and false. Can anybody 
explain? TIA




SetBacktestMode( backtestRegularRaw2 );
SetCustomBacktestProc("");
MaxBuys = 3;
if ( Status( "action" ) == actionPortfolio )
{
        bo = GetBacktesterObject();
        bo.PreProcess();
        for ( i = 0; i < BarCount; i++ )
        {
                dtstr = DateTimeToStr( dt[ i ] );   
                cntBuys = 0;
                for ( sig = bo.GetFirstSignal( i ); sig; sig = 
bo.GetNextSignal( i ) )
                {
                        if ( sig.IsEntry() )
                        {
                                CanEnter = False;
                                if ( CntBuys <= MaxBuys )
                                {
                                        pos = bo.FindOpenPos( 
sig.Symbol );
                                        if ( pos )
                                        {
                                        _TRACE( "Pos already exists " 
+ sig.Symbol + " Pos: " + Pos + " isEntry: " +  sig.IsEntry());
                                        }
                                        else
                                        {
                                                CanEnter = True;
                                                CntBuys++;
                                        _TRACE( "Can Enter bar = " + 
sig.Symbol + " Pos: " + Pos + " isEntry: " +  sig.IsEntry());
                                        }
                                }
                                if ( ! CanEnter )
                                        sig.Price = -1;
                        }
            if ( sig.IsExit() )
                break; 
        }
        // now check all open positions and find matching signals
                for ( pos = bo.GetFirstOpenPos(); pos; pos = 
bo.GetNextOpenPos() )
                {
                        if ( ( sig = bo.FindSignal( i, pos.Symbol, 
2 ) ) ) // look for exit position matching given open pos
                        {
                                if ( pos.BarsInTrade < 2 )
                                        sig.Price = -1; // ignore 
sell signal if trade is too young
//                                      _TRACE("i= " + i + " Date: " 
+ dtstr + " BarsinTrade: " +  pos.BarsInTrade);
                        }
                }
        bo.ProcessTradeSignals( i );
        }
        bo.PostProcess();
}


Reply via email to