I've imported end of day data into NinjaTrader, and with the code below, am not getting the results I expected.
protected override void Initialize()
{
CalculateOnBarClose = true;
ExitOnClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
// Is Close[-1] yesterday's open? Is Open[0] today's open?
if (Open[0] < Close[-1])
{
EnterLong(DefaultQuantity, "MyBuy");
}
}
When I look at the chart in the Backtest summary, it seems that I buy at today's open and sell at tomorrow's open. How can I ensure to buy at today's open and sell at today's close?

Comment