Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to check the pending orders (Stop, Limit, StopLimit)

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

    how to check the pending orders (Stop, Limit, StopLimit)

    Hello everyone!
    If I ask the wrong question, sorry.
    I moved from mql ...

    this is a test for the presence of market orders (for example, one of the options):
    if (Position.MarketPosition == MarketPosition.Flat)
    if (Position.MarketPosition ==MarketPosition.Long)
    if (Position.MarketPosition ==MarketPosition.Short)

    And how to check if the pending orders? (Stop, Limit, StopLimit)
    If a pending order is set one or more?


    ps. Sorry for my bad English.

    #2
    Welcome to our forums zilibob4ik - this would not be a check for any market orders, but a check for which market position your strategy would current have, so if it would be flat, long or short - this is not tied to any specific order type, but the actual position the strategy is current working with.

    If you want to check an orderstate of a specific strategy generated order, please work with the IOrder object - http://www.ninjatrader.com/support/h...ightsub=IOrder

    A more detailed reference sample for those advanced methods would be given here - http://www.ninjatrader.com/support/f...ead.php?t=7499

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Welcome to our forums zilibob4ik - this would not be a check for any market orders, but a check for which market position your strategy would current have, so if it would be flat, long or short - this is not tied to any specific order type, but the actual position the strategy is current working with.

      If you want to check an orderstate of a specific strategy generated order, please work with the IOrder object - http://www.ninjatrader.com/support/h...ightsub=IOrder

      A more detailed reference sample for those advanced methods would be given here - http://www.ninjatrader.com/support/f...ead.php?t=7499
      Thank you for your response.
      But of these links, I have not found examples of using commands
      if there is an established pending orders.

      The strategy set EnterLongStop and EnterShortStop.
      How to check their availability and their parameters (price, volume ...)
      Maybe need to remember in the strategy,
      which have been set pending orders and for what price.

      Comment


        #4
        You would be able to check off each of those properties in the assigned IOrder object, for example .LimitPrice, .StopPrice, .Quantity.

        Let's say on one bar you go if (entryOrder == null && myCondition) entryOrder = EnterLongLimit(1, 1547.0, "LongLimit");

        Then on the next bar you could check if (entryOrder != null) Print("LimitOrder at " + entryOrder.LimitPrice);

        Comment


          #5
          Originally posted by zilibob4ik View Post
          Thank you for your response.
          But of these links, I have not found examples of using commands
          if there is an established pending orders.

          The strategy set EnterLongStop and EnterShortStop.
          How to check their availability and their parameters (price, volume ...)
          Maybe need to remember in the strategy,
          which have been set pending orders and for what price.
          Used named IOrders. You can check their state by simply querying them for their state, "pending" or otherwise.
          Last edited by koganam; 08-28-2013, 11:52 AM.

          Comment


            #6
            Bertrand, thank you very much!

            I do not understand, ninjatrader launches strategy performs an error?
            My strategy after its launch, sets the pending orders

            Code:
            protected override void Initialize()
            {
              CalculateOnBarClose = true;
              Unmanaged = true;
            }
            protected override void OnBarUpdate()
            {       
            many conditions....
              SubmitOrder(0, OrderAction.Buy, OrderType.Stop.....
              SubmitOrder(0, OrderAction.Sell, OrderType.Stop.....
            }
            But, I do not understand why so many established orders, despite the existence of conditions.
            As if the function OnBarUpdate () is looped.
            I spent a little experiment.


            Code:
            protected override void Initialize()
            { 
              CalculateOnBarClose = true;
            }
              int start=0;
            
              protected override void OnBarUpdate()
            {
            Print("OnBarUpdate Starting: "+start);
            start++;
            ....
            }

            In the end, I was really surprised...

            ----Output panel-------

            Code:
            OnBarUpdate Starting: 0
            OnBarUpdate Starting: 1
            OnBarUpdate Starting: 2
            ...
            ...
            ...
            OnBarUpdate Starting: 2640
            OnBarUpdate Starting: 2641
            OnBarUpdate Starting: 2642

            WHY?
            Why is this happening?
            After launching the strategy, if enabled CalculateOnBarClose = true;
            code needs to be run once, after the close of the current bar.
            Last edited by zilibob4ik; 08-31-2013, 12:13 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            670 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            379 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            582 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X