Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to prevent re-calculation?

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

    How to prevent re-calculation?

    Hello
    I have developed an indicator which, when placed on the chart, is displayed correctly but as soon as a new bar appears, it is erased and only the new bar is displayed.
    I imagine this is due to the condition if ( BarsInProgress != 0 )...
    I'd like to know how to remedy this problem.
    Thanks for your help.​

    #2
    Your code has a bug.

    I doubt BarsInProgess has anything to do with your problem.

    As far as preventing re-calculation, that sounds very nonsensical,
    since re-calculating as new bar data arrives is usually what an
    indicator is supposed to do.

    Sounds like you have some kind of problem which occurs when
    calculating during State.Realtime -- since you say calculating and
    rendering works during State.Historical just fine.

    So, you need to add some Prints to figure out what your code is
    doing. Add them to key areas to prove your assumptions are true,
    and use them generously to prove expected code paths are, in fact,
    being taken.

    Without more information (aka, your code) it's difficult for anyone
    to offer any serious guidance.

    You could post some or all of your code, but you'd learn much more
    by devoting your time to studying the execution of your code by using
    some well-placed Print statements.

    Comment


      #3
      Hello bicou,

      What is being erased?

      Is this a plot added with AddPlot()? (Are you unsetting previous bar plot values?)

      Is this a drawing object? (Are you using unique tag names for each new object?)
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        As Chelsea B said, use a unique tag. I don't know if this will help, but if your indicator includes a draw object, and that draw object's tag is not unique, the draw object keeps getting overwritten and is always at the last bar. In the draw object's parameters, set the tag using a prefix, like "triangle1", and then append a string which is unique to the current bar. The easiest way to do that would look something like this: "triangle1" + CurrentBar.ToString().​
        Last edited by c2injacator; 07-21-2023, 08:28 PM.

        Comment


          #5
          thank you for your answers.
          I'll see as soon as I get back.​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          557 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X