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 jaybedreamin, Today, 05:56 PM
      0 responses
      2 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Working...
      X