Hi All,
For some reason, when I use the code below I get a 'long' 'entry' signal on the 12/02/2007 but not on the 13/02/2007. So entering trades using the signals does not match the trades that are generated when I do not use the 'custom backtest'. Can someone please tell me where I'm going wrong?
SetTradeDelays( 0, 0, 0, 0 );
BuyPrice = ShortPrice = SellPrice = CoverPrice = Open;
SetOption( "MaxOpenPositions", 5 );
SetPositionSize( -20, spsPercentOfEquity );
RoundLotSize = 1;
/*** Custom Backtest ***/
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.PreProcess(); // Do pre-processing (always required)
DateTimeValue = DateTime();
for ( i = 0; i < BarCount; i++ ) // Loop through all bars
{
CurrentOpenTrades = bo.GetOpenPosQty();
for (sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
{
if ( sig.IsLong() )
{
if ( sig.IsEntry() ) // && TotalOpenTrades < MaxPos )
{
_TRACE( "Share Bought - Symbol: " + sig.Symbol );
}
else
if ( sig.IsExit() )
{
_TRACE( "Share Sold - Symbol: " + sig.Symbol );
}
}
}
bo.HandleStops(i); // Handle programmed stops at this bar
bo.UpdateStats(i, 1); // Update MAE/MFE stats for bar
bo.UpdateStats(i, 2); // Update stats at bar's end
}
bo.PostProcess(); // Do post-processing (always required)
}
....
Buy = Ref( BuySetup, -1 );
Sell = Ref( SellCondition, -1 );
PositionScore = ROC( C, 63 );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );