Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATI Interface Orders Inconsistencies

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

    ATI Interface Orders Inconsistencies

    I have written an external application that loads the NT DLL interface to execute orders to NT.

    Currently, I have create a Long Market Order that invokes an ATM strategy. This ATM strategy has a set profit target and stop loss. The code is as follows.

    Code:
    NTClient.Command("PLACE", "Sim101", "$EURUSD", "BUY", 1, "MARKET", 0, 0, "GTC", "od1", "", "testATM", "");
    When the target is reached, the ATM strategy works 100%, exiting the position and canceling the other stop order. Concurrently, when the stop loss is reached, the ATM strategy works 100%, exiting the position and canceling the other target order.

    My problem is, when I manually exit the position via my external application. In my application I send a ClosePosition command for the currency pair I have a position for. The code is as follows:

    Code:
    NTClient.Command("CLOSEPOSITION", "Sim101", "$EURUSD", "", 1, "MARKET", 0, 0, "GTC", "od1", "", "", "");
    Sometimes this command will Cancel both my target and stop orders generated by the ATM strategy, and close my position. Other times it will cancel my target, modify my stop order, and leave my position open. I believe this is in error.

    One way I was able to alleviate this error is by first canceling the target / stop with a CANCELALLORDERS command, Sleeping for 1.25 seconds, then commanding a CLOSEPOSITION command. The following code:

    Code:
    NTClient.Command("CANCELALLORDERS", "Sim101", "$EURUSD", "", 0, "MARKET", 0, 0, "GTC", "od1", "", "", "");
    Sleep(1250);
    NTClient.Command("CLOSEPOSITION", "Sim101", "$EURUSD", "", 0, "MARKET", 0, 0, "GTC", "od1", "", "", "");
    If I change my Sleep to 250, this solution doesn't work, and my position remains open with a the target canceled by NT, and the stop order moved.

    If you need anything from me let me know.

    Thanks guys!
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    #2
    Hi mrlogik,

    Have you tried using CLOSESTRATEGY? Then use OrderStatus to see if they have been cancelled?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I will try that and let you know.

      Thanks
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Hey Josh.

        Would the command to cancel the Place order I posted originally be...

        Code:
        NTClient.Command("CLOSESTRATEGY", "", "", "", 0, "", 0, 0, "", "", "", "", "testATM");
        Thanks
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          When you did the PLACE one, you would have needed to use the optional strategyID. Then you can CLOSESTRATEGY via the strategyID.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Hey Josh.

            yes, that worked. Thank you.

            I am also trying to make a button that allows me to cancel the target order placed by my "testATM" strategy. This is how I'm doing it.

            Placing the order as such.
            Code:
            NTClient.Command("PLACE", "Sim101", "$EURUSD", "BUY", 1, "MARKET", 0, 0, "GTC", "od1", "", "testATM", "eNTDLL");
            And to Cancel
            Code:
            NTClient.Command("CANCEL", "Sim101", "$EURUSD", "", 0, "MARKET", 0, 0, "GTC", "od1", "Target1", "", "eNTDLL");
            This is canceling both my Stop1 and my Target1. Is this the proper behavior?

            Thanks again!
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Hmm. Please try it with only the orderID and strategyID filled out.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                No Luck.

                I have attached a .Zip of my .csv log file.

                You can see the entry, target1 / stop1, the command to cancel target1.
                They both seem to cancel.

                The order after was just for me to close out the position since I lost my target / stop; we can ignore that.

                Thanks Josh.

                Much Appreciated.
                Attached Files
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  Hmm. I will have to get back to you on this.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Josh.
                    mrlogik
                    NinjaTrader Ecosystem Vendor - Purelogik Trading

                    Comment


                      #11
                      mrlogik,

                      Are these targets and stops from an ATM strategy? If so are they OCO paired? If so then they will both cancel when you cancel one of them. If this is not what you hoped for you need to disable OCO.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Hey Josh,

                        Thanks. That makes sense, and did it.

                        much appreciated.
                        mrlogik
                        NinjaTrader Ecosystem Vendor - Purelogik Trading

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by DJ888, 04-16-2024, 06:09 PM
                        4 responses
                        12 views
                        0 likes
                        Last Post DJ888
                        by DJ888
                         
                        Started by terofs, Today, 04:18 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post terofs
                        by terofs
                         
                        Started by nandhumca, Today, 03:41 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post nandhumca  
                        Started by The_Sec, Today, 03:37 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post The_Sec
                        by The_Sec
                         
                        Started by GwFutures1988, Today, 02:48 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Working...
                        X