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

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 warreng86, 11-10-2020, 02:04 PM
          7 responses
          1,360 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          5 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          9 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          14 views
          0 likes
          Last Post maybeimnotrader  
          Working...
          X