Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there an open order?

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

    Is there an open order?

    Hello everyone, how do I code to verify if an order is open or not? (market order).

    Code:
     orden = OrderState();
    if (orden == false){
    //"The order is no exist, not open" how to select by order name and type?
    }
    Thanks and regards.
    Last edited by samir; 04-10-2021, 07:19 PM.

    #2
    Hello samir,

    In OnOrderUpdate() check the order.OrderState to be OrderState.Working or OrderState.Accepted.

    Below is a link to the help guide which includes an example.
    https://ninjatrader.com/support/help...rderupdate.htm
    https://ninjatrader.com/support/help.../nt8/order.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am learning to program, and I do not understand some concepts that appear in the manual.
      Very thanks, can you tell me how to detect if this order is open or not?

      Code:
      EnterShort(Convert.ToInt32(DefaultQuantity), @"one");
      And, how to "delete stop loss" for an order "one"?? (no stop loss).

      I have open order "@one" with stoploss, and then I want to remove the stop loss.

      I need to know:
      -If exist open market order "@one"
      -Delete stop loss ("@one")

      very thanks and regards
      Last edited by samir; 04-12-2021, 08:57 AM.

      Comment


        #4
        Hello samir,

        In OnOrderUpdate:
        Code:
        if (order.Name == "one" && (order.OrderState == OrderState.Accepted || order.OrderState == OrderState.Working))
        {
        // the order named 'one' is still working
        }
        Set methods, like SetStopLoss(), cannot be cancelled or unset.

        If you are using ExitShortStopMarket or ExitShortStopLimit() these can be cancelled with CancelOrder().


        Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        607 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        353 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 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
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X