Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

onOpen ?

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

    onOpen ?

    I've created a indicator which I'm using on 1 minute bars. I've set 'Calculate on bar close' to false.

    What I want: I would like to save the 'Open' value of each bar in a SQL Server Database. The database connection is working so thats not the problem. However: onUpdateBar() triggers on each tick of these bars, so my indicator is saving the same 'Open' value multiple times during the creation of the bar.

    I would like the 'Open' value to be saved just once, and not each tick.

    I would like to avoid checking the database each tick to see if I've already saved the open value. I'm using 50+ instruments so that would cause tremendous database load.

    Is there anyway to let a piece of NinjaScript code just fire once, on the first tick of a bar?

    #2
    Originally posted by Rickman View Post
    I've created a indicator which I'm using on 1 minute bars. I've set 'Calculate on bar close' to false.

    What I want: I would like to save the 'Open' value of each bar in a SQL Server Database. The database connection is working so thats not the problem. However: onUpdateBar() triggers on each tick of these bars, so my indicator is saving the same 'Open' value multiple times during the creation of the bar.

    I would like the 'Open' value to be saved just once, and not each tick.

    I would like to avoid checking the database each tick to see if I've already saved the open value. I'm using 50+ instruments so that would cause tremendous database load.

    Is there anyway to let a piece of NinjaScript code just fire once, on the first tick of a bar?
    Code:
    if (FirstTickOfBar){//save the values that you want}
    ref: http://ninjatrader.com/support/helpG...ttickofbar.htm

    Comment


      #3
      Hello Rickman,

      Thank you for your note.

      I put together a sample indicator which will check if the CurrentBar is >= to a variable who’s value equals the current bar plus 1, which is assigned from within the condition. This if statement only becomes true on a new bar.

      Please let us know if you need further assistance.
      Attached Files
      Alan P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      77 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      45 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      27 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      63 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X