I try to submit a buy limit order at market on close and valid for the next day. The backtest is executed based on daily bars. I also add a 1 minute timeframe to have intraday granularity. But the buy limit order is ignored and I don't understand why. According to the high/low values of the concerning trading day, it should got filled, I guess.
Here is the code:
protectedoverridevoid Initialize()
{
Add(PeriodType.Minute, 1);
CalculateOnBarClose = true;
TraceOrders = true;
}
protectedoverridevoid OnBarUpdate()
{
if (BarsInProgress == 0)
{
Print("Time: " + Time[0].ToString());
Print("High: " + High[0].ToString());
Print("Low: " + Low[0].ToString());
if (Close[0] > Close[1] && counter == 0)
{
EnterLongLimit(1, true, 1, Low[0] - 10 * TickSize, "Buy limit");
counter = 1;
}
}
}
Here is the log:
Time: 19.09.2007 00:00:00
High: 1,6559
Low: 1,6492
19.09.2007 00:00:00 Entered internal PlaceOrder() method at 19.09.2007 00:00:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1,6491 StopPrice=0 SignalName='Buy limit' FromEntrySignal=''
20.09.2007 00:00:00 Cancelled order due to end of session handling: BarsInProgress=1: Order='NT-00000/Back101' Name='Buy limit' State=Working Instrument='$EURCHF' Action=Buy Limit price=1,6491 Stop price=0 Quantity=1 Strategy='gtctest' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='e598d36379a94519a6370639446fdcee' Gtd='01.12.2099 00:00:00'
Time: 20.09.2007 00:00:00
High: 1,6534
Low: 1,6444
Regards
Ralph
Comment