Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Processing Historical Data

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

    Processing Historical Data

    I need clarification about the NinjaScript life cycle, particularly the OnStateChange() method. I need to perform some calculations on historical bars, meaning all past chart bars except the currently forming one.
    I was thinking of changing State somewhere in the code, but I need to figure out how and where to code this change. An easier option would seem to put my logic in the OnBarUpdate() method with this code:
    Code:
    protected override void OnBarUpdate()
    {
    // Skip OnBarUpdate events
    if (State == State.Historical)
    // my logic
    }
    Is the latter enough? What would be NinjaScript's best approach?​

    #2
    Hello Gianpiero,

    Thanks for your post.

    If you would like certain code to only calculate when historical bars are processed, you could check if State == State.Historical in OnBarUpdate() and put your code within that method.

    To specify you want some code to only calculate on real-time data, you could check if State == State.Realtime in OnBarUpdate() and put your code within that method.

    See this help guide page for more information about State: https://ninjatrader.com/support/help.../nt8/state.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    157 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    307 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    346 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    176 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X