Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sync position after restart Strategy

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

    Sync position after restart Strategy

    NT8 provides several following syncing methods but I still need more guidelines.
    https://ninjatrader.com/support/help...rtbehavior.htm

    Here is the scenario: if I have bought 100 shares of IBM stocks either using Strategy or manually, then for any reason, I restarted Strategy. How can I apply my Strategy to sell these 100 (sh) of IBM? Is it possible to use ExitLongLimit() anymore?

    If it is possible that Strategy can obtain this existing 200 share of IBM in my real account, can ExitLong() be used here to sell this 200 (sh) of IBM?
    Last edited by localappleseed; 09-17-2020, 08:58 AM.

    #2
    Hello localappleseed,

    Thank you for your post.

    This could be achieved by specifically programming the strategy to be able to adopt the account position.

    https://ninjatrader.com/support/help...ccountPosition

    https://ninjatrader.com/support/help...itionaware.htm

    I'm attaching an example strategy made by one of my colleagues that will detect if there is an open position on the account for the instrument the strategy is applied to and submit stop loss/profit target orders to protect that position that should be helpful.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      This is so cool! Thanks a lot.

      Comment


        #4
        Hi, Kate,

        I tried to test this sample code you provided while there is a pending buying order submitted through SuperDOM. It looks like it didn't catch this pending position, is there anything I may have missed?

        protected override void OnBarUpdate()
        {

        if(State ==State.Historical) return;
        Print(State.ToString()+PositionsAccoun t[0].Quantity.ToString());
        Print(PositionsAccount[0].MarketPosition.ToString());


        Here are the outputs:
        Positions in State.DataLoaded:
        Positions in State.DataLoaded:

        Comment


          #5
          Hello localappleseed,

          Thank you for your reply.

          It would not be expected that an unfilled order would be recognized using Adopt Account Position - in fact, if you try to enable the strategy with a pending buy order you should see an error message pop up telling you that it cannot enable the strategy as "Adopt Account Position" requires that there are no working/pending orders on the strategies' instruments in that account.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by WeyldFalcon, Today, 02:07 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ThomasC  
          Started by hfwiley, Today, 03:02 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Melissa  
          Started by pdennis, Today, 02:34 PM
          2 responses
          13 views
          0 likes
          Last Post pdennis
          by pdennis
           
          Started by tonynt, Today, 01:47 PM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Kate  
          Started by WesFoster, Today, 12:39 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Dennis  
          Working...
          X