• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Placing short orders through NinjaTrader.Client assembly, raises error for stop loss

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

    Placing short orders through NinjaTrader.Client assembly, raises error for stop loss

    Hi, I'm trying to place orders through de NinjaTRader.Client dll and I have encountered the problem that, if I place the order to sell a future and set the stop above the current price, ninjatrader raises an error indicating that stops above the current price are not supported..???? Is that possible? I'm using the Sim101 account.... Thanks in advance for any tips...
    Console.WriteLine(c.Command("PLACE", "Sim101", "ES 09-20", "SELL", 1, "STOPMARKET", 0, 3155, "DAY", "12", "12", "", "").ToString());

    #2
    Hello abner77,

    A buy stop order must be above the ask, a sell stop order must be below the bid.

    This is also true if you pick up the phone and call your broker.


    If you are wanting to place a sell order above the bid, you would need to use a limit order or a market if touched order.
    Last edited by NinjaTrader_ChelseaB; 07-09-2020, 09:35 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello abner77,

      A buy stop order must be above the ask a sell stop order must be below the bid.

      This is also true if you pick up the phone and call your broker.


      If you are wanting to place a sell order above the bid, you would need to use a limit order or a market if touched order.
      Sorry, I don't understand, if I want to aply an order with stop loss, let's say, current price is at 3150 and I want to go short (sell), and protect the maximum loss with the stop loss set at 3157, that canno't be below the bid, cause the bid is going to be, much lover than that.

      Comment


        #4
        Hello abner77,

        When in a short position a stop market order used as a stop loss would be a buy order and not a sell order.

        A buy order is used to exit a short position.

        A buy stop market must be above the current ask price.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello abner77,

          When in a short position a stop market order used as a stop loss would be a buy order and not a sell order.

          A buy order is used to exit a short position.

          A buy stop market must be above the current ask price.
          How would then I place an order with a stop loss from the API. It was my understanding that in order to place an Stoploss order it had to be in the same command as place, because the command CHANGE returns an error saying that the MARKET order that i place before (cause I've tried allso that, placing a market order and then try to change it to set an stoploss), is already on the market and cannot be changed. If I understand correctly, what you are saying is that in order to do this kind of protection I must place another operation in the opposite way with a limit price?

          What does STOPMARKET then do? I have upload an image with the ninjatrader.Client help that it's relevant to this question...

          Comment


            #6
            Hello abner77,

            Below is a link to the help guide with the available command parameters.
            https://ninjatrader.com/support/help...ableToCommands

            As well as a link the help guide with a list of available functions.
            https://ninjatrader.com/support/help.../functions.htm

            PLACE would be used to submit an order.

            As an example:

            SubscribeMarketData();
            double currentAskPrice = MarketData("ES 09-20", 2);
            Command("PLACE", "Sim101", "ES 09-20", "BUY", 1, "STOPMARKET", 0, (currentAskPrice + 1),
            "DAY", string.Empty, NewOrderId(), string.Empty, string.Empty)
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello abner77,

              Below is a link to the help guide with the available command parameters.
              https://ninjatrader.com/support/help...ableToCommands

              As well as a link the help guide with a list of available functions.
              https://ninjatrader.com/support/help.../functions.htm

              PLACE would be used to submit an order.

              As an example:

              SubscribeMarketData();
              double currentAskPrice = MarketData("ES 09-20", 2);
              Command("PLACE", "Sim101", "ES 09-20", "BUY", 1, "STOPMARKET", 0, (currentAskPrice + 1),
              "DAY", string.Empty, NewOrderId(), string.Empty, string.Empty)
              If I do that and set a 7 pips as stop loss, it doesn execute, because price is far from there, (I'm saying the stop is way op the current price so obviously order does not execute) I don't understand this logic. how do i set up a buy or sell position configured with an stop loss of maximum 7 points against the position. Cannot be that difficult..... or there is something odd in the api not explained in the guide. I need a sample of how to do just that.

              Last edited by abner77; 07-09-2020, 11:18 AM.

              Comment


                #8
                Image of code added. This code does not execute, does not raise error by ninjatrader, but does nothing as I commented in the last post.

                Comment


                  #9
                  Hello abner77,

                  Do you have NinjaTrader 7 open?

                  I'm finding the code I have suggested is working without issue.

                  Below is a link to a video.
                  https://drive.google.com/file/d/1tW5...w?usp=drivesdk

                  And a link to a forum post on the API.
                  https://ninjatrader.com/support/foru...626#post793626
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello abner77,

                    Do you have NinjaTrader 7 open?

                    I'm finding the code I have suggested is working without issue.

                    Below is a link to a video.
                    https://drive.google.com/file/d/1tW5...w?usp=drivesdk

                    And a link to a forum post on the API.
                    https://ninjatrader.com/support/foru...626#post793626
                    I'm using NinjaTRader 8 64 bits

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello abner77,

                      Do you have NinjaTrader 7 open?

                      I'm finding the code I have suggested is working without issue.

                      Below is a link to a video.
                      https://drive.google.com/file/d/1tW5...w?usp=drivesdk

                      And a link to a forum post on the API.
                      https://ninjatrader.com/support/foru...626#post793626
                      The sample of the video is not valid IMHO. You are using a BUY order with an stop which is just 1 point ABOVE the price. That's not the definition of setting a stop order. A buy order with an stop loss would be configured with the stop price several points BELOW the current price, so the operation would be executed at a market price, and, in case the market move against your position an touches the price set as stop loss, the position would be automatically closed.

                      Comment


                        #12
                        Hello abner77,

                        I just wanted to clarify, were you able to try doing the test that Chelsea had provided a video of despite it not necessarily being valid or not?

                        The purpose of that was simply to put the order in and see it in the platform as a demonstration. You mentioned that the platform did nothing when you submitted the order so this test helps to make sure the platform is able to see an order come through.

                        I would suggest to go from the sample like shown in the video to test the API. If something you try after that point stops working you can know it was because of the code you used and not something else. A nothing result wouldn't be expected so making sure the connection is established and working is a good starting point.



                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Jesse View Post
                          Hello abner77,

                          I just wanted to clarify, were you able to try doing the test that Chelsea had provided a video of despite it not necessarily being valid or not?

                          The purpose of that was simply to put the order in and see it in the platform as a demonstration. You mentioned that the platform did nothing when you submitted the order so this test helps to make sure the platform is able to see an order come through.

                          I would suggest to go from the sample like shown in the video to test the API. If something you try after that point stops working you can know it was because of the code you used and not something else. A nothing result wouldn't be expected so making sure the connection is established and working is a good starting point.


                          I am able to place market orders and close positions through the API NinjaTrader.Client without any issue , the problem is just for the STOPMARKET orders (I haven't tried STOPLIMIT, but for the way I have trained my system STOPMARKET and CLOSEPOSITION positions are the only ones I really need.....

                          These are working no problems so far (see image attached):

                          Comment


                            #14
                            Hello abner77,

                            I tried this myself using the video steps and I can see stop market orders working on my end just like the video. I would suggest to save what you have as a zip excluding all the build data and attach it as a sample so we can review that before we continue further.

                            I look forward to being of further assistance.
                            JesseNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Jesse View Post
                              Hello abner77,

                              I tried this myself using the video steps and I can see stop market orders working on my end just like the video. I would suggest to save what you have as a zip excluding all the build data and attach it as a sample so we can review that before we continue further.

                              I look forward to being of further assistance.
                              Hi, I attach this toy sample trying to place a STOPMARKET order. Thanks for the assistance.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by webus, Today, 02:03 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post webus
                              by webus
                               
                              Started by momchi, Yesterday, 07:12 PM
                              1 response
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChrisSch  
                              Started by DieSlower, Yesterday, 11:02 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post DieSlower  
                              Started by gujungg, Yesterday, 10:59 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post gujungg
                              by gujungg
                               
                              Started by DieSlower, Yesterday, 09:46 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post DieSlower  
                              Working...
                              X