Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Putting indicator thread to sleep

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

    Putting indicator thread to sleep

    Hi,

    I have indicator code that writes out bar data to a file on bar close -- I configure the indicator to update on bar close only, so it would appear to be simple. However, I noticed in the time stamp in the data file that the bar close event one-minute bars sometimes would orruce at 58 or 59 seconds of the current as opposed to the almost always 00 or 01 seconds of the new bar. To insure that I only write the bar data just after the next bar has started, I would want to have the indicator thread sleep say 1.2 second at a time if a check shows that we haven't quite crossed the minute boundary.

    Would having the thread on which the indicator is being calculated sleep interrupt/interfere with processing in other areas of the NT application?

    Thanks,

    Gordon

    #2
    Gordon,

    Let me start off by providing a little more information on how NinjaTrader builds bars. A minute bar is actually not on a 60 second timer. It checks the timestamps of the incoming ticks. When the timestamp of an incoming tick crosses the boundary of the minute then NT knows that a bar has closed and starts building a new bar. So it is possible to have the last tick of a bar timestamped as 58, receive the next tick as 01 and that will close the prior bar without seeing a 59 or 00 timestamp.

    You should not sleep the indicator thread itself because that will lock up the whole application.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    625 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    567 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X