• 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 rickyblah12, Today, 09:34 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by CaptainAmericaXX, Today, 09:05 AM
      2 responses
      10 views
      0 likes
      Last Post koganam
      by koganam
       
      Started by tdawson11, Today, 07:48 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by habibalex, Today, 09:03 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by memonolog, Today, 07:56 AM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Working...
      X