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 sjsj2732, Yesterday, 04:31 AM
    0 responses
    30 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    286 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    282 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    132 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X