For some reason if I do the backtesting on historical datas or with market replay datas, the command EnterLongLimit completely ignores the price input.
The Code:
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CurrentBar != CurrentBars[0])
{
CancelOrder(ShortHigh);
}
if (LongHigh == null)
if (High[0] < High[1])
{
EnterLongLimit(4,High[1],"LongHigh");
CurrentBar = CurrentBars[0];
}
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled,
double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
if(order.Name == "LongHigh")
{
LongHigh = order;
}
if (LongHigh != null && LongHigh == order)
{
if (LongHigh.OrderState == OrderState.Cancelled)
{
LongHigh = null;
}
else
{
LongHigh = null;
}
}
}
The limit order is always placed at the opening price of the next bar.
Best
S.
Comment