![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
Hello,
My strategy employs limit orders and is designed to be always in the market. Thus, outside of the first trade, each trade is a reversal. I'm using Managed approach, and when I reverse, the log will show a "Close Position" trade and a "myOrder" trade, the Close Position of course being Ninja automatically placing an order to first go flat. I need to monitor the order state after the reversal order is submitted. The question I have is this: if I check if OrderState.PartFilled ==true, is that checking the "myOrder" part only, or could a part fill on the "Close Position" order cause a part filled state? If the answer is checking the state is regarding "myOrder", that begs the question: how can I check the state of the Ninja created "close position" order? If the answer is the state is checking both, then my question is how can I tell the difference between the "close position" state and the "myOrder" state? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,786
Thanks: 160
Thanked 567 times in 558 posts
|
Coolmoss,
Is "myOrder" the IOrder object name, or the signal name? Did you name these both the same? It should be checking both, as you'd have just a single order object. If you want to tell the difference, you can read the signal name string of that order - which would be the entry signal you gave it: "myOrder" or the NinjaTrader named: "Close Position" or "Sell", "BuyToCover", etc. Code:
if (myOrder.OrderState == OrderState.PartFilled) Print(myOrder.ToString());
Matthew
NinjaTrader Customer Service
Last edited by NinjaTrader_Matthew; 08-21-2012 at 07:16 PM.
|
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
Hi Matthew,
Thanks much for your help. I do understand what you've said, but it's not quite what I'm asking. Let me try to rephrase with a more concrete example: Let's say strategy is short. Then the strategy gets a signal to go long. Ninja trader places two separate orders. One of the orders is the myOrder IOrder object (and it has some unique signal name based on various condition sets) which is programmed in the strategy. I understand how to check if this is part filled. Also, Ninjatrader, simultaneously places an order; under the hood so to speak, which shows up in the log named as "Close Position". So, if I was originally short 2 contracts, and strategy gets signal to go long, there is a buy order for 2 contracts called "Close Position" and a buy order for 2 contracts called whatever the signal was actually named (lets say "myEntrySignalName"). Is there a way to distinguish a part fill on the Close Position versus myEntrySignalName? This is actually a pretty important thing to be able to do and it's not obvious how to do so. So, again, from my first post: when checking for some order state against the order object AND signal name, is the check against the whole closePosition/myOrder combination, or is it just checking the the second portion (and not the Close Position order which Ninja places under the hood). |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Hello,
For this level of control you would be bordering into the unmanaged approach and likely would be best switching to that. However If I understand correctly you can use OnOrderUpdate() and for each order that gets processed watch for an order that has the name "Close Position" and you can check what got filled on it. This is just identify an order via its order name however. To track the exit order you would need to use the unmanaged approach and submit the exit manually from the strategy this way you could track it and nothing going on "Behind the scenes". -Brett
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
|
Thank you both, helps a lot. I continue to be amazed at how much can be done with Managed if you really learn the ins and outs of Ninjascript. I'll experiment some with this and if it doesn't do what I need, then unmanaged will be coming sooner rather than later in my plans
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OrderState question. Part-filled. | Rocket130713 | Automated Trading | 10 | 10-25-2012 11:37 AM |
| how to know the order status (filled, not filled etc) | Nirajkumar | Strategy Development | 2 | 03-24-2012 10:19 PM |
| Part filled FX order | wildebeest | Automated Trading | 1 | 10-13-2010 07:05 AM |
| 5 tick reversal/ 5 bar reversal | Kevin21 | Charting | 1 | 10-09-2009 09:25 AM |
| Incorrect order qty and filled price after order filled | elconna | Miscellaneous Support | 3 | 10-07-2009 10:51 AM |