PDA

View Full Version : BarsInProgress[1] causing expiration of BarsInProgress[0] orders


nolantx
11-26-2008, 10:16 PM
With TraceOrders on, I can see that with 3 active orders, a new bar on the higher timeframe of the same instrument (BarsArray[1]) will cause the first of the three orders to expire but leave the other two.

How can I keep all orders active until a new bar of the BarsArray[0] timeframe?

NinjaTrader_Ray
11-27-2008, 08:56 AM
Are your orders being submitted in the context of BarsInProgress[1] or [0]?

nolantx
11-27-2008, 06:32 PM
All orders are submitted withing the body of an

if(BarsInProgress == 0)
{
order and position management logic ..
}

NinjaTrader_Ray
11-28-2008, 06:52 AM
Would you be able to to create a basic script that will demonstrate this to us so we can run some further tests?

nolantx
11-29-2008, 02:49 PM
I have attached a simple strategy which I placed on an ES 233t chart that adds the ES 5000v.

If an order is working on the primary timeframe while a new bar is completed on the secondary (5000v), the order is cancelled.

NinjaTrader_Ray
11-29-2008, 03:02 PM
We will check this out. Thanks.

NinjaTrader_Josh
12-01-2008, 08:01 AM
nolantx,

I can't seem to get your strategy working the way you have described. Please inform me of exact reproduce steps. I am setting EntriesPerDirection to 3 and running on CalculateOnBarClose = true. Thank you.

nolantx
12-02-2008, 07:32 PM
When Entries per Direction is set to 3 and Entry handling is set to UniqueEntries, all 3 orders are placed and the 1st order is canceled on the completion of the higher timeframe bar.

When Entries per Direction is set to 3 and Entry handling is set to AllEntries, the third order is rejected with the following log entry:

Ignored PlaceOrder() method at 12/2/2008 8:32:19 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=829.00 StopPrice=0 SignalName='S3' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

Either way, the 1st order is canceled with the higher timeframe (BarsArray[1]) bar completes, as follows:

Cancelled expired order: BarsInProgress=1: Order='72a3fc58697d412293f5c76385728f45/Replay101' Name='S1' State=Working Instrument='ES 12-08' Action=SellShort Limit price=828.75 Stop price=0 Quantity=1 Strategy='Multi_Test' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='72a3fc58697d412293f5c76385728f45' Gtd='12/1/2099 12:00:00 AM'

The logic cannot, basic as it is, should not place any orders while BarsInProgress = 1.

Please advise, there must be something I'm overlooking.

NinjaTrader_Josh
12-03-2008, 07:22 AM
nolantx,

I used your strategy and do not experience the behavior you are stating. Please ensure you are on NT6.5.1000.7.

This is what I get:
12/3/2008 7:18:27 AM BarsInProgress 1
12/3/2008 7:18:27 AM BarsInProgress 0
12/3/2008 7:18:28 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:28 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S1' FromEntrySignal=''
12/3/2008 7:18:28 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:28 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S2' FromEntrySignal=''
12/3/2008 7:18:28 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:28 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S3' FromEntrySignal=''
12/3/2008 7:18:30 AM BarsInProgress 1
12/3/2008 7:18:30 AM BarsInProgress 0
12/3/2008 7:18:31 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S1' FromEntrySignal=''
12/3/2008 7:18:31 AM Ignored PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S1' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
12/3/2008 7:18:31 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S2' FromEntrySignal=''
12/3/2008 7:18:31 AM Ignored PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S2' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
12/3/2008 7:18:31 AM Entered internal PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S3' FromEntrySignal=''
12/3/2008 7:18:31 AM Ignored PlaceOrder() method at 12/3/2008 7:18:31 AM: Action=SellShort OrderType=Limit Quantity=100 LimitPrice=50.00 StopPrice=0 SignalName='S3' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
12/3/2008 7:18:33 AM BarsInProgress 1
You can clearly see BIP1 firing off yet no order cancellation occurred. The next BIP0 call sends the same orders again and of course these are going to be ignored because we are already holding 3 orders.

nolantx
12-03-2008, 11:51 AM
Josh,

You are not testing this strategy on the ES. If I put this strategy on another contract as you have done, it works fine.

Please try this on the same contract as the higher timeframe (ES 12-08) with Entries per direction of 3 and try both 'UniqueEntries" and 'Allentries'. I think you'll see different results.

NinjaTrader_Josh
12-03-2008, 12:11 PM
That is expected behavior. If you are using the same instruments you need to resubmit on all bar series of that instrument, not just the one you submitted to.

nolantx
12-03-2008, 01:21 PM
Thank you so much Josh, somehow I overlooked this in the documentation. Can you post a link to those guidelines please.

NinjaTrader_Josh
12-03-2008, 01:27 PM
http://www.ninjatrader-support.com/HelpGuideV6/Overview36.html

kcsystemtrader
02-07-2009, 02:48 PM
That is expected behavior. If you are using the same instruments you need to resubmit on all bar series of that instrument, not just the one you submitted to.

I am having a similar issue. My strategy runs only on secondary bar series (2 bar series for one instrument):


Initialize:
//Add tick by tick bars to strategy
Add(PeriodType.Tick, 1);

OnBarUpdate:
// 1 min bars
if (BarsInProgress == 0)
return;

//Enter on tick updates but use primary bars for entry signal
//Current tick > Closing price of previous 1 min bar
if (BarsInProgress == 1 && Close[0] > Closes[0][1])
EnterLongLimit(PositionSize, Close[0], "Buy");


A limit order gets submitted and is immediately cancelled and resubmitted on the next tick update. How do I resubmit the order (on both bar series) on each tick update so that it doesn't get cancelled?

I thought that would happen automatically since I have not referenced a specific BarsInProgress reference in my EnterLongLimit statement.

NinjaTrader_Ben
02-08-2009, 10:05 AM
Hello,


I recommend checking to see if the "Buy" order is in place and building a bool flag that tells you if the order should be placed based on your trade criteria.. If it is not, place the order.