Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get the current Order

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

    How to get the current Order

    Hi,

    After I submited few entry orders. (see example)
    I can only see the last position status by checking the "Position". Is there a command to monitor the current order (such as "Order")?

    OnBarUpdate()
    {
    if (cond1) EnterLong("T1");
    if (cond1) EnterLong("T2");
    if (cond1) EnterLong("T3");
    if (Position.MarketPosition != MarketPosition.Flat){
    Print("P:" + Position.ToString());
    if (Order.Name == "T2") { /* looking for Current Order */
    Print("Order:" + Order.ToString());
    }
    }
    }

    Regards,
    Toyogo

    #2
    Sure, OnOrderUpdate() -

    More information - http://www.ninjatrader-support.com/H...derUpdate.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Hi,

      OnOrderUpdate only triggerred whenever there is a state change. It doesn't help in my case. I want to monitor the current price against each order (eg. I've 3 orders onhand) inside OnBarUpdate(). What command is available?

      Regards,
      Toyogo

      Comment


        #4
        OnOrderStatus triggers as the price of the order is changed. Thus, you can monitor any order price change.

        Comment


          #5
          Hi,

          I am saying that in my case, I do not change the order price after entering it through EnterLong(). However, the market price or when I do a backtesting, is the historical price keep advancing and changing. Therefore it will not trigger the OnOrderUpdate. I want to be able to call the order (of cause, one way is to use ord1=EnterLong() to keep the variable as a reference). I am looking for a standard variable for order such as "Position" where I can check the curent position.

          Regards,
          Toyogo

          Comment


            #6
            Not sure I follow. If you change the order price, then OnOrderStatus would be fired (even on backtest). If you don't change the order price then you would need to code a variable like Josh suggested in your other thread on the same issue.

            The current position can be checked on the Position property.

            Comment


              #7
              Originally posted by NinjaTrader_Dierk View Post
              Not sure I follow. If you change the order price, then OnOrderStatus would be fired (even on backtest). If you don't change the order price then you would need to code a variable like Josh suggested in your other thread on the same issue.

              The current position can be checked on the Position property.
              Hi,

              You've got my point, "The current position can be checked on the Position property". However, it only has

              Position.AvgPrice
              Position.GetProfitLoss
              Position.MarketPosition
              Position.Quantity

              I want to be able to find the order property of the current position such as order.Name etc.

              Regards,
              Toyogo

              Comment


                #8
                A position is not an order. A position could be built from multiple orders. Thus, there is no reference back from a position to the orders which built the position.

                Comment


                  #9
                  Originally posted by NinjaTrader_Dierk View Post
                  A position is not an order. A position could be built from multiple orders. Thus, there is no reference back from a position to the orders which built the position.
                  Hi,

                  So are u saying that it is the sum of all orders with the same symbol? eg. for EURUSD:

                  EnterLongLimit(100000,1.5810); when the 1st one is triggered,
                  Position.AvgPrice /* = 1.5810 */
                  Position.GetProfitLoss
                  Position.MarketPosition
                  Position.Quantity /* = 100000 */


                  EnterLongLimit(200000,1.5800); when the 2nd one is triggered, Position.AvgPrice /* = 1.5805, ave of 1.5800/1.5810 */
                  Position.GetProfitLoss
                  Position.MarketPosition
                  Position.Quantity /* = 300000, sum of 100k+200k */


                  If this is the case. Then you are right that the Position cannot be referenced to order.

                  Is there a command to find the current order property (back to my question) that I want to check it in OnBarUpdate()?

                  Regards,
                  Toyogo

                  Comment


                    #10
                    Please make sure you understand the concept of orders/executions/positions:
                    - an order could yield multiple executions (partial fills)
                    - a position could be built from multiple executions/orders

                    Thus there is no concept of an "order property" at the position. If you want to track order fills, then you could monitor the OnOrderStatus() event.

                    Comment


                      #11
                      Hi,

                      I've got you!

                      Thanks
                      Toyogo

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      602 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      347 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      560 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      559 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X