Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving a Ninja ATM stop from within a Tradestation strategy

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

    Moving a Ninja ATM stop from within a Tradestation strategy

    I am trying to move a Ninja ATM stop from within a Tradestation strategy using your ATI.

    These are the steps I have taken;
    1) Manually enter a trade in Ninja with a set ATM stopmarket order. The ATM strategy is named "ABC".
    2) Within a TradeStation strategy I check for an open position in Ninja for the current symbol using the command "NumToStr(NTMarketPosition(""), 0))", and also check for the average entry price using the command NumToStr(NTAvgEntryPrice(""), 2)).

    I would now like to move the stopmarket order created in the Ninja ATM strategy named ”ABC” to a price I calculate in the strategy, I have checked your online documentation but am having difficulty getting a command that will do this successfully.


    i.e.
    Symbol ESH08
    NTMarketPosition -2
    NTAvgEntryPrice 1445.25
    Stop (ABC) 1447.00

    What is the best way to move the stop from 1447.00 to my calculated price i.e. 1449 using your ATI? I tried the following command (among others) which I can’t get to work;

    NTCommand("Place", "", "", “”, "-2", "Stop", "", "1449", "GTC", "", "MyStop", "", "ABC")

    Your help is appreciated.

    Thanks


    Kevin.

    #2
    Unfortunately, you can not manage orders generated from a manually entered ATM strategy. You can however, for an ATM strategy generated through the Automated Trading Interface.
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks for your prompt reply Ray, what do you think is the best way to do this?

      Is the following a logical way to do this or can you recommend something better?

      1) Place the order manually in Ninja with no stop.
      2) Have a TradeStation chart with the stop strategy running which checks every tick to see if Ninja has an open position for this symbol, if it does place an order with an orderID using the NTBuyStop or NTSellStop commands.
      3) Use the NTCommand "place" to move the known orderID as required?

      Can you please point me towards some useful sample code if possible?

      Thnaks again.


      Kevin.

      Comment


        #4
        Yes, that for sure would work. Unfortunately, we do not have any EL reference code apart from the NTSampleStrategy that comes with the our ELD of functions.
        RayNinjaTrader Customer Service

        Comment


          #5
          Ray, I'm new to ninjaTrader, If I place an NTBuyStop with an OrderID via the ATI will the stop appear in the Dome and will I be able to move it manually at first and then let the strategy manage the stop by referencing the OrderID?

          Thanks

          Kevin.

          Comment


            #6
            Yes to all questions.
            RayNinjaTrader Customer Service

            Comment


              #7
              Thanks for your help today Ray, I have one last question before I quit for the weekend. Is it possible to get the Last price traded from Ninja using the ATI? If so can you point me towards the command I would need to use?

              Have a great weekend and thanks again for all your help.

              Kevin.

              Comment


                #8
                int SubscribeMarketData(string instrument)
                Starts a market data stream for the specific instrument. Call the MarketData() function to retrieve prices. Make sure you call the UnSubscribeMarketData() function to close the data stream. A return value of 0 indicates success and -1 indicates an error.

                int UnSubscribeMarketData(string instrument)
                Stops a market data stream for the specific instrument. A return value of 0 indicates success and -1 indicates an error.

                double MarketData(string instrument, int type)
                Gets the most recent price for the specified instrument and data type. 0 = last, 1 = bid, 2 = ask. You must first call the SubscribeMarketData() function prior to calling this function.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  I'm trying to use the ATI to monitor an account/symbol for an open position and then add a stop with Orderid=MYSTOP, since this will execute in TS on a tick basis and not on the close of the bar I will need to check that there are no valid orders in existence with the orderid=MYSTOP beforeI place a new stop.

                  What is the best way to do this?

                  Comment


                    #10
                    I would check if order exists by:

                    string Orders(string account)
                    Gets a string of order Ids of all orders that were initiated through the ATI if an account separated by '|'.

                    Comment


                      #11

                      May also help.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        NTCommand "Place" error

                        Ray/Josh, I'm having some problems with the NTCommand "place" from within my tradestation strategy. I'm using the @es continuous contract, Ninja sim account “99999”.

                        According to your help guide the command should be constructed as follows;

                        value1= NTCommand("Command", "Account", "Instrument", "Action", “QTY”, “Order Type”, ” LimitPrice”, ”Stop Price”, “TIF”, “OCO ID”, “ORDER ID”, “Strategy”, “Strategy ID” )

                        It seems that the parameter “Instrument” is always set to the Tradestation Symbol value i.e. “@ES”and not the Ninja equivalent of "ES 03-08" and if “Instrument” is specified the parameter is read as the “ACTION” input i.e.

                        once value1= NTCommand("PLACE", "", "SELL", 1, "STOP", 0, 6 , "DAY", "", "MyOrderId", "", "");

                        generates the following Ninja log entry;

                        16/01/2008 15:24

                        ATI
                        AT
                        'PLACE;;@ES;SELL;1;STOP;0;6;DAY;;MyOrderId;;' processing


                        once value1= NTCommand("PLACE", "99999", "SELL", 1, "STOP", 0, 6 , "DAY", "", "MyOrderId", "", "");

                        generates the following Ninja log entry;

                        16/01/2008 15:26

                        ATI
                        AT
                        'PLACE;99999;@ES;SELL;1;STOP;0;6;DAY;;MyOrderId;;' processing

                        once value1= NTCommand("PLACE", "99999", "", "SELL", 1, "STOP", 0, 6 , "DAY", "", "MyOrderId", "", "");
                        does not verify in Tradestation, the error is that for “SELL” – a Numerical expression is expected here.

                        The same error is generated if the contract is specified i.e.
                        once value1= NTCommand("PLACE", "99999", "ES 03-08", "SELL", 1, "STOP", 0, 6 , "DAY", "", "MyOrderId", "", "");

                        Please advise as I would like to specify both an account and a symbol.

                        Thanks

                        Kevin.
                        Last edited by strad739; 01-16-2008, 09:40 AM.

                        Comment


                          #13
                          According the help guide the comment should be

                          int 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)
                          Function for submitting, cancelling and changing orders, positions and strategies. Refer to the Commands and Valid Parameters section for detailed information. A return value of 0 indicates success and -1 indicates an error. The Log tab will list context sensitive error information.


                          Comment


                            #14
                            Dierk, please read my email.

                            Comment


                              #15
                              Did you send me mail? Have not got anything yet.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by f.saeidi, Today, 11:02 AM
                              1 response
                              2 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by geotrades1, Today, 10:02 AM
                              4 responses
                              12 views
                              0 likes
                              Last Post geotrades1  
                              Started by rajendrasubedi2023, Today, 09:50 AM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by lorem, Today, 09:18 AM
                              2 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by geddyisodin, Today, 05:20 AM
                              4 responses
                              30 views
                              0 likes
                              Last Post geddyisodin  
                              Working...
                              X