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

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 ender_wiggum, Today, 09:50 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by rajendrasubedi2023, Today, 09:50 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by geotrades1, Today, 10:02 AM
    0 responses
    4 views
    0 likes
    Last Post geotrades1  
    Started by bmartz, Today, 09:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by geddyisodin, Today, 05:20 AM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X