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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X