Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

closing positions for other strategies

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

    closing positions for other strategies

    Dear friends.
    I try to create strategy which can monitor positions from other instruments or opened manually. But I have a trouble with closing position. As I understand I can influence only at my strategy. If manually opened positions is Short with 5 lots, and my strategy opens Long position with 5 lots, I will not close first position.
    I have attached my strategy.
    Attached Files

    #2
    I have attached screens from my terminal.
    Attached Files

    Comment


      #3
      Hello daglas,
      If you open a position for 5 short manually and your strategy opens a position for 5 long, then overall your account position will be flat however your strategy position will be 5 long.

      You can use the below unsupported code to check on the overall account position.
      Code:
      foreach (Position p in Account.Positions)
      {
      	if (p.Instrument.FullName == Instrument.FullName)
              {
      		//do stuff
              }
      }
      I will leave the thread open for any forum member who can further assist you in this regard.
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Joydeep View Post
        Hello daglas,
        If you open a position for 5 short manually and your strategy opens a position for 5 long, then overall your account position will be flat however your strategy position will be 5 long.

        You can use the below unsupported code to check on the overall account position.
        Code:
        foreach (Position p in Account.Positions)
        {
            if (p.Instrument.FullName == Instrument.FullName)
                {
                //do stuff
                }
        }
        I will leave the thread open for any forum member who can further assist you in this regard.
        Many thanks for your help.
        I have check this code, it has access only for position which are visible on Positions Tab. I can't get data about from my strategy with this code. I think I should you getpnl method in code of my strategy and compare it with positions available on Position tab.
        Also I have get some strange message about overfill orders.
        Attached Files

        Comment


          #5
          Hello daglas,
          Position.Quantity should give you the current position held by your strategy.



          An overfill is categorized as when an order returns a "Filled" or "PartFilled" state after the order was already marked for cancellation. The cancel request could have been induced by an explicit CancelOrder() call, from more implicit cancellations like those that occur when another order sharing the same OCO ID is filled, or from things like order expirations.
          JoydeepNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 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
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X