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

How do you tell if your position is a simulated historical position

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

    How do you tell if your position is a simulated historical position

    Hi, I'm wondering if there is a definitive way to tell if your strategy currently executing a historical stimulated position after it has transitioned to real time. I understand that you can detect a discrepancy between the Account position and the strategy position, however as far as the strategy is concerned, it doesn't know what other existing strategies out there may be affecting the account position.

    We need to perform some special handling and feedback to the user when the strategy is in this special state - how do we know if we're in this state (from a programmatic perspective)?

    Thanks in advance.
    Jeremytang
    NinjaTrader Ecosystem Vendor - Shark Indicators

    #2
    Hello Jeremytang,

    An easy way to tell would be if the position is not flat on the last fully closed historical bar.
    Code:
    if (State == State.Historical && CurrentBar == Count - 2 && Position.MarketPosition != MarketPosition.Flat)
    {
    // the position is not flat on the last fully closed historical bar
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea, does (Count-2) always gaurentee being at the close of the last historical bar, (assuming we're in BarsInprogress=0) even if there are multiple barseries loaded in the strategy?


      QUOTE=NinjaTrader_ChelseaB;n1052814]Hello Jeremytang,

      An easy way to tell would be if the position is not flat on the last fully closed historical bar.
      Code:
      if (State == State.Historical && CurrentBar == Count - 2 && Position.MarketPosition != MarketPosition.Flat)
      {
      // the position is not flat on the last fully closed historical bar
      }
      [/QUOTE]

      Jeremytang
      NinjaTrader Ecosystem Vendor - Shark Indicators

      Comment


        #4
        Hello Jeremytang,

        The positions on other instruments you would want to check individually.

        Code:
        if (State == State.Historical && BarsInProgress == 1 && CurrentBars[1] == BarsArray[1].Count - 2 && Positions[1].MarketPosition != Position.Flat)
        But for the primary instrument only the last bar is necessary and if the instrument is the same for added series this uses the primary series position.

        And yes, when the state is historical 'Count - 2' is the last closed bar (there is an unclosed historical bar after that transitions to real-time).
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, Today, 10:57 PM
        0 responses
        6 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Today, 09:29 PM
        0 responses
        7 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Working...
        X