NinjaTrader Support Forum  

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 03-02-2009, 12:24 PM   #1
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default Order Rejected

3/2/2009 9:13:31 AM|0|32|For a market order, the expiration must be Day or MOC. Affected Order: Buy 3727 Market
3/2/2009 9:13:36 AM|0|128|Strategy 'Strat1' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

How do I set the expiration date for a market order?
Phyre is offline  
Reply With Quote
Old 03-02-2009, 12:34 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Phyre,

When you first start up your strategy you should be able to select Day for the order TIF.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-02-2009, 12:36 PM   #3
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

Okay, Thanks!
Phyre is offline  
Reply With Quote
Old 03-02-2009, 05:04 PM   #4
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default position

When I restarted the strategy NT is showing my position as long even though the market order for the buy was rejected. How do I tell the strategy to reset?
Phyre is offline  
Reply With Quote
Old 03-03-2009, 05:45 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

You are talking about your historical strategy position and not your account position, correct? This is expected, as upon startup the strategy will cycle through all trades to arrive at the last historical open one.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-03-2009, 12:39 PM   #6
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

Actual trading position is flat since the order was rejected. Since NT shows the order as rejected I would think it could keep in sync but it seems to think it's now long and it's not.

To put it simply, the strategy thinks it's 4000 shares long and it's not. How do I reset it?

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
You are talking about your historical strategy position and not your account position, correct? This is expected, as upon startup the strategy will cycle through all trades to arrive at the last historical open one.
Phyre is offline  
Reply With Quote
Old 03-03-2009, 12:42 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Phyre,

If a strategy receives an OrderRejected event it will try to terminate itself. There is no reconciliation done by the strategy. If you start up your strategy again it will start up as if it were brand new.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-03-2009, 05:12 PM   #8
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

It did terminate itself.

When I start the strategy it says 4000 long in the position column...
Phyre is offline  
Reply With Quote
Old 03-04-2009, 05:50 AM   #9
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Hi Phyre, which option do you checked under Tools > Options > Strategies > NinjaScript > On starting a real time strategy?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-04-2009, 01:43 PM   #10
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

Immediately submit.
Phyre is offline  
Reply With Quote
Old 03-04-2009, 01:48 PM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Phyre,

Remember, as you start a strategy it always calculates out a strategy position. A strategy position is NOT to be confused with an account position. Please see this article: http://www.ninjatrader-support2.com/...ead.php?t=4033
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-04-2009, 01:54 PM   #12
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Phyre,

Remember, as you start a strategy it always calculates out a strategy position. A strategy position is NOT to be confused with an account position. Please see this article: http://www.ninjatrader-support2.com/...ead.php?t=4033
This is a new strategy and on it's very first attempt to make a trade it died. The first trade would have put it in a long position if it had worked but it didn't. The actual position is flat.

If the strategy thinks its in a long position, am I to assume that I just have to let it run until it tries to sell it's virtural position so that it will be flat in both virtual and actual? Is there really no way to reset the virtual position to flat???

I guess I'm having a hard time believing that I have no control over the virtual position and that once NT gets out of sync there isn't an easy way reset the strategy back to flat. Am I really going to have to a control variable to my strategy to fake close out my virtual position?

This all makes me suspicious that NT does a lot of guessing when it comes to PnL calculations and reports. Are trade confirmations used at all?
Last edited by Phyre; 03-04-2009 at 02:51 PM.
Phyre is offline  
Reply With Quote
Old 03-04-2009, 01:57 PM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Phyre,

The strategy NEVER knows or cares about what your account position is. To the strategy its always a strategy position. As far as it is concerned, it is always virtual. You need to ensure your account position is in line with the strategy position when you start it. If you do not want to worry about it that much you can just select "Wait until flat before executing live" and then just ensure your account position is flat before you start up your strategy. Then they will become in sync with each other.

If you restart your strategy it goes through and recalculates based on the historical data. There is no setting or resetting. As you start your strategy again it already is a new instance.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-04-2009, 03:03 PM   #14
Phyre
Junior Member
 
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Phyre,

The strategy NEVER knows or cares about what your account position is. To the strategy its always a strategy position. As far as it is concerned, it is always virtual. You need to ensure your account position is in line with the strategy position when you start it. If you do not want to worry about it that much you can just select "Wait until flat before executing live" and then just ensure your account position is flat before you start up your strategy. Then they will become in sync with each other.

If you restart your strategy it goes through and recalculates based on the historical data. There is no setting or resetting. As you start your strategy again it already is a new instance.
Forget about my real account or my real position. What I hear you telling me is that I don't have control over my strategy. I can't start flat. It's always going to start somewhere based on history. Strategies aren't flexible enough to start where I tell them to.
Phyre is offline  
Reply With Quote
Old 03-04-2009, 03:12 PM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Phyre,

The way you have coded your strategy you are evaluating all historical bars on the chart. From those bars you evaluate out a strategy position. This is what you are seeing. If you don't want it to process old bars, don't have it calculate historically.

Code:
if (Historical)
     return;
At the beginning of the OnBarUpdate().
NinjaTrader_Josh 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 Rejected Hugo1 Strategy Development 1 02-09-2009 01:22 AM
Order Rejected by IB Pete S Connecting 1 11-13-2007 01:38 PM
IB order rejected gert74 Connecting 1 10-29-2007 01:26 AM
Rejected StopLimit order EuroFX Automated Trading 3 09-19-2006 01:53 AM
Order rejected - Could not value this order at this time dwil Automated Trading 1 06-07-2006 03:09 AM


All times are GMT -6. The time now is 08:40 PM.