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

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.
    Brandon H.NinjaTrader Customer Service

    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.
          Brandon H.NinjaTrader Customer Service

          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 Ashkam, 04-29-2024, 09:28 AM
            4 responses
            43 views
            0 likes
            Last Post Ashkam
            by Ashkam
             
            Started by nightstalker, Yesterday, 02:05 PM
            1 response
            29 views
            0 likes
            Last Post NinjaTrader_Eduardo  
            Started by dcriador, Today, 02:09 PM
            0 responses
            7 views
            0 likes
            Last Post dcriador  
            Started by nicthe, Today, 07:38 AM
            4 responses
            22 views
            0 likes
            Last Post bltdavid  
            Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
            30 responses
            98 views
            0 likes
            Last Post cmtjoancolmenero  
            Working...
            X