Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market position bug ... again

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

    Market position bug ... again

    I literally just reset my database, closed NT8, re-opened, applied my strategy and am getting this statement equating to true? No positions... why does it think I have one on?

    Positions[0].MarketPosition == MarketPosition.Long

    I don't understand how last night everything was working fine on market replay... and now I'm getting errors? No code changes... just opened NT8 and tried to start my strategy on SIM.

    the inconsistency of this platform is confusing and alarming.

    Here is my positions tab ... empty
    Click image for larger version

Name:	image.png
Views:	138
Size:	13.7 KB
ID:	1297036

    #2
    Note: This is live market, not market replay. The Account is SIM

    Comment


      #3
      Hello halgo_boulder,

      This could be a historical virtual position opened with a historical order (which will not be a real-time order or position).

      You can use prints to print the State one line before the entry is submitted to check if this is the case.


      Below is a link to a forum post on start behavior.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi Chelsea,

        1. I wiped the database clean (reset database) before starting the strategy

        2. I tried both "submit immediately" and "submit immediately synchronize account" start behaviors. Both produce the same result.

        Comment


          #5
          Hello halgo_boulder,

          Resetting the database will not prevent a script from submitting orders in historical data.

          The start behavior also will not prevent historical orders, but controls how the script synchronizes those historical orders.

          As discussed on the forum thread I have linked you, to prevent historical orders, return in OnBarUpdate() when the State is not State.Historical.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            OK now I understand what is meant by "historical order".

            I fixed it... and to let you and everyone else know... a better approach is merely wrap any order (enter or exit) in the condition like so:

            if (State == State.Realtime)
            {
            ExitLong(0,0,"","");
            ExitShort(0,0,"","");
            }


            Rather than just using a "return" which would exit that bar's processing entirely.

            This way, if you have signals in your code that print on the chart, or to the output window, they will still print, and historical orders will not be submitted.​

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            116 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            61 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            82 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X