GT
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Intrabar Backtest
Collapse
X
-
Intrabar Backtest
So, working on an intrabar backtest using 15 min (primary) and 1 min data and entering on limit orders. If I set liveUntilCancelled to false the limit order is cancel after 1 minute but if I set it to true I am not sure when/how to cancel it as the next bar may fire a new limit entry order . How do i set this up to keep the order working for the full 15 minute primary bar instead of the 1 minute secondary bar?
GTTags: None
-
GreenTrade, this is currently not possible without some extra code. You will have to set liveUntilCancelled to true and then you can cancel the order after 15 minutes have passed with CancelOrder().AustinNinjaTrader Customer Service
-
What happens if the previous 15 bar sent a long entry order names "myLE" and is liveUntilCancelled is set to true, then on the next 15 minute bar I send cancel order for "myLE" but the current bar is sending the entry order again because the entry criteria is met again? Will the new order be working or will it cause a problem?
This is a huge NT limitation that makes me consider other platforms.
GT
Comment
-
GreenTrade, you can check to see if the conditions are still true, and if they are, you can leave the order open and not cancel it at all.
Another option would be to cancel the order every bar and then reissue the order after the cancel if the conditions are still true.AustinNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Austin View PostAnother option would be to cancel the order every bar and then reissue the order after the cancel if the conditions are still true.
GT
Comment
-
So after adding the suggested cancelOrder code and changing the strategy code to include IOrder entry and exit orders I get the following information via TraceOrders. Any ideas where to start with this?
1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=0.1M LimitPrice=1.0074 StopPrice=0 SignalName='myLE' FromEntrySignal=''
1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=1.0034 SignalName='MyStop' FromEntrySignal='myLE'
1/4/2011 3:45:00 AM Ignored PlaceOrder() method at 1/4/2011 3:45:00 AM: Action=Sell OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=1.0034 SignalName=MyStop' FromEntrySignal='myLE' Reason='An Exit() method to submit an exit order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
**NT** An Exit() method to submit an exit order at '1/4/2011 3:45:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=0.1M LimitPrice=1.0079 StopPrice=0 SignalName='MyTarget' FromEntrySignal=myLE'
**NT** Error on calling 'OnBarUpdate' method for strategy 'MyCustomStrat/97641bd0718b424db9d05a027565f88c': Object reference not set to an instance of an object.
1/4/2011 4:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Backtest' Name='Profit target' State=Working Instrument='$AUDUSD' Action=Sell Limit price=1.0079 Stop price=0 Quantity=0.1M Strategy='MyCustomStrat' Type=Limit Tif=Gtc Oco='NT-00000-942' Filled=0 Fill price=0 Token='a0cfa878243f4da39d6761d23c7cdbea' Gtd='12/1/2099 12:00:00 AM'
1/4/2011 4:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00001/Backtest' Name='Stop loss' State=Working Instrument='$AUDUSD' Action=Sell Limit price=0 Stop price=1.0034 Quantity=0.1M Strategy=MyCustomStrat' Type=Stop Tif=Gtc Oco='NT-00000-942' Filled=0 Fill price=0 Token='53cf79c8f8924ed497f86fd6cf325a55' Gtd='12/1/2099 12:00:00 AM'
GT
Comment
-
GreenTrade, I see two different issues in your order traces. First of all is the ignored order, which was caused by you trying to open an order that opposes another, already open, order. NinjaTrader does not allow for two opposing orders to be working at the same time. To get around this, you'll need to either submit only one at a time, or move to an Unmanaged strategy.
The second issue is the object reference error. This is caused when you try to access an object that doesn't exist. You will most likely need to run some null checks on the objects in your code before you access them to be sure they actually exist.AustinNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by strategist007, Today, 07:51 PM
|
0 responses
2 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,967 views
3 likes
|
Last Post
by jhudas88
Today, 06:59 PM
|
||
Started by rbeckmann05, Today, 06:48 PM
|
0 responses
4 views
0 likes
|
Last Post
by rbeckmann05
Today, 06:48 PM
|
||
Started by rhyminkevin, Today, 04:58 PM
|
4 responses
58 views
0 likes
|
Last Post
by dp8282
Today, 06:13 PM
|
||
Started by iceman2018, Today, 05:07 PM
|
0 responses
6 views
0 likes
|
Last Post
by iceman2018
Today, 05:07 PM
|
Comment