NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 02-09-2009, 04:55 PM   #1
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Question Trouble understanding the Internal (interal?) Order Handling

Could someone please help me understand about NT's Internal Order Handling?

I've been programming using ATM Strategies and OIFs. Now I wish to backtest more, so I'm attempting to re-program my ideas using EnterLimitStop(), etc. for entries.

My strategies deal with entering several order at the beginning of the day, to be very short-lived and everything exited before the day ends. There are many, many orders which will never be hit, because the market never gets up to (or down to) that particular entry. This works very well using ATM Strategies via code and manually entering them in Charts or SuperDoms.

I am having troubles with orders being ignored (i.e. Log entries saying "An Enter() method to submit an entry order ... has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.")

Sadly, I am only attempting to do what I successfully do manually using ATM Strategies: Many Stop Entries above and below the morning price, to be executed when the Stop is triggered. Enter() methods seem to be seeing that there are orders on the other side, and cancelling them.

Based on using AAPLHere's a code snippet:

... Initialize()
CalculateOnBarClose = false;
EntryHandling = EntryHandling.UniqueEntries;
EntriesPerDirection = 15;

... OnBarUpdate()
EnterShortLimit(0, true, 2, 98.00, "Two-Leg1...01");

EnterLongStopLimit(0, true, 2, 102.20, 102.42, "Two-Leg1...02");



These have two separate Signal Names, but I only get the initial Short order showing a State. The Long order in this example, receives the Log error I'd mentioned before.

What am I not getting?


Thanks,

Brian1
Brian1 is offline  
Reply With Quote
Old 02-10-2009, 05:22 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Hi Brian1,

NinjaTrader's internal order handling rules are discussed here - http://www.ninjatrader-support.com/H...verview36.html

They were implemented to reduce unwanted positions in a fast real time trading environment.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2009, 08:22 AM   #3
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Default

Bertrand, I know this well. Could you please respond to my question?

Why does this work manually, but not via code? I would expect the opposite - that you can do more in code than via your GUI.

If someone would kindly look at the code, maybe they could see something that I am not. Should this be that entering a Short Limit order AND a Long StopLimit order be cancelling like it is? What could I possibly be doing wrong?

Please respond,

Brian1
Last edited by Brian1; 02-10-2009 at 08:26 AM.
Brian1 is offline  
Reply With Quote
Old 02-10-2009, 08:49 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Brian1, unfortunately there is no other workaround as putting both in separate strategies, otherwise you would run into the 'Internal Order Handling' procedures.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2009, 12:26 PM   #5
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Default

Thanks for the reply. I have a few questions still?

1) Do you have any thoughts on why I am able to do this using the Chart or SuperDom entries? It is very easy (thankfully) to enter a Short Limit order above the market price, and also enter a Long Limit order below the market price. Do you think that NinjaTrade will take this ability away at some point in the future, realizing that it violates the "Internal Order Handling" procedures. I need to make certain that NT is going to do what I need. Again, it does it in the Charts and SuperDom entries, very nicely.

2) I've used OIFs for ATM Strategies to do this as well. However, because I am unable to Backtest using ATM Strategies, I must now code my strategies to do backtesting. Do you think I can use OIF orders WITHOUT ATM Strategies (i.e. leaving that field blank) and still have orders above and below the current market price?

(Remember these are all ORDERS. They are NOT TRADES or POSITIONS above and below ... but simply orders.)

3) Oh, one more question: I'd been told that NT v7 will have ATM Strategy backtesting. Is this still in the plans?

Thanks,

Brian1
Brian1 is offline  
Reply With Quote
Old 02-10-2009, 12:51 PM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Hi,

1. No I am not aware of a change in this regard. For automatic strategies, you can use separate strategies to accomplish this.

2. Yes, the ATM strategy field is an optional value in the OIF files - http://www.ninjatrader-support.com/H...nFilesOIF.html

3. You can manually code out the ATM strategies behavior for backtesting, NinjaTrader 7 feature announcements will be made when available - thanks for your understanding.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2009, 08:10 PM   #7
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Default

Thank you Bertrand, for your responses.

Please note that answer #3 is exactly what I am asking to do. Because of NT's "Internal Order Handling" procedures, one actually is prevented from writing code to backtest something that can be accomplished using an ATM Strategy.

It's a Catch-22:
(a) I cannot backtest ATM Strategies. So I'm encouraged to write code to do that.
(b) If I try to write code to build a backtestable strategy without use of ATM Strategies, I receive errors saying I cannot place Enter() orders above and below the current price. Something that ATM Strategies allow me to do (and that I need to do).

Are you seeing the issue here? Could I please discuss this with a developer or manager? This matters greatly to me.

Thank you,

Brian1
Last edited by Brian1; 02-10-2009 at 08:20 PM.
Brian1 is offline  
Reply With Quote
Old 02-11-2009, 03:10 AM   #8
MJT
Senior Member
 
Join Date: Jun 2006
Posts: 111
Thanks: 0
Thanked 1 time in 1 post
Default

Brian, You have to write the code so that you avoid violating the order handling rules.
If this is just for backtesting, then I think your strategy needs to wait until the market price reaches your entry price, then place the order. To use it for real trading you may want your order placed earlier, in which case your strategy would place the order only when price is a certain distance from your planned entry price, then cancel it if price moves away and gets close to another order entry point.
I hope that makes sense.
MJT is offline  
Reply With Quote
Old 02-11-2009, 07:08 AM   #9
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,411
Thanks: 252
Thanked 976 times in 959 posts
Default

Thanks for your input MJT.

Not sure I follow Brian, you should be able to code out ATM strategies for backtesting as those would (if for example long) place exit orders above the market and a stop for protection below.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-13-2009, 09:13 AM   #10
Brian1
Member
 
Join Date: Feb 2008
Location: Overland Park, KS
Posts: 94
Thanks: 0
Thanked 0 times in 0 posts
Send a message via Skype™ to Brian1
Default

Hey thanks MJT. Much appreciated.

Writing it that way is my long term intent. I just thought I'd be able to more quickly backtest my theories. ATM Strategy has worked great for forward testing, but doesn't allow backtesting at this time.

So ... I guess I've got my work cut out for me.

Thanks to both of you.

Brian1
Brian1 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Order Handling in Backtest 8DTK8 Strategy Analyzer 1 10-23-2008 04:11 PM
Same order is getting fired twice. order state and handling problem Rocket130713 Automated Trading 19 09-22-2008 06:58 AM
Internal Order Handling Rules for Stop Limits wayneFH Strategy Development 7 06-14-2008 06:39 PM
Order Entry Placement (basic understanding) phineas Automated Trading 2 04-04-2008 08:55 AM
Order error handling Aussie2 Strategy Development 4 12-27-2007 06:36 AM


All times are GMT -6. The time now is 09:00 PM.