Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Position and Account Position disagreement after position is closed

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

    Strategy Position and Account Position disagreement after position is closed

    I am having an issue in which the strategy and the actual account are out of sync.

    The strategy places an order in the OnBarUpdate method.

    I am checking to make sure it is flat prior to entry and the setting a limit order and a calulated target and stop.

    EnterLongLimit(_price, tt.Name);

    // set target and stop
    _s = _price - (tt.OptimalStop * TickSize);
    _t = _price + ((tt.OptimalTarget - OffsetBuffer) * TickSize);

    SetStopLoss(CalculationMode.Price, _s);
    SetProfitTarget(CalculationMode.Price, _t);

    Everything works fine, target (or stop) is hit and the position is closed.

    On the strategy (under the position column) will still say that it is long.

    If I stop and start, everything is cleared and the strategy is ready to trade again.

    I added some code to check Position and PositionAccount:

    Print("strategy " + Position.MarketPosition);
    Print("account " + PositionAccount.MarketPosition);

    The account shows Flat and the strategy shows long. Eventually the strategy goes flat and will trade again.

    I have no other trade management in the strategy yet.


    #2
    Hello kenconcannon,

    Thanks for your post.

    Is the strategy going out of sync when first enabling the strategy on a Chart or in the Strategies tab of the Control Center?

    Or, is the strategy becoming out of sync while running realtime?

    Are you manually placing orders to the same instrument and same account that the strategy is running on?

    I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      The disagreement doesn’t happen in SIM. Only live.

      When I start the strategy everything is fine. I’m not placing any additional orders. It does clear (strategy is flat) after a few bars.

      Comment


        #4
        It looks like what is in disagreement is the tab on the command center still reading short when it is flat. Does this matter or is this just a display update issue?

        Comment


          #5
          Hello kenconcannon,

          Thanks for your note.

          Strategy Positions are driven by Executions and it seems that the Execution might have been delayed.

          Please write in to [email protected], answer the questions below in your email, and attach your Log and Trace files to your response so we may investigate this further.

          In the Subject of your email, include 'ATTN BrandonH - 3560430'. In the Body of the email, include a link to this forum thread.

          Please answer ALL the following questions so I may accurately assist.
          • What broker/data provider are you connected to when running your strategy? (Interactive Brokers, NinjaTrader Continuum, etc.)
          • What Time and Timezone did you see the issue occur?
          • What Time did you see the position update properly?

          Follow the steps below to manually attach your log and trace files to your response.
          • Open the Windows File Explorer (hotkey = Windows key + E) Then navigate to "Documents" > Open the "NinjaTrader 7/8" folder
          • Right-click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
          • Send the 2 compressed folders as attachments to this email.
          • Once complete, you can delete these compressed folders.
          I look forward to assisting further.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Hi Brandon,

            After doing research it looks like it is just a delay in updating the strategy tab in the Control Center. The strategy is reflecting the proper market position for the Position and the Position account object.

            Thanks for you help!
            Ken

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            56 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            132 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
            45 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