Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Please help - Position Qty ?

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

    Please help - Position Qty ?

    Basically, my issue is that: currently I have 1 short position, and then I enter long 2 contracts. In theory, the position tab should only show 1 contract . however, it still shows 2 long ( after the short 1 was closed). I am wondering why?

    Here is my code:

    if ("condition 1 ok" && Position.Quantity == 0)

    {
    EnterLong( 1, "Buy1" );
    }

    // Condition set 2
    if ("Condition 2 ok" && Position.MarketPosition == MarketPosition.Short)
    {
    EnterLong( 2, "Buy2" );
    }

    Thank you very much!

    #2
    Hello OceanBass,

    Thanks for your post and welcome to the forums!

    With reference to the managed approach in the helpguide: http://ninjatrader.com/support/helpG...d_approach.htm

    The entry method, EnterLong() will reverse a position if one exists.

    In the example of 1 short, condition set 2, the EnterLong(2, "Buy2") would issue one buy market to close the position and then two buy market to enter you into a long position with two contracts.

    edit- added the 2, "buy2" to clarify

    Comment


      #3
      Thanks Paul!

      So if I modified the code as below , should be work, right?

      if ("condition 1 ok" && Position.Quantity == 0)

      {
      EnterLong( 1, "Buy1" );
      }

      // Condition set 2
      if ("Condition 2 ok" && Position.MarketPosition == MarketPosition.Short)
      {
      EnterLong( 1, "Buy2" ); ///change qty=1
      }

      Comment


        #4
        Hello OceanBass,

        Thanks for your reply.

        Correct.

        Comment


          #5
          Thank you Paul. One more question, sorry.

          The "Position" Tab is showing account position or strategy position? if it is account position, then where is strategy position showing ( as you know , sometimes they are different)?

          Thanks.

          Comment


            #6
            Hello OceanBass,

            Thanks for your reply.

            The positions tab in the control center shows the actual account position.

            The strategies tab in the control center shows the strategy position.

            Comment


              #7
              Hi Paul,

              if I have 2 short positions for 2 different symbols, like 1 short ES and 1 short CL. Then if I enterLong(), will it close all 2 short positions. how do I make sure it reverse the symbol I want only?

              Thanks.

              Comment


                #8
                someone can help below question? thanks.

                Comment


                  #9
                  Hello OceanBass,

                  Thanks for your post.

                  For your understanding we have skeleton crew available on the weekend and depending on the volume of queries not all questions can be quickly answered.

                  If you have one strategy for CL and one strategy for ES, only the one (with EnterLong) will be reversed. The strategies run independent of each other.

                  If you have both instruments in the same strategy then you would need to use the method overload of (for example): EnterLong(int barsInProgressIndex, int quantity, string signalName) where the variable BarsInProgress points to which instrument to reverse. Reference: https://ninjatrader.com/support/help...?enterlong.htm

                  If you are writing a multiseries strategy please do review: https://ninjatrader.com/support/help...nstruments.htm

                  Don't hesitate to use your sim101 account for testing your various questions as this will help increase your Ninjascript knowledge.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  558 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  324 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  545 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  547 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X