Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTOrderStatus question

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

    NTOrderStatus question

    In an earlier thread touching on a similar topic, it was said:

    "You can not retrieve order id values of ATM strategy generated stop/target orders."

    Does this also mean that the status of ATM strategy generated stops and targets cannot be acquired through the ATI?

    I am trying to determine in a 2 stop 2 target strategy, whether a change of position is due to the target being hit, or the stop being triggered.

    Any suggestions on how to do this?

    Thanks.

    #2
    Correct. However, NT 6.5 will provide a way to
    a) get the order IDs of stop/target orders per ATM strategy
    b) then call NTOrderStatus for these order IDs

    NT 6.5 first beta will be available in ~ 2 weeks.

    Comment


      #3
      Thanks Dierk. I will look forward to v6.5.

      Comment


        #4
        NTOrderStatus not returning status of stop order

        I am running on 6.5, and I am still not getting back the status of a stop order. I am assigning my stop order its own ID, and then launching a call to NTOrderStatus("my_stop_order_id"). This same call works for my_order_id.

        Is there a work around? I just want to make sure that my stop is set.

        Thanks again,

        Thomas

        Comment


          #5
          Use NTStopOrders(string strategyId) to see if you are actually using the right orderId string for the stop.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            That doesn't work . . .

            Josh,

            This is what I am doing and neither of the calls are returning with data for checking the stop order status:

            function main()
            {

            order_id="1000";

            if (isLastBarOnChart() && NTConnected(1))
            {
            if (!orderPlaced)
            {
            if (NTBuyMarket("order_id", 1) == 0) // buy 1 unit at market, assign order id (optionally)
            orderPlaced = true;
            stop_order_id=order_id+1;
            NTSellStop(stop_order_id, contract_num, buy_stop_level);

            }
            else
            {
            // print some information on the current position and order
            debugPrint("Position size: " + NTMarketPosition("") + "\r\n");
            debugPrint("AvgEntryPrice: " + NTAvgEntryPrice("") + "\r\n");
            debugPrint("OrderStatus: " + NTOrderStatus("order_id") + "\r\n");
            debugPrint("StopOrderStatus_1: " + NTOrderStatus("stop_order_id") + "\r\n");
            debugPrint("StopOrderStatus_2: " + NTStopOrders("") + "\r\n");
            debugPrint("Filled #: " + NTFilled("order_id") + "\r\n");
            debugPrint("AvgFillPrice: " + NTAvgFillPrice("order_id") + "\r\n");
            debugPrint("RealizedPnL: " + NTRealizedPnL("") + "\r\n");
            }
            }
            }

            I see the order accepted in NT, I just can not get the call returned to my EFS.

            Let me know what I am missing . . .

            T

            Comment


              #7
              NTOrderStatus("stop_order_id") is wrong. Your stop_order_id is a string variable. You don't need to use quotes. NTOrderStatus(stop_order_id)

              Also, NTStopOrders("") <- you are missing the strategyId.

              To get a list of the strategyIds you need to use NTStrategies(string account). Please see this article: http://www.ninjatrader-support.com/H...unctions1.html

              NTStrategies() gets you strategyIds. NTStopOrders() gets you orderIds. NTOrderStatus() gets you the order status.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                OK, I will try . . .

                Josh,

                I understand the differences between using quotes and not, I was just following the examples that are provided with NT.

                Also, if I do not need to use quotes, I just want to let you know the function works perfectly well for:

                debugPrint("OrderStatus: " + NTOrderStatus("order_id") + "\r\n");

                In my case, I am not using the strategy variable, nor am I using account, so in essence:

                1. I need to get the default strategy
                2. Pass that in with NTOrderStatus to get the stop order status?

                If that is the case, why do I not have to do that with the regular order? Do you think you could just post an example in the same form of NTSample.efs that beginners could follow?

                Regards,

                Thomas.

                Comment


                  #9
                  Thomas,

                  The difference between "order_Id" was that that was never a variable. This is why you needed the quotes. When you did NTBuyMarket("order_id", 1) you used quotes so when you call the NTOrderStatus you use quotes also to match up the same order_Id name.

                  Because you now use NTSellStop(stop_order_id, contract_num, buy_stop_level) with stop_order_id being a string variable as opposed to simply being a string your stop's orderId is NOT "stop_order_id". It is whatever is contained inside that string.

                  So simply, to get NTOrderStatus() of your stop orders you need to type out the actual string of the stop order. If you did NTOrderStatus(stop_order_id) that will work to get your last stop order, but because you did this earlier stop_order_id=order_id+1; you will now need to decrement it to get your previous stop orders.

                  In fact, I think you may need to first declare your stop_order_id.
                  Code:
                  var stop_order_id = "1000";
                  stop_order_id=order_id+1 <- I don't know what that line will do. When operating on strings the + just concatenates, it doesn't do math. You may be getting strings that look like 10001 or it may be confused by the 1 because thats not another string. stop_order_id = stop_order_id + "1" would work better in getting you unique ids. This way you get strings that look like 1000, 10001, 100011, 1000111.
                  Last edited by NinjaTrader_JoshP; 09-19-2008, 02:45 PM.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Think I got it . . .

                    Josh,

                    I think I am seeing what you are saying.

                    Change:

                    if (NTBuyMarket("order_id", 1) == 0)

                    to

                    if (NTBuyMarket(order_id, 1) == 0)

                    And all should work well. I was getting confused between the vars I was passing in and the quotes. I will let you know how my testing goes on Monday. Just let me know if you see any errors below:

                    function main() {

                    order_id=1000;

                    if (isLastBarOnChart() && NTConnected(1)) {
                    if (!orderPlaced) {
                    if (NTBuyMarket(order_id, 1) == 0) // buy 1 unit at market, assign order id (optionally)
                    orderPlaced = true;
                    stop_order_id=order_id+1;
                    stop_orderPlaced = true;
                    NTSellStop(stop_order_id, contract_num, buy_stop_level);
                    }
                    else {
                    // print some information on the current position and order
                    debugPrint("Position size: " + NTMarketPosition("") + "\r\n");
                    debugPrint("AvgEntryPrice: " + NTAvgEntryPrice("") + "\r\n");
                    debugPrint("OrderStatus: " + NTOrderStatus(order_id) + "\r\n");
                    debugPrint("StopOrderStatus: " + NTOrderStatus(stop_order_id) + "\r\n");
                    debugPrint("Filled #: " + NTFilled(order_id) + "\r\n");
                    debugPrint("AvgFillPrice: " + NTAvgFillPrice(order_id) + "\r\n");
                    debugPrint("RealizedPnL: " + NTRealizedPnL("") + "\r\n");
                    }
                    }
                    }

                    I assume even if my order_id's are INT in efs, they are treated as strings by the calls.

                    Regards,

                    Thomas.

                    Comment


                      #11
                      If your assumption is right (I do not know exactly) then you should be fine.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks, got it working . . .

                        Josh,

                        Thanks for your help, got it working. I have just one question that is confusing between your documentation and what I am seeing in testing.

                        Once the stop order is sent, it shows in NT as "Accepted" (Order confirmation received by broker). Would this status ever change to "Working" (Order confirmation received by exchange)?

                        I just need to know which states to code for.

                        Thanks again,

                        Thomas.

                        Comment


                          #13
                          Which broker are you using?
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            Interactive Brokers

                            IB is the broker, but I think the other state is for when you place a limit order, and not stop limit.

                            T

                            Comment


                              #15
                              With IB, Accepted means that its on their servers, usually stop orders. I believe you will get a working state once the order is triggered.
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by helpwanted, Today, 03:06 AM
                              1 response
                              11 views
                              0 likes
                              Last Post sarafuenonly123  
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              242 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              387 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Working...
                              X