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 DavidHP, Today, 07:56 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by kujista, Today, 06:23 AM
      3 responses
      9 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by Mindset, Yesterday, 02:04 AM
      2 responses
      18 views
      0 likes
      Last Post NinjaTrader_RyanS  
      Started by f.saeidi, Today, 08:03 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by samish18, 04-17-2024, 08:57 AM
      15 responses
      54 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X