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

Indicator is not executing at the last bar?

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

    Indicator is not executing at the last bar?

    Hello, I have a very strange error. One of my indicators is not executing at the last bar?

    The last bar index is 3425, and the trace print of my indicator just do until 3424! (I have searched for 3425 with find, but no result)

    All indicators on the chart has Calculate = Calculate.OnPriceChange;
    Another indicator at the chart, had a trace print showing 3425!

    protected override void OnBarUpdate()
    {
    //fixedDistDays = UpAndDowns().FixedDistDays;
    Print(String.Format("CurrentBar {0} LastBarIndex_G {1}", CurrentBar, LastBarIndex_G));
    if (CurrentBar == LastBarIndex_G)
    {
    //doEndOf_OnBarUpdate();
    }
    }

    Please, give me some hint what might be wrong?

    Thank you. /andbro

    #2
    Hello AndBro, and thank you for your question.

    While I am not familiar with your code, this seems to be what is known as a "fencepost problem". If there are exactly 3425 bars, they will be indexed 0 - 3424, and CurrentBar will never be 3425 .

    If you do not have exactly 3425 bars, please let us know so we can assist further.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jessica, no it is not a fence-problem. Last bar index is 3425, and that is the value I expect CurrentBar to have, when my indicator is executed the last time. All other indicators on the same chart executes with CurrentBar = = 3425, except from one that executes with CurrentBar == 3424 and then no more.

      Some ideas?
      - It is a long chain of indicators …
      - Some indicator are “called” from several different indicators … (tree ..). The “problem”-indicator is a ”leaf”.
      - I do some code in State == State.Transition (… then I expect the CurrentBar to be 3425!)
      - I use Update() … (I’m a bit suspicious about this function … can this one cause the problem)
      - I have no errors that might have abort the last loop for the failing indicator. Nothing in the output-window, neither in the log-tab.

      I need help to direct me so I can narrow the space where the problem is to be found.

      Thank you.

      Comment


        #4
        I feel as though I am not quite on the same page. Would you be able to provide a compileable code sample that demonstrates what is happening?
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Hello Jessica, some problems are solved after a night’s sleep! This morning the problem is gone! All indicators do as I expect. I have no clue what happened yesterday.
          Anyway, I hope I will never see this error again, and thank you for spending your time to help me.
          /andbro

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          2 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          6 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Working...
          X