Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

get status of position

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

    get status of position

    Hello

    If I place three similar orders triggered by the same event with different stop losses and targets

    EnterLong(100,"E1");
    EnterLong(100,"E2");
    EnterLong(100,"E3");

    How can I monitor the status of each position. For example I can check OnOrderUpdate for entry order but how I can monitor execution of stop orders?

    My goal is to always know the status of each position independently.

    Also, Do I understand correctly that if this position got closed with ExitLong("E1") all stop and profit orders fro E1 got canceled automatically.

    Then if I want to reuse the same name e.g. rung again EnterLong(100,"E1"), and place new stop loss order the software will know that new stop loss order refers to the last EnterLong rather than to the previous that got closed.


    Thank you.

    #2
    Hello sergeysamsonov,

    If you are using multiple stops that you would like to monitor, then you should move away from the Set statements and use instead ExitLongStop(), ExitShortStop.

    You can then expose information regarding each order as long as you have created an IOrder object for this.

    Yes, if you submit a market order ExitLong(E1), then any stops/ targets associated with this order are canceled.

    If you are using Set statements, then you can tie these together with the fromEntrySignal parameter SetStopLoss(string fromEntrySignal, CalculationMode mode,double value,bool simulated)

    If you're using the set method that doesn't use a specific signal, it's still applied to new entries.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      monitoring execution

      Ok, then if I submit multiple ExitLongStop() orders for the same position (e.g. E1), do I have to cancel previous orders or they get canceled automatically once the closest order gets triggered?

      Also is it better to place stop/ target orders from OnOrderUpdate when entry order gets Filled, or it is better to do it from OnBarUpdate at the same time as EnterLong() order is placed?

      Also, If I place market order and I have enough money, is there a chance that order will not be filled? In other words do I have to monitor Cancelled and Rejected states?

      Comment


        #4
        You can submit multiple Exit statements for the same position, but only one actual order is submitted, matching the quantity of E1.

        If these are orders you would like active immediately upon entry execution, then submitting in OnOrderUpdate() should work for you. You wouldn't notice too much of a difference submitting in OnBarUpdate() but that extra level of control is there for you.

        There can be cases where your order is not filled. There are default actions taken when your order is rejected (orders canceled, position closed)

        See here for real time error handling options and default actions when your order state is rejected:
        Last edited by NinjaTrader_RyanM1; 08-24-2010, 05:10 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          limit orders

          Thank you for previous replies.

          And what about limit orders, If I submit EnterLongLimit(E1) and then before it gets filled or rejected I send another EnterLongLimit(E1) with lower price, do I have to worry about canceling the first limit order or it is automatically replaced by a new order because it has the same identifier "E1"?

          Is it the same for ExitLongLimit(E1)?

          Comment


            #6
            entryOrder == null

            I have also noticed in this example



            that before placing "entryOrder = EnterLong()" you check for "entryOrder == null" in the if statement, why do you do this? (this question comes from an experienced programmer, I am trying to understand the logic behind it)

            Do I have to set entryOrder = null, after its execution or this happens automatically, is it a reliable way to check if this order has not been submitted before?

            Comment


              #7
              If you resubmit Limit orders with the same order name, it would just update them, same as for stop orders.

              You can't access an emtpy object, we have tip concerning the object oriented programming issue - http://www.ninjatrader.com/support/f...ead.php?t=4226

              Correct you would nullify the IOrder objectd as needed in OnExecution() and OnOrderUpdate().

              Comment


                #8
                position id

                Hello

                A few more questions

                1. Please confirm that I understand correctly that when OnPositionUpdate is called there is no way to check what signal triggered it?

                Example

                EnterLong("Enter1")

                OnPositionUpdate
                {
                if Signal == Enter1 then do something
                }

                2.OnExecution()

                Is there a way to check if it was a partial fill rather then complete fill?

                3. If it was a partial fill for EnterLong("Enter1") and I send after partial fill ExitLong("Enter1") order, does the unfilled part of the EnterLong("Enter1") order gets cancelled?

                4. If one of orders gets rejected due to error (stop/target/exit) does the entire position with the same name gets closed. In order words EnterLong was successful but ExitLongStop got rejected.

                Comment


                  #9
                  Correct, as this is your overall strategy position then, you can check an individual signal via the IOrder objects in OnOrderUpdate() for example - http://www.ninjatrader-support.com/H...V6/IOrder.html

                  Yes, you can check for the orderstates directly in the OnExecution() via the IOrder objects - http://www.ninjatrader.com/support/f...ead.php?t=7499

                  The cancellation request for the rest would be issued, but that's no guaranteee as it could execute as we say 'in flight' - http://www.ninjatrader-support.com/H...njaTrader.html

                  If the order gets rejected, the strategy is terminated (with default RealtimeErrorHandling at work) and it will attempt to close the position.

                  Comment


                    #10
                    only one order gets filled

                    Thank you, here is another question, I am almost finished

                    From OnBarUpdate I place three orders simultaneously:

                    if (CurrentBar == 100) // for example
                    {
                    for (int i=0; i<3; i++)
                    {
                    Print ("Placing EnterLong order: " + i.ToString());
                    EnterLong(i.ToString);
                    }

                    Then I monitor execution from OnOrderUpdate

                    for (int i=0; i<3;i++)
                    {
                    if (long_enter[i] != null && long_enter[i].Token == order.Token && order.OrderState == OrderState.Filled)
                    {
                    Print ("EnterLong order filled: " + i.ToString());
                    }
                    }

                    What happens is that only first order gets filled. I get only first notification like this:

                    Placing EnterLong order: 0
                    Placing EnterLong order: 1
                    Placing EnterLong order: 2
                    EnterLong order filled: 0

                    Now, if in the first loop I change i=1;i<2 I get
                    Placing EnterLong order: 1
                    Placing EnterLong order: 2
                    EnterLong order filled: 1

                    So it seems that software can not handle when multiple similar orders a sent simultaneously. Any suggestions?

                    Comment


                      #11
                      What EntriesPerDirection setting are you using here?

                      Comment


                        #12
                        thank you this fixed it

                        Comment


                          #13
                          OnExecution is not called

                          Hello

                          Is there a reason why OnExecution sometimes is not called when EnterLong order is submitted.

                          I have the following settings set

                          EntriesPerDirection = 6;
                          EntryHandling = EntryHandling.UniqueEntries;

                          And I have only 3 long order so far.

                          It seems that I miss some entries when EntterLong orders are submitted but not executed.

                          Thank you.

                          Comment


                            #14
                            sergey,

                            OnExecution() receives events only when there is an execution. If your order has not executed yet then there would be no event. If you want events from just order submission you can use OnOrderUpdate().
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Thank you for all your support.

                              A few more questions:

                              1. If I use CalculateOnBarClose = false; option, in real time do I get this statement CrossAbove(SMA(Close,16), SMA(Close,29), 1) == true;
                              correct more than once, in order words until the current bar gets complete (it may have more than one tick?) is this correct?

                              2. If I place limit order that needs to be canceled after a few ticks what is the best way to do this, how can I count ticks since the order was submitted. I can also use time units (e.g. two minutes) if it is possible.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              633 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              364 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
                              567 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              568 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X