Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exact behaviour of EnterLong or EnterShort

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

    Exact behaviour of EnterLong or EnterShort

    Hello,

    I have been playing with those functions and from my results, I understand they behave like this, but I'm not exactly sure, since I have not been able to read their exact behaviour in the documentation (https://ninjatrader.com/support/help...entershort.htm , https://ninjatrader.com/support/help...nterlong.htm):
    - If there are no positions, they will simply open the desired position.
    - If there are other positions of the opposite side (for example, we call EnterLong(50) when having a SHORT position of 200), the current positions will be closed and then the LONG position itself will be opened. Therefore, we end up with a position of LONG with quantity 50. This strikes me as a bit odd. I would expect my position in that case to be SHORT 150 in that case.
    - If there are other positions of the same side, the specified quantity is simply added to the position. So if we have a position of LONG 50, and call EnterLong(200), we end up with a LONG position of 50.

    Are my assumptions correct? Where can I read more about them, or even other possible ways to handle the position for a specific instrument?

    Best regards.

    #2
    Hello Flood,

    Thank you for your note.

    If you're short 50, then call EnterLong(200), you are correct, the short position will be closed then you will be net long 200. This is expected behavior of the managed approach.

    If you are an experienced programmer, I might suggest looking into the unmanaged approach, which does not use EnterLong/Short methods but rather SubmitOrder.

    I would encourage you to read the following section of our helpguide,


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello Alan,

      Thanks for the quick reply. I will take a look into it, and come back here if I have any other questions.

      Best regards,
      Guillermo.

      Comment


        #4
        Originally posted by Flood View Post
        Hello,

        I have been playing with those functions and from my results, I understand they behave like this, but I'm not exactly sure, since I have not been able to read their exact behaviour in the documentation (https://ninjatrader.com/support/help...entershort.htm , https://ninjatrader.com/support/help...nterlong.htm):
        - If there are no positions, they will simply open the desired position.
        - If there are other positions of the opposite side (for example, we call EnterLong(50) when having a SHORT position of 200), the current positions will be closed and then the LONG position itself will be opened. Therefore, we end up with a position of LONG with quantity 50. This strikes me as a bit odd. I would expect my position in that case to be SHORT 150 in that case.
        EnterLong(50) means "NT, make orders so that I end up with a position of 50 Long from this order, when you are done." Therefore, if you are flat or short, NT will take you out, if necessary, and then enter you 50 long. If you are already long, NT will simply add to the position.

        If you are trying to reduce the short position by 50, then simply exit a quantity of 50. ExitShort(50).
        - If there are other positions of the same side, the specified quantity is simply added to the position. So if we have a position of LONG 50, and call EnterLong(200), we end up with a LONG position of 50.

        Are my assumptions correct? Where can I read more about them, or even other possible ways to handle the position for a specific instrument?

        Best regards.
        The part in red seems to make no arithmetic sense. Did you get the numbers wrong? You should end up with 250 long, not 50 long.
        Last edited by koganam; 10-04-2017, 11:15 AM. Reason: Improved explanation of how orders affect market position.

        Comment


          #5
          Originally posted by koganam View Post
          The part in red seems to make no arithmetic sense. Did you get the numbers wrong? You should end up with 250 long, not 50 long.
          Oops, yes, I misstyped them, I wanted to write 250 long at the end. Nice catch!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          54 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          131 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X