Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When exactly does (Position.MarketPosition == MarketPosition.Long) become true?

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

    When exactly does (Position.MarketPosition == MarketPosition.Long) become true?

    Is it when the order.Orderstate is Initialized? Submitted? Accepted? Working? Or Filled? My money's on Filled but I'm seeking reassurance.

    #2
    Filled or PartiallyFilled if this is an entry order to go long, and if you were flat before.

    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thanks Bruce. Also, is there any real benefit to doing things in OnMarketUpdate when coding for realtime since OnBarUpdate is always called each time as well before OnMarketUpdate.


      Last edited by markdshark; 04-16-2023, 09:55 AM.

      Comment


        #4
        You can't know the order these events will be called. They may happen in a particular order during BACKTESTING or on SIM ACCOUNTS but with live brokers the order can vary.

        Generally speaking, you should process things in OnBarUpdate if what you're doing is about trade price information, and use OnMarketData if you're processing L1 information such as bid or ask changes, but there are other special cases, so you just have to think about what you are doing and whether it needs to be in OnMarketData.

        Bear in mind that if you use the OnMarketData approach you will have to do a tick replay or market replay to backtest.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello markdshark,

          Thanks for your post.

          QuantKey_Bruce is correct. Position.MarketPosition will be equal to market position long anytime an entry order you place becomes filled or partially filled and you were in a flat position before.

          Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm
          Order State Definitions: https://ninjatrader.com/support/help...efinitions.htm

          Further, you should typically process logic in OnBarUpdate() because as QuantKey_Bruce stated, the order of events that process could be different from the events you see when backtesting or from the Sim101 account and is dependent on your broker.
          <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,
            Why does " you were in a flat position before " matter here to determine Position.MarketPosition == Long?
            Suppose my account have 1 contract of short position now, then I submitted 2 contract of long order. Once this short order filled, isn't the Position.MarketPosition = Long ?

            Comment


              #7
              Hello judysamnt7,

              In that post brandon was just saying that the position would be long now once a long execution happens, the position will change from flat to long in his example.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              53 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              130 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              70 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              44 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