Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Alarm

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

    Alarm

    Hello there !

    I want to put a sound alarm on a set of conditions in my indicator.
    My indicator is "real time", not calculated at bar close.

    How can I setup my sound alarm to play only the first time the conditions are met and not at each ticks ?

    Thank you very much.
    J.

    #2
    Hi jed77, you could use FirstTickOfBar() to generate it only then and not on subsequent ticks in that bar, see this link here please - http://www.ninjatrader-support.com/H...TickOfBar.html

    Alternativelt you can also set the rearm setting to a higher number - http://www.ninjatrader-support.com/H...eV6/Alert.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes, but sometime, conditions are met "intra bar" not at the 1st tick...
      How can I handle that ?
      Thx
      J.

      Comment


        #4
        Ok, did you try using a higher rearm setting then?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          No, not yet, was trying to investigate if there's a better solution....
          Keeping that as "Plan B"

          J.

          Comment


            #6
            Hi jed77, more elegant way would be to program it manually. You could reset a variable on the first tick of the new bar and record then if your alert condition has triggered.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              HoHo !
              That sounds good !
              This is the idea I had in mind, but I don't really know how to do....
              Thx
              J.

              Comment


                #8
                Hi jed77, ok here is some sample code that would do this. Remember you need a unique alert id for this to work. Please put the variable

                Code:
                private bool myAlert = false;
                in your Variables() section.

                This is the OnBarUpdate() then -

                Code:
                [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (CurrentBar < [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])
                [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2];
                
                [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] > Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] 
                && myAlert == [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2])
                {
                Alert([/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"myAlert"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] + CurrentBar, NinjaTrader.Cbi.Priority.High, [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"Action"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"Alert1.wav"[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], [/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2], Color.DarkGray, Color.Blue);
                myAlert = [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2];
                }
                
                [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (FirstTickOfBar)
                myAlert = [/SIZE][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]false[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2];[/SIZE][/SIZE]
                [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2][FONT=Verdana][/FONT][/SIZE][/FONT][/SIZE][/FONT]

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thx Bertrand, I'll have a look at that !
                  All the best and Happy new year.
                  J.

                  Comment


                    #10
                    Thanks jed77, a happy holiday season to you and your family!
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    16 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    11 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    244 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    387 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X