• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alert only triggered once per Bar

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

    Alert only triggered once per Bar

    Hi,

    I've developed an alert that's triggered while a bar is still in progress (CalculateOnBarClose = false), but if it is triggered I want to make sure it can't be triggered again within the same bar. How can this be achieved?

    Thanks

    #2
    Hello laocoon,

    Thanks for your post.

    You can check to see if the current bar is the same bar as the alert was issued on. For example assume you create a private int alertBar and then save the CurrentBar into it when you set the alert:

    if (your alert conditions && CurrentBar != alertBar)
    {
    Alert(...);
    alertBar = CurrentBar; // save the current bar on the first time through
    }


    So in the example if the current bar is not equal to the alertBar then the alert will sound and the current bar number will be saved into alertBar, on the next tick(s) the alert will not be issued until a new bar is opened and CurrentBar changes.

    Reference: https://ninjatrader.com/support/help...currentbar.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Perfect, thanks so much Paul!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Erwin Beckers, 11-04-2018, 02:39 AM
      4 responses
      69 views
      2 likes
      Last Post brucerobinson  
      Started by ntbone, Today, 01:25 AM
      0 responses
      5 views
      0 likes
      Last Post ntbone
      by ntbone
       
      Started by bomanpbm, Yesterday, 09:27 PM
      0 responses
      5 views
      0 likes
      Last Post bomanpbm  
      Started by tgn55, Yesterday, 08:47 AM
      0 responses
      11 views
      0 likes
      Last Post tgn55
      by tgn55
       
      Started by ballboy11, 05-04-2019, 10:26 AM
      6 responses
      61 views
      0 likes
      Last Post Kermit
      by Kermit
       
      Working...
      X