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

Alert on new bar?

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

    #31
    Originally posted by NinjaTrader_AdamP View Post
    Jim P,

    I am happy to assist you.

    The code I posted in post number 2 will work for you. For future reference, you can go to Tools > New NinjaScript > Indicator then just paste this code into your OnBarUpdate() method. However, Ill just attach this indicator below. To import it, go to Files > Utilities > Import NinjaScript.

    Please let me know if I may assist further.
    Hey, would this indicator also work with range bars?

    Comment


      #32
      Hello ntpro,

      Thank you for your post.

      The indicator will work for all bar types. Make sure to use CalculateOnBarClose = true for this indicator to truly alert when the bar closes.

      Comment


        #33
        I tried changing the sound file in the indicator script to another one that was listed in the NT folder sound file and the original still plays. I restarted NT and that still did not help. Any ideas?

        Comment


          #34
          Hello Volcom,

          Thank you for your post and welcome to the NinjaTrader Support Forum!

          Can you provide the line of code you altered?

          Comment


            #35
            I simply changed "Alert1.wav" to "Alert2.wav", saved the file and re-started NT. However, sound file still plays "Alert1.wav".


            Alert(
            "Bar CLOSED!", NinjaTrader.Cbi.Priority.High, "Bar CLOSED!", "Alert2.wav", 10, Color.Red, Color.Yellow);

            Comment


              #36
              Originally posted by Volcom View Post
              I simply changed "Alert1.wav" to "Alert2.wav", saved the file and re-started NT. However, sound file still plays "Alert1.wav".


              Alert(
              "Bar CLOSED!", NinjaTrader.Cbi.Priority.High, "Bar CLOSED!", "Alert2.wav", 10, Color.Red, Color.Yellow);
              You say "saved the file." How? Did you compile the indicator?

              Comment


                #37
                Thanks, compiling the script solved the problem. I was only saving it by clicking the little disk icon in the top right hand corner.

                Comment


                  #38
                  Is it possible to have this formula tweaked to trigger alert

                  ONLY when the CLOSED bar was DIFFERENT from the previous bar?

                  By DIFFERENT I mean different color.


                  I basically do not want the alert to trigger when the trend continues only when it is reversing.
                  Last edited by zdzich; 09-23-2015, 06:11 AM.

                  Comment


                    #39
                    Hello zdzich,

                    Thank you for your post and welcome to the NinjaTrader Support Forum!

                    You would change the code in the OnBarUpdate() method to the following:
                    Code:
                            protected override void OnBarUpdate()
                            {
                    			
                    			if((Close[0] > Open[0] && Close[1] < Open[1])
                    			|| (Close[0] < Open[0] && Close[1] > Open[1]))
                    			{
                    			Alert("Bar CLOSED!", NinjaTrader.Cbi.Priority.High, "Bar CLOSED!", "Alert1.wav", 10, Color.Red, Color.Yellow);
                    			}
                    			
                            }

                    Comment


                      #40
                      Hi Patrick!

                      Thanks for quick response but it doesn't seem to work. The code compiled no problems but now there is no alert at all.

                      Comment


                        #41
                        Hello zdzich,

                        Thank you for your response.

                        Can you copy and paste your code into your response? Or you can attach the .cs file found under (My) Documents\NinjaTrader 7\bin\Custom\Indicator to your response.

                        Comment


                          #42
                          Ok my bad! It does work with regular minute graph.

                          Is it possible to make it work with Heiken Ashi and Renko chart?

                          Heiken Ashi bar always opens in the middle of a previous bar. Heiken Ashi Formula:

                          Close = (Open Price + High + Low +Close) / 4

                          Open = (Average of Open Price and Close Price of the previous bar)

                          High = (Maximum value of the (High, Open, Close))

                          Low = (Minimum value of the (Low, Open, Close))
                          Attached Files
                          Last edited by zdzich; 09-23-2015, 11:37 AM.

                          Comment


                            #43
                            Hello zdzich,

                            With a Renko chart it should be fine, but with the Heiken Ashi the logic would need to be changed. The Heiken Ashi is an indicator and would need to be what we compare against.

                            For information on the Heiken Ashi indicator method please visit the following link: http://ninjatrader.com/support/helpG...eiken_ashi.htm

                            Comment


                              #44
                              Dear Patrick,

                              For some reason now it stopped working altogether. I keep getting error message in log:

                              [Error on calling 'OnBarUpdate' method for indicator 'CloseBarAlert' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.]

                              but it does trigger the error at the right times. Any ideas? I'm not a coder just so you know =]

                              In case its needed I'm also attaching log file.
                              Attached Files

                              Comment


                                #45
                                Hello zdzich,

                                Can you provide the script that implements the Heiken Ashi indicator?

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by sidlercom80, 10-28-2023, 08:49 AM
                                167 responses
                                2,260 views
                                0 likes
                                Last Post jeronymite  
                                Started by warreng86, 11-10-2020, 02:04 PM
                                7 responses
                                1,361 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by Perr0Grande, Today, 08:16 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post Perr0Grande  
                                Started by elderan, Today, 08:03 PM
                                0 responses
                                9 views
                                0 likes
                                Last Post elderan
                                by elderan
                                 
                                Started by algospoke, Today, 06:40 PM
                                0 responses
                                10 views
                                0 likes
                                Last Post algospoke  
                                Working...
                                X