Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Understanding a Part Filled state on reversal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Understanding a Part Filled state on reversal

    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
    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());
    edit: If all you're wanting is the Signal name, you can use myOrder.Name
    Last edited by NinjaTrader_Matthew; 08-21-2012, 07:16 PM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      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).

      Comment


        #4
        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

        Comment


          #5
          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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by morrnel, Today, 06:07 PM
          2 responses
          14 views
          0 likes
          Last Post morrnel
          by morrnel
           
          Started by thumper57, Yesterday, 04:30 PM
          6 responses
          20 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by sastrades, 05-10-2024, 09:59 AM
          3 responses
          55 views
          0 likes
          Last Post rc5781
          by rc5781
           
          Started by guyonabuffalo, Yesterday, 10:01 PM
          2 responses
          22 views
          0 likes
          Last Post guyonabuffalo  
          Started by reynoldsn, 05-10-2024, 07:04 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X