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

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:	24
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 geddyisodin, 04-25-2024, 05:20 AM
            8 responses
            61 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by jxs_xrj, 01-12-2020, 09:49 AM
            4 responses
            3,287 views
            1 like
            Last Post jgualdronc  
            Started by Option Whisperer, Today, 09:55 AM
            0 responses
            5 views
            0 likes
            Last Post Option Whisperer  
            Started by halgo_boulder, 04-20-2024, 08:44 AM
            2 responses
            22 views
            0 likes
            Last Post halgo_boulder  
            Started by mishhh, 05-25-2010, 08:54 AM
            19 responses
            6,189 views
            0 likes
            Last Post rene69851  
            Working...
            X