Thanks to everyone who helped off-list. :)

--- In [email protected], "whitneybroach" <whitneybro...@...> wrote:
>
> Here's an interesting tale of confusion.
> 
> Aside from sleep, WTF am I missing?
> 
> A rotational strategy opens new trades only on a certain day of the month, 
> detected by rd_ok (rotation day ok).  if rd_ok==1, it's ok to open a new 
> rotational trade.  The strategy also uses variable stop losses, so a CBT is 
> required to prevent replacement trades from opening until rd_ok==1.  
> (Error43: Variable stops are not supported in Rotational Trading mode.)
> 
> Explore says rd_ok is defined on every bar in the AA date range.
> ///////////// AFl outside of the CBT
> ie_rd_ok = IsEmpty( rd_ok );
> Filter=1;
> AddColumn( dt, "dt", formatDateTime );
> AddColumn( ie_rd_ok, "ie_rd_ok", 1.0 );
> /////////////
> 
> ///////Explore results
> dt    ie_rd_ok
> 1/2/2009      0 // so rd_ok is NOT {Empty} on 1/2/2009
> 1/5/2009      0
> 1/6/2009      0
> // and so forth
> //////
> 
> But Backtest _TRACE of CBT says rd_ok is {Empty} on the first several bars of 
> the test in the same date range.
> //////TRACE with file, line, col and times omitted
> cbtstart
> dt,ie_rd_ok // is rd_ok empty on this bar?
> 1/2/2009,1 // yes, rd_ok IS empty on 1/2/2009; bummer, dude
> 1/5/2009,1 // same here
> 1/6/2009,1
> // and so forth
> ///////
> 
> The difference is not a problem if the CBT correctly tests for IsEmpty and 
> then disables new trade entries by setting sig.Price=-1, a mid-level CBT 
> technique from the Houston presentation.
> 
> //////// CBT 
> SetCustomBacktestProc("");
> if( Status("action") == actionPortfolio )
> {
>   if(Trace) _TRACE( "cbtstart" );
>   if(Trace) _TRACE( "dt,rd_ok" );
>   bo = GetBacktesterObject();
>   bo.PreProcess();
>   ie_rd_ok = IsEmpty( rd_ok );
> 
>   for( bar = 0; bar < BarCount; bar++ )
>   {
>     if(Trace) _TRACE( NumToStr( dt[bar], formatDateTime ) + "," + NumToStr( 
> rd_ok[bar], 1.0 ) );
>     // if empty or not a rotation day, disable new entries
>     if ( ie_rd_ok[bar] == 1 | rd_ok[bar] != 1 )
>     {
>       for( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( bar ) 
> )
>       {
>         if( sig.IsEntry() ) sig.Price = -1;
>       } // for sig
> 
>               } // if rd_ok[bar] != 1
> 
>     bo.ProcessTradeSignals( bar );
> 
>   } // for bar
> 
>   bo.PostProcess();
> 
>   if(Trace) _TRACE( "cbt end" );
> 
> } // if status("action") == actionPortfolio
> ///////
> 
> But that's not happening.  The if statement in the CBT does not appear to 
> detect the ie_rd_ok.
> ///////// AA Results
> Date  Information     
> 1/2/2009 // first date in range in AA for Explore and Backtest
>       Scores:US.LNG=0.144794, JY.LNG=0.0960975 // rest omitted 
>       Enter Long, US.LNG, Price: 129.531, Shares: 1, Commission: 1, Rank: 
> 0.144794, Equity 999998, Margin Loan: 0, Fx rate: 1
>       Enter Long, JY.LNG, Price: 110.28, Shares: 1, Commission: 1, Rank: 
> 0.0960975, Equity 999996, Margin Loan: 0, Fx rate: 1
> //and so forth
> // but there should be no Enter because of the CBT code that follows
> ////////////
> 
> The way I read the results, the _TRACE statement thinks ie_rd_ok==1 and the 
> if statement disagrees -- but they're in the same CBT.
> 
> Is this just another Explore vs Backtester conundrum?
> 
> Best regards,
>


Reply via email to