• 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 Gregory Arkadin, Today, 03:31 PM
      0 responses
      13 views
      0 likes
      Last Post Gregory Arkadin  
      Started by cutzpr, Today, 03:27 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by caveat_lector, Today, 03:18 PM
      1 response
      5 views
      0 likes
      Last Post caveat_lector  
      Started by cutzpr, Today, 01:16 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by fling_wing, Yesterday, 09:00 PM
      2 responses
      19 views
      0 likes
      Last Post fling_wing  
      Working...
      X