Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem With ATI Interface and Using NTCommand

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

    Problem With ATI Interface and Using NTCommand

    Hi,
    I am working on some custom Easy language scripts with the ATI interface to Ninjatrader. In using the NTCommand listed below I ran into a issue. It seems that if I send a Market or Limit order with the NTCommand my stop is ignored. In the log I see the order come in as a market order, and the stop I passed in shows up in the stop field, but when my Strategy receives the order it uses the stop setup in the strategy option under the strategy box not the stop I passed in. Is there a way around this ? Any comments or help would be appreciated.
    Thanks


    SendCommandSuccess = NTCommand("PLACE","AcctName","SELL",1,"MARKET",0,( localmax + .0002),"GTC","",orderidstring,"StradegyName","");


    #2
    imported post

    Widgetman,

    Not sure I follow exactly. To be sure:

    - Does your initial entry order also call a NT strategy template which then auto submits your stop and targets?

    - If yes, once the stop/target is in place, what further action do you want your EL strategy to do

    Ray
    RayNinjaTrader Customer Service

    Comment


      #3
      imported post

      Hi Ray,
      Thanks for the quick response. The issue I am having is I want to pass in the stop which is represented below. In the NTCommand below I am sending a sell market order with no limit price, and a stop of (localmax + .0002). This would vary on a stop for the euro from .0005 to .0008 depending on some other variables in my equations. The issue I have is when the order comes in I see the sell market order with the correct stop that I sent in the log. After it fills I then see a Buylimit order pop up with a limit and stop of what I assume is set by the strategy template. It seems to overide my ATI stop. In the Ninja strategy I manually set the target to 8 pips, and my stop to 1 pip since I can not set it to 0. I also use the custom stop strategy option and set step 1 to values of 6 1 6. I have played with those numbers in different ways and it did not seem to matter. My question is how do I tell the strategy I created to use the stop I passed in with the NTCommand via the ATI instead of the hard stop I must enter in the strategy template.

      Comment


        #4
        imported post

        I see.

        For clarification:

        - Order is placed which references a strategy
        - Order is filled strategy submits stops/targets
        - You then want to modify the price of the automatically submitted stop order to a new price

        If that is correct, you need to call the NTCommand()

        Instead of "PLACE" pass in "CHANGE", pass in "STOP1" if you are modifying the 1st stop order, pass in a new stop price and pass in the unique strategy id that you used when you create the initial entry order.

        Ray
        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          Hi Ray,
          Listed below is what I think you mean. If I am passing in a strategy name and I also get a unique orderID before I send the order why do I still need a unique strategy id ?
          Can that strategy id be anything and how does that correlate to the name of the actual strategy I created in the DOM ?
          Thanks

          NTCommand(string command, string account, string action, int quantity, string orderType, double limitPrice, double stopPrice, string timeInForce, string oco, string orderId, string strategy, string strategyId)



          // Send This Command To Place Order
          SendCommandSuccess = NTCommand("PLACE","AcctID","SELL",1,"MARKET","","" ,"GTC","",orderidstring,"StrategyName","StrategyID ");

          // Send This Command To Change Stop Of STrategy ???
          SendCommandSuccess = NTCommand("PLACE","AcctID","CHANGE","","","",(loca lmax + .0002),"GTC","",orderidstring,"StrategyName","Stra tegyID");

          Comment


            #6
            imported post

            Should look something like the code below. You need a unique strategy id since NT needs to know which strategie's stop1 order to change.



            // Send This Command To Change Stop Of STrategy
            SendCommandSuccess = NTCommand("CHANGE","AcctID","","","","",(localmax + .0002),"GTC","","STOP1","","YourStrategyId");
            RayNinjaTrader Customer Service

            Comment


              #7
              imported post

              Actually,

              I believe it should look like this. I have excluded order qty value since I believe it is ignored if empty string.

              SendCommandSuccess = NTCommand("CHANGE","","","","","0",(localmax + .0002),"","","STOP1","","YourStrategyId");
              RayNinjaTrader Customer Service

              Comment


                #8
                imported post

                Hi Ray,

                Thanks for the help. I tried what you said and passed in a strategy ID. Listed below is what I tried. What I saw happen is I got a message back in the log stating 'No Such order'. I also noted that even though I got a new orderid before I sent the market order Once it filled the order id was different. My question is how do I get back the order ID that actually filled from the market order sent. It appears that the two are different.

                orderidstring = NTNewOrderId();

                SendCommandSuccess=NTCommand("PLACE","ACCTID","SELL",1,"MARKET",0,(localmax+.0002),"GTC","","","STRATEGY","STRATEGY");

                SendCommandSuccess=NTCommand("CHANGE","ACCTID","",0,"",0,(localmax+.0002),"GTC","","STOP1","STRATEGY","STRATEGYID");


                Comment


                  #9
                  imported post

                  Looks like you are not generating a unique strategy id.

                  strategyIdString = "SomeRandomUniqueValue"

                  ndCommandSuccess=NTCommand("PLACE","ACCTID","SELL",1,"MARKET",0,(localmax+.0002),"GTC","","","STRATEGY",strategyIdString);

                  SendCommandSuccess=NTCommand("CHANGE","ACCTID","",0,"",0,(localmax+.0002),"GTC","","STOP1","",strategyIdString);
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    imported post

                    Hi Ray,

                    I did generate a unique strategy ID called Monky69

                    I set the strategy ID in both NTCommand strings to "Monky69" which is the last parameter of 12 in the NTCommand String. It came back and told me no such order. Please post me a NTCommand string that you thinks works so I can try it if you have time.



                    -Thanks


                    Comment


                      #11
                      imported post

                      Widgetman,

                      You can use the Automated Trading OIF builder via Tools menu. This generates a string representation of what the Command function should look like.

                      Ray
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        imported post

                        Ray,

                        That was a excellent idea. I built a sell command in the OIF builder and listed below is what it generated. My question now is your help file online shows 12 parameters in the NTCommand Function. The OIF string listed below shows 13. Which is correct ?



                        PLACE;SIM101;6E 12-06;SELL;1;MARKET;0;0;DAY;OCO1;IDName;Mann;Monky69

                        Comment


                          #13
                          imported post

                          12 is correct. OIF requires the insrument string. The NTCommand function itself is a wrapper around the DLL function Command which is actually built from 13 parameters. The wrapper just takes care of the instrument parameter for you.

                          Ray
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            imported post

                            Hi Ray,

                            Listed below is a log of a order that fired earlier from a cuctom system I am developing. I tried the things you suggested and found that no matter what I call the strategy ID variable the order to change a stop after I get a filled market order is rejected. I was wondering if there was any scripts available in easy language that I could look at. I am sure it is something I may be doing wrong, but I want to eliminate the possibility that the ATI interface may not work quite right with a Easy Language type interface. Any suggestions or help you could privide would be appreciated. I currently do development for a few customers of yours and I want to continue to support them in the future.

                            -Thanks

                            // Here Is The Command Lines I Am Sending In Easy Language

                            SendCommandSuccess
                            =NTCommand("PLACE","ACCTID","SELL",1,"MARKET",0,(localmax+.0002),"GTC","","Order1","Strategy","StrategyID");

                            OrderStatus=NTOrders("AcctID");

                            print("Order Status Is ",OrderStatus:0:4);

                            SendCommandSuccess=NTCommand("CHANGE","","",0,"",0,(localmax+.0002),"","","Order1","Strategy","StrategyID");





                            11/22/2006 10:37StrategyCancelling any remaining strategy orders
                            11/22/2006 10:37ExecutionExecution='6E 12-06/0001f4e5.44231579.01.01' Instrument='6E 12-06' Account='ACCTID' Exchange=Globex Price=1.2959 Quantity=1 Market position=Short Operation=Insert Order='268711972' Time='11/22/2006 10:37:30 AM'
                            11/22/2006 10:37OrderOrder='268711972/ACCTID' Name='Stop1' New State=Filled Instrument='6E 12-06' Action=Sell Limit price=1.2939 Stop price=1.2959 Quantity=1 Type=StopLimit Filled=1 Fill price=1.2959 Error=NoError Native error=''
                            11/22/2006 10:37OrderOrder='268711972/ACCTID' Name='Stop1' New State=Working Instrument='6E 12-06' Action=Sell Limit price=1.2939 Stop price=1.2959 Quantity=1 Type=StopLimit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:37OrderOrder='268711973/ACCTID' Name='Target1' New State=PendingCancel Instrument='6E 12-06' Action=Sell Limit price=1.2971 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='268711973/ACCTID' Name='Target1' New State=Working Instrument='6E 12-06' Action=Sell Limit price=1.2971 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='268711973/ACCTID' Name='Target1' New State=Accepted Instrument='6E 12-06' Action=Sell Limit price=1.2971 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='268711972/ACCTID' Name='Stop1' New State=Accepted Instrument='6E 12-06' Action=Sell Limit price=1.2939 Stop price=1.2959 Quantity=1 Type=StopLimit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='5dc96e54f510485087e2a23587ad3b5e/ACCTID' Name='Target1' New State=PendingSubmit Instrument='6E 12-06' Action=Sell Limit price=1.2971 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='fd70704700e14dc8960f046b4409a159/ACCTID' Name='Stop1' New State=PendingSubmit Instrument='6E 12-06' Action=Sell Limit price=1.2939 Stop price=1.2959 Quantity=1 Type=StopLimit Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36PositionInstrument='6E 12-06' Account='ACCTID' Avg price=1.2963228 Quantity=1 Market position=Long Operation=Insert Currency=UsDollar
                            11/22/2006 10:36ExecutionExecution='6E 12-06/0001f4e5.4423152a.01.01' Instrument='6E 12-06' Account='ACCTID' Exchange=Globex Price=1.2963 Quantity=1 Market position=Long Operation=Insert Order='268711971' Time='11/22/2006 10:36:22 AM'
                            11/22/2006 10:36OrderOrder='268711971/ACCTID' Name='Entry' New State=Filled Instrument='6E 12-06' Action=Buy Limit price=0 Stop price=1.2957 Quantity=1 Type=Market Filled=1 Fill price=1.2963 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='268711971/ACCTID' Name='Entry' New State=Working Instrument='6E 12-06' Action=Buy Limit price=0 Stop price=1.2957 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderOrder='268711971/ACCTID' Name='Entry' New State=Accepted Instrument='6E 12-06' Action=Buy Limit price=0 Stop price=1.2957 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36ATIOIF 'CHANGE;;6EZ6;;0;;0;1.2957;;;Order1;StrategyName;S trategyID' invalid order ID/Name 'Order1'
                            11/22/2006 10:36ATIAT 'CHANGE;;6EZ6;;0;;0;1.2957;;;Order1;StrategyName;S trategyID' processing
                            11/22/2006 10:36OrderOrder='2d8d02814066430091795881d4eac66b/ACCTID' Name='Entry' New State=PendingSubmit Instrument='6E 12-06' Action=Buy Limit price=0 Stop price=1.2957 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
                            11/22/2006 10:36OrderSubmitting order with strategy

                            Comment


                              #15
                              imported post

                              Your are submitting too fast.

                              Do this:

                              Submit the Place command. Wait a minute (to be safe), the strategy will have submitted the stop and targets.

                              Then issue a change to the STOP1.

                              SendCommandSuccess=NTCommand("CHANGE","","",0,"",0,(localmax+.0002),"","","STOP1","","StrategyID");
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              61 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              39 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              21 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              23 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              51 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X