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:	142
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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            43 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            21 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            30 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            50 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Working...
            X