![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Phyre,
When you first start up your strategy you should be able to select Day for the order TIF.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Okay, Thanks!
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#7 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
It did terminate itself.
When I start the strategy it says 4000 long in the position column... |
|
|
|
|
|
#9 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
Hi Phyre, which option do you checked under Tools > Options > Strategies > NinjaScript > On starting a real time strategy?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Immediately submit.
|
|
|
|
|
|
#11 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#12 | |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
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.
|
|
|
|
|
|
|
#13 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#14 | |
|
Junior Member
Join Date: Feb 2009
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
|
|
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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;
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |