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

[amibroker] Re: Max simultaneous open positions



PureBytes Links

Trading Reference Links

This seems to work.  I could probably get a more efficient version for
EOD stats if I could compare year, month and day from DateTime() to
DateNum().  By building tedt and txdt with only yyymmdd, the bar
loop could be from tedt to txdt rather than from 0 to BarCount - 1.

How do we decode DateTime() into yyymmdd for an EOD system without
converting to strings as an intermediate step?

/////////////////////////////////////////////////////
  // Finalize backtester up here

  // CUSTOM METRICS
  
  dt = DateTime();
  sot = IIf( True, 0, 0 );  // simultaneous open trades

  for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
  {
    //
    tedt = trade.EntryDateTime;
    txdt = trade.ExitDateTime;
    for( bar = 0; bar <= ( BarCount - 1 ); bar++ )
    {
      if ( ( tedt <= dt[bar] ) AND ( txdt >= dt[bar] ) )
      {
        sot[bar]++;
      }// if
    }// for bar
  } // for trade

  msot = LastValue( Highest( sot ) );
  bo.AddCustomMetric( "MSOT", msot, msot, 0, 0 );

/////////////////////////////////////////////////////


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.13/632 - Release Date: 1/16/2007 4:36 PM