I'm surprised that I haven't had a response.  Whilst I haven't been 
able to resolve it, I would have expected that it wasnn't a difficult 
problem.

Graham
>
> Just starting to get my hands dirty in the Custom Backtester and 
have 
> read everything I can find.
> 
> Some time ago I found some code on this forum for a custom metric 
for 
> Max Open Positions - it has worked fine on Long systems but when I 
> try it on a Short system, it returns O max Open Trades.  Have I 
> missed something?
> 
> Code follows.
> 
> Graham
> 
> SetOption("UseCustomBacktestProc", True);
> SetCustomBacktestProc("");
> 
> //==================  Open Position Count  ==================
> vCounts = Cum( 0 );
> vMaxCount = 0;
> 
> if ( Status( "action" ) == actionPortfolio )
> {
>     vBO = GetBacktesterObject();
>     vBO.PreProcess();
> 
>     for ( vBar = 0; vBar < BarCount; vBar++ )
>     {
>         vBO.ProcessTradeSignals( vBar );
>         vCnt = 0;
> 
>         for ( vPos = vBO.getFirstOpenPos(); vPos; vPos = 
> vBO.getNextOpenPos() )
>         {
>             vCnt++;
>             _TRACE( "Count: " + vCnt );
>         }
> 
>         vCounts[vBar] = vCnt;
> 
>         if ( vCnt > vMaxCount )
>         {
>             vMaxCount = vCnt;
>         }
>     }
> 
>     vBO.PostProcess();
> 
>     vBO.addCustomMetric( "Max Open Posn", vMaxCount );
> 
>     AddToComposite( vCounts, "~OpenPosCount", "V", atcFlagDefaults 
| 
> atcFlagEnableInBacktest | atcFlagEnableInPortfolio );
> }
>


Reply via email to