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().
        https://ninjatrader.com/support/help...ancelorder.htm

        Below I am providing a link to a forum post with helpful information about getting started with NinjaScript.
        https://ninjatrader.com/support/foru...040#post786040
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Realsmooth3, Yesterday, 09:10 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by wooofad, 06-15-2020, 01:08 PM
        8 responses
        93 views
        0 likes
        Last Post echoxray  
        Started by bubblegum, Today, 12:00 AM
        0 responses
        2 views
        0 likes
        Last Post bubblegum  
        Started by eseorvuda, Yesterday, 10:28 PM
        0 responses
        2 views
        0 likes
        Last Post eseorvuda  
        Started by ctrent, Yesterday, 09:58 PM
        0 responses
        5 views
        0 likes
        Last Post ctrent
        by ctrent
         
        Working...
        X