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

Checking IExecution and IExecution.IOrder

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

    Checking IExecution and IExecution.IOrder

    Was wondering if the proper way to check the dirrection of an execution is to look at the execution.MarketPosition property? Also wondering what is the difference between execution.Quantity and execution.Order.Filled properties? TIA

    #2
    execution.MarketPosition tells you what kind of execution this is. Whether it was a buy or sell.

    execution.Quantity is the quantity of the particular execution event you are processing. execution.Order.Filled is the filled amount for the order. Orders can be filled by multiple executions and execution.Order.Filled will reflect all the executions. There are implications to using execution.Order.Filled though. Since NT is multi-threaded it is possible to have race conditions where execution.Order.Filled could be greater than the total filled execution.Quantity received.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Okies, one more question about advanced order handling. Is there any guarantee on order execution sequencing? For example if I have two target sell orders at different prices and the previous bar's high was lower then either order, am i guaranteed that on a succeding bar that would execute both orders that the order with the lower order will fire OnExecution first? TIA

      Comment


        #4
        No guarantees.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          After spending many hours trying to implement a single entry, multi exit system with dynamic limit orders i think i finally put something together that is robust enough to backtest with. Just to confirm what i think i've figured out so far, if you have multiple targets associated with a stop order, its your responsibilty to change the size of the stop when one of the targets is executed? Also i was wondering if there is anyway to get the BarsInProgress property associated with an IOrder? Finally do orders throw any exceptions, when something goes really wrong with an order I see a message in the log tab, but when adding try catch e.ToString() to my code these errors don't seem to throw exceptions.
          Last edited by darckeen; 04-15-2009, 05:59 AM.

          Comment


            #6
            darckeen,

            To scale-out you have to scale-in. If you are not scaling-in the internal signal tracking will likely go out of sync. When signal tracking is intact partial fills or anything like that will automatically amend the quantities of your remaining exit orders.

            There is no information on which BarsInProgress the order was submitted to, but you can use the IOrder to determine which instrument it trades on.

            When an order goes haywire there is no exception thrown. The strategy will likely terminate itself after closing all open positions and cancelling all open orders.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Is there anyway at all to check if an order is rejected? I've been encountering some problems when my strat submits a limit sell order bellow the bid, limit buy order above the offer, sell stop above the bid, buy stop bellow the bid. I've put in a check to modify the orders to conform to those constaints but my worry is that in the time between the adjustment and the execution the modified order could still be rejected in a fast market.

              Comment


                #8
                Use OnOrderUpdate() and check the OrderState on your IOrder.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Anyway to check to see why the order was rejected? Say if it was rejected due an invalid price versus rejected due to insufficient buying power?

                  Comment


                    #10
                    darckeen,

                    When an order is rejected it will already halt the strategy for you with a popup message stating the rejected reason. Other than that, no you will not know.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Yup, I just was testing my strategy having it send intentinally invalid orders and got that popup. I was my intention to handle the error myself and switch to a market order when and invalid limit/stop order is submitted and let the strategy keep running. Anyway to avoid having the strategy shutdown like this when an invalid order is submitted?

                      Comment


                        #12
                        Highly not recommended unless you are absolutely 100% sure you know what you are doing. You need to handle 100% of all possible error scenarios or else your strategy may behave unexpectedly.

                        Josh P.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bortz, 11-06-2023, 08:04 AM
                        47 responses
                        1,607 views
                        0 likes
                        Last Post aligator  
                        Started by jaybedreamin, Today, 05:56 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post jaybedreamin  
                        Started by DJ888, 04-16-2024, 06:09 PM
                        6 responses
                        19 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by Jon17, Today, 04:33 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post Jon17
                        by Jon17
                         
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        15 views
                        0 likes
                        Last Post Javierw.ok  
                        Working...
                        X