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

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
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by PaulMohn, Today, 12:36 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by yertle, Yesterday, 08:38 AM
      8 responses
      36 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by rdtdale, Today, 01:02 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by alifarahani, Today, 09:40 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      19 views
      0 likes
      Last Post RookieTrader  
      Working...
      X