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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    236 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    151 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    162 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    243 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    198 views
    0 likes
    Last Post CarlTrading  
    Working...
    X