• 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

  • laocoon
    started a topic Alert only triggered once per Bar

    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

  • laocoon
    replied
    Perfect, thanks so much Paul!

    Leave a comment:


  • NinjaTrader_PaulH
    replied
    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

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by chazyang, Today, 08:11 AM
1 response
4 views
0 likes
Last Post NinjaTrader_PatrickG  
Started by Erwin Beckers, 11-04-2018, 02:39 AM
6 responses
78 views
2 likes
Last Post koganam
by koganam
 
Started by sergey_z, Today, 02:34 AM
3 responses
14 views
0 likes
Last Post NinjaTrader_PaulH  
Started by frankduc, Today, 05:24 AM
4 responses
18 views
0 likes
Last Post frankduc  
Started by shmarola, Today, 01:01 AM
0 responses
4 views
0 likes
Last Post shmarola  
Working...
X