Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Approach Current Position Long, Short or Flat

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

    Unmanaged Approach Current Position Long, Short or Flat

    I am developing an Unmanaged Approach strategy and have a question about reliably determining whether a Ninjatrader Continuum account is currently Long, Short or Flat in real-time.

    1) Market condition analysis is based on 15-second bars which are loaded as the primary data series.

    2) A tick data series is added with during State.Configure.

    3) Unmanaged Limit entry orders to go Long or Short are placed within OnBarUpdate() while processing the 15-second bars.

    4) ProfitTarget/StopLoss OCO orders are created during tick data series processing after an entry limit order has filled.

    I understand the necessity of assigning Order objects myself within OnOrderUpdate() to keep track of track of the current states of orders and I am doing that. My question is whether I also need to keep track of Long, Short or Flat market positions myself or whether something generally similar to this within OnBarUpdate() will be reliable:
    Code:
    if (position.MarketPosition == MarketPosition.Long)
    {
        (Conditionally do something ...)
    }
    else if (position.MarketPosition == MarketPosition.Short)
    {
       (Conditionally do something ...)
    }
    else  // Flat
    {
        (Conditionally do something ...)
    }

    #2
    I just noticed that I didn't capitalize "position.MarketPosition" in the code above. Both instances should have been "Position.MarketPosition".
    Last edited by caveat_lector; 03-14-2020, 05:40 PM.

    Comment


      #3
      Hi caveat_lector, thanks for your post.

      It's reliable to use the MarketPosition variable, it will be updated when the position changes. You also have access to the OnPositionUpdate method so you can know exactly when the account/strategy position changes.

      https://ninjatrader.com/support/help...tionupdate.htm - OnPositionUpdate

      Kind regards,

      -ChrisL

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X