[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Max simultaneous open positions



PureBytes Links

Trading Reference Links

How do we know the greatest number of simultaneously open positions
during a backtest?  (Perhaps the MaxOpenPositions is never approached
during the test?)

Does this code make sense?  Is a low-level CBT truly required for 100%
accuracy?

Happy New Year,
Whitney

///////////////////////////////////////////////////////////
// test max simultaneously open positions
// record custom metric

SetOption( "MaxOpenPositions", 1000 );
SetOption( "CommissionMode", 3 );
SetOption( "CommissionAmount", 0.0 );
SetPositionSize( 1, spsShares );

// buy and sell signals set here

SetCustomBacktestProc("");

// mid-level custom backtester
if( Status("action") == actionPortfolio )
{

  bo = GetBacktesterObject();
  bo.PreProcess();
  
  mop = 0; // max open positions

  for( bar = 0; bar < BarCount; bar++ )
  {

    bo.ProcessTradeSignals( bar );

    // update max open positions
    p = 0;
    for ( openpos = bo.GetFirstOpenPos; openpos; openpos =
bo.GetNextOpenPos() )
    {
      p++;
      if ( p > mop ) mop = p;
    }

  } // for bar

  bo.PostProcess();
  
  bo.AddCustomMetric( "Max open positions", mop );

} // if status("action") == actionPortfolio
///////////////////////////////////////////////////////////


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.1/611 - Release Date: 12/31/2006 12:47 PM