Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Chart Trader, Order.OrderAction and BuyToCover/SellShort

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

    Chart Trader, Order.OrderAction and BuyToCover/SellShort

    My understanding from the documentation is that when creating a short position one would use OrderAction.SellShort and OrderAction.BuyToCover to enter and exit a position in an instrument. I noticed when using the Chart Trader if I hit Sell for an instrument with no position the order action is Sell instead of SellShort. Once in a position it does correctly use BuyToCover to exit the position.

    Why doesn't the chart trader use SellShort for these orders?

    #2
    Hello ntbone, thanks for writing in.

    If you need the Chart Trader order action for sell orders to be SellShort I can submit a feature request to our development team. The current design is intended likely for all the different connections we support, but the exact reason why is not publicly available info.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I don't need it to SellShort. I am just trying to understand the behavior of why, with no position open, it doens't use SellShort instead of Sell. I am using the unmanaged code to create orders in my own scripts and my understanding is if you want to go short you use the SellShort action, yet I see the built in chart trader does not do this.

      Comment


        #4
        Further, I tested both the Basic Entry and Order Ticket with the same behavior. With no position if I sell an instrument, it uses a Sell order. If I then close the order it uses buy to cover. If I just use the buy button, it uses the Buy Action.

        So it would seem based on behavior of the built in functionality
        • Use Buy for long
        • Use Sell to exit a long position
        • Use Sell for shorting
        • Use Buy to exit a position (or part of one).
        • Use BuyToCover to close a position ???
        Its very unclear why one would use SellShort or BuyToCover as I am never able to get it to use SellShort and it only uses BuyToCover if I hit the close button.
        Last edited by ntbone; 03-29-2021, 10:57 AM.

        Comment


          #5
          Hello, thanks for your reply.

          A OrderAction.Buy or OrderAction.BuyToCover are both just buy orders that do the same thing. The same goes for the sell orders. It's up to you if you use just buy or sell or the variants for clear labeling of trade actions.

          Please let me know if I can assist any further.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Ah. So this will not impact behavior by the brokers?

            Comment


              #7
              Originally posted by ntbone View Post
              Further, I tested both the Basic Entry and Order Ticket with the same behavior. With no position if I sell an instrument, it uses a Sell order. If I then close the order it uses buy to cover. If I just use the buy button, it uses the Buy Action.

              So it would seem based on behavior of the built in functionality
              • Use Buy for long
              • Use Sell to exit a long position
              • Use Sell for shorting
              • Use Buy to exit a position (or part of one).
              • Use BuyToCover to close a position ???
              Its very unclear why one would use SellShort or BuyToCover as I am never able to get it to use SellShort and it only uses BuyToCover if I hit the close button.
              Does it matter?

              Sorry, I'm not trying to be funny. I'm curious as to what you've found that
              makes the chosen nomenclature in the messages you see suggest there
              is a problem.

              I mean, from the broker's point of view, there are only two kinds of order
              actions, Buy and Sell. Period. Full Stop. (Ok, three if you count Cancel.)

              [EDIT: Apparently this is not true for all brokers.]

              Brokers don't have a separate order action types known as SellShort or
              BuyToCover -- these are just nicknames for Buy and Sell -- and these
              nicknames are NinjaTrader specific, probably chosen by the engineers
              in the early days of product development.

              [EDIT: It appears some brokers need to know this, so "SellShort"
              is distinct and different from just "Sell". NinjaTrader exposes the
              distinction for its API, but whether the broker technology also
              needs the distinction is abstracted away -- NinjaTrader does the
              right thing internally for whatever broker it's talking to]

              I think you may be reading way too much into this.
              Why does it matter that the messages you see don't reflect the order
              Action name used in Unmanaged mode? Is it documented that Chart
              Trader is using the Unmanaged mode APIs?

              Let's first consider that Unmanaged mode's OrderAction has 4 values,
              which perform the following actions,

              OrderAction.Buy BuyToOpen - Enter Long position
              OrderAction.Sell SellToClose - Exit Long position
              OrderAction.SellShort SellToOpen - Enter Short position
              OrderAction.BuyToCover BuyToClose - Exit Short position

              If you want to open a Short position using Unmanaged mode in a Strategy
              (not Chart Trader, or Basic Entry, etc) then you would specify the correct
              NinjaScript C# code to do that -- which is OrderAction.SellShort -- using
              the correct method -- which is SubmitOrderUnmanaged.

              Chart Trader != Unmanaged mode
              Basic Entry != Unmanaged mode

              Let's just assume: Unmanaged mode is an exposed API that is using unexposed
              lower level methods. These lower level methods are non-public & deeply internal.
              A variety of public APIs and internal platform operations make use of these lower
              level APIs.

              Don't over-emphasize wording in the messages you see at the expense of the
              operational intent of that wording. I mean, whether the message says "Sell" or
              "SellShort" doesn't really matter that much. These messages are for human
              consumption.

              I mean, internally, inside the NinjaTrader Unmanaged API code, "Sell" exits a
              long position, and "SellShort" enters a short position. In both cases, however,
              the platform sends the same Sell command to your broker.

              [EDIT: My bad. The effect appears the same, but as further posts clarify,
              some brokers may well require the Sell vs SellShort distinction. Regardless,
              it's a very low level of detail which we (the users of NT APIs) don't know or
              care about. Just use correct Sell or SellShort as documented, and every
              thing should be fine, NT takes care of these broker-specific details for us.]

              Make sense?

              Last edited by bltdavid; 04-02-2021, 04:31 PM. Reason: Some of my answers were off, added EDITs with correction

              Comment


                #8
                It wasn't clear whether the distinction between BuyToCover and Buy or SellShort and Sell would matter to the broker or not. Conceptually I agree that there are only 2 types of actions (or three as you called it out). I wanted clarification that these order actions wouldn't matter as far as the broker is concerned. I want to create code that creates orders with minimal likely hood of the orders being rejected. If this distinction mattered it would be important to set it correctly and not have orders rejected simply due to incorrect parameter.

                I used the various built in order entry functionality in NinjaTrader as an attempt to answer the question as to whether the information mattered. These parameters cannot be set by the user. The user can only pick whether to buy or sell. If the Chat Trader/Basic Entry always used BuyToCover/SellShort when dealing with a short position then it would indicate a potential that this is required. It would still need clarification. My findings showed that the manual entry orders sometimes used the distinction and sometimes didn't.

                I wanted clarification from NinjaTrader developers themselves that this distinction didn't matter as far as the broker is concerned. Chris L confirmed that for me.

                Additionally, the conclusion that ChartTrader or Basic Entry != unmanaged mode is not one conclusion I could draw. Its quite possible all modes of trading go through the unmanaged API. Hopefully there is some core single API that all order entry goes through and since the unmanaged API has the maximum control over orders it would make sense that all methods including Chart Trader, Basic Entry, the Strategy managed mode API's and the unmanaged API all go through the same core order submit/creation API.

                Comment


                  #9
                  Hello,

                  The best rule of thumb is to use SellShort order action to open shorts positions, and BuyToCover if the unmanaged order is meant to close out a short position. Some brokers will require the correct OrderAction to be set to open/close positions (like TD Ameritrade).

                  Best regards.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi ntbone,

                    Earlier a similar question was asked and received what I thought was a pretty reasonable response.

                    Some brokers require closing orders to be a '..tocover' and some brokers do not.

                    The NT design trys to help reduce the number of unexpected problems developers get hung up on by defaulting to assume you are working with a more restrictive broker that requires a "toCover" order type for some orders.


                    HedgePlay

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by lightsun47, Today, 03:51 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post lightsun47  
                    Started by 00nevest, Today, 02:27 PM
                    1 response
                    8 views
                    0 likes
                    Last Post 00nevest  
                    Started by futtrader, 04-21-2024, 01:50 AM
                    4 responses
                    44 views
                    0 likes
                    Last Post futtrader  
                    Started by Option Whisperer, Today, 09:55 AM
                    1 response
                    13 views
                    0 likes
                    Last Post bltdavid  
                    Started by port119, Today, 02:43 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post port119
                    by port119
                     
                    Working...
                    X