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 fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Working...
      X