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

Alerts on COBC=false

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

    #16
    Originally posted by NinjaTrader_PatrickH View Post
    Hello cachevery,

    Thank you for your response.

    It would be the following:
    Code:
    if(FirstTickOfBar)
    {
    if( soundAlert != "" )
    {
    PlaySound( soundAlert );
    }
    if( emailAddress != "" )
    {
    string body = subject + Environment.NewLine + Environment.NewLine + "Message generated at " + Time[0];
    SendMail( fromEmailAddress, emailAddress, subject, body );
    }
    }
    }
    Thanks Patrick for the snippet.So now if i want the code to alert COBC = true,i should re-write it back,correct?Or should i creat anothe indicator and put them both on the chart?
    Suggestions?

    Comment


      #17
      Hey Patrcik,your idea doesn`t work.

      Comment


        #18
        Hello cachevery,

        I have created a sample indicator for you using the parts of the snippets you have provided along with some of the other posts in this thread.

        Rather than using the PlaySound I have used Alert. The reason for this is because Alert already includes a timer method that allows you to specify the frequency at which you will be alerted. Using this will require less logic to get it to do what you want.

        As i said i want both COBC =tru/false to behave equally.But when i set COBC = false itt`s firing alrets every second.I wnan the alers to go off intra-bar and on the bar close,depending on what i need.
        To make the code behave equally I have used a function because the logic is the same if COBC = true or false.

        In order to make COBC behave equally but also not alert you on every bar I have chosen to Alert()

        You do not need the alert window open for Alert to work.

        Please let me know if I may be of further assistance.
        Attached Files
        JesseNinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_Jesse View Post
          Hello cachevery,

          I have created a sample indicator for you using the parts of the snippets you have provided along with some of the other posts in this thread.

          Rather than using the PlaySound I have used Alert. The reason for this is because Alert already includes a timer method that allows you to specify the frequency at which you will be alerted. Using this will require less logic to get it to do what you want.



          To make the code behave equally I have used a function because the logic is the same if COBC = true or false.

          In order to make COBC behave equally but also not alert you on every bar I have chosen to Alert()

          You do not need the alert window open for Alert to work.

          Please let me know if I may be of further assistance.

          Hi Jess,what do i do with it?Should i put the original indicator alongside with the sample you`ve provided?

          Comment


            #20
            Hello cachevery,

            I just included the indicator for you to import into your NinjaTrader to take a look at how I have laid the code out in an indicator. to Import it you would use the File -> Utilities -> Import Ninjascript tool from the NinjaTrader control center window.

            If you would like you can put your code inside the sections of the indicator I had attached and give it a try. You could also use the code I had attached inside your own indicator filling in your code where you need it to be.

            It is simply a reference on how I had interpreted what you were asking for.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #21
              Originally posted by NinjaTrader_Jesse View Post
              Hello cachevery,

              I just included the indicator for you to import into your NinjaTrader to take a look at how I have laid the code out in an indicator. to Import it you would use the File -> Utilities -> Import Ninjascript tool from the NinjaTrader control center window.

              If you would like you can put your code inside the sections of the indicator I had attached and give it a try. You could also use the code I had attached inside your own indicator filling in your code where you need it to be.

              It is simply a reference on how I had interpreted what you were asking for.

              Please let me know if I may be of further assistance.

              I tried tu put it inside,but i get constant errors.I have a complicated code.Probably it`s more then just re-arm function or something to it.

              Comment


                #22
                Hello cachevery,

                Yes if you are just copying your whole code into the code I provided you will most likely get errors.

                I would recommend just using what I had provided as a reference on a possible way you could accomplish what you are trying to do.

                I had recommended the Alert() method as it has a timeout so you don’t have the sound go off every bar but rather every so many seconds. You could set this to a high value if you only want to be alerted once.

                The rest of the code was just a reference on how to check the conditions and apply logic surrounding how you had specified you wanted to be alerted.

                Please let me know if I may be of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by NinjaTrader_Jesse View Post
                  Hello cachevery,

                  Yes if you are just copying your whole code into the code I provided you will most likely get errors.

                  I would recommend just using what I had provided as a reference on a possible way you could accomplish what you are trying to do.

                  I had recommended the Alert() method as it has a timeout so you don’t have the sound go off every bar but rather every so many seconds. You could set this to a high value if you only want to be alerted once.

                  The rest of the code was just a reference on how to check the conditions and apply logic surrounding how you had specified you wanted to be alerted.

                  Please let me know if I may be of further assistance.
                  I got error in this line when try to replace soundalert method as you suggest:

                  if (soundAlert != "") {
                  Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, WhereWasThisCalledFrom, soundAlert, alertTimeout, Color.Black, Color.Yellow);

                  Comment


                    #24
                    Hello cachevery,

                    You are correct, if you copied that directly into your code that would not work. This is because I used 2 variables that are in the indicator I had attached.

                    Please note this is what you copied

                    Code:
                    Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, [B]WhereWasThisCalledFrom[/B], soundAlert, [B]alertTimeout[/B], Color.Black, Color.Yellow);
                    The Bolded text is why you are getting an error.

                    The first: WhereWasThisCalledFrom This is a string value that would be the text in the alert window, you can replace this with a blank string if you are not going to use the alert window.

                    The second alertTimeout This needs to be a integer value, 10 would equal 10 seconds for the timeout.

                    The completed code for Alert would be as follows
                    Code:
                    Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, "", soundAlert, 5, Color.Black, Color.Yellow);
                    Here is a link to the help guide documentation on Alert listing the overloads it takes and giving example usage.


                    I would recommend taking a look in the help guide on any of the items you are unsure on because most everything has a working generic code example you can copy directly into your script.
                    JesseNinjaTrader Customer Service

                    Comment


                      #25
                      Originally posted by NinjaTrader_Jesse View Post
                      Hello cachevery,

                      You are correct, if you copied that directly into your code that would not work. This is because I used 2 variables that are in the indicator I had attached.

                      Please note this is what you copied

                      Code:
                      Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, [B]WhereWasThisCalledFrom[/B], soundAlert, [B]alertTimeout[/B], Color.Black, Color.Yellow);
                      The Bolded text is why you are getting an error.

                      The first: WhereWasThisCalledFrom This is a string value that would be the text in the alert window, you can replace this with a blank string if you are not going to use the alert window.

                      The second alertTimeout This needs to be a integer value, 10 would equal 10 seconds for the timeout.

                      The completed code for Alert would be as follows
                      Code:
                      Alert ("SoundAlert", NinjaTrader.Cbi.Priority.High, "", soundAlert, 5, Color.Black, Color.Yellow);
                      Here is a link to the help guide documentation on Alert listing the overloads it takes and giving example usage.


                      I would recommend taking a look in the help guide on any of the items you are unsure on because most everything has a working generic code example you can copy directly into your script.
                      I did as you suggested but now it`s completely silen.LOL...Not a small task i guess.There`s more to it.

                      Comment


                        #26
                        Hello cachevery,

                        I am not sure where you are running into an issue using the previous code.
                        If it is silent this could be a couple of things,
                        If COBC is set to true then you would need to wait for the bar to close then if your conditions are met it would be called.
                        If COBC is false then it should happen as your conditions are met.
                        Also because you are specifying a different sound file than the example has please make sure it is the correct format and make sure the name is exactly the same in the code as it is on the file. If this is the case please refer to this line of the documentation
                        soundLocation
                        File name of .wav file to play. Provide either the absolute file path or just the name if the file is located in C:\Program Files\NinjaTrader Installation Folder\sounds folder
                        If you would like to test the Alert using generic settings I would recommend starting a new indicator and pasting the following code in the OnBarUpdate()

                        When you run it, it will wait for the bar to close (COBC = true) it will alert you once then wait 10 seconds then alert you again.

                        This is the example from the help guide. This uses the default Alert1.wav that comes with ninjatrader, Alerts using sound every 10 seconds.
                        Code:
                        Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert1.wav", 10, Color.Black, Color.Yellow);
                        Please let me know if I may be of additional assistance.
                        JesseNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by mattbsea, Today, 05:44 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post mattbsea  
                        Started by RideMe, 04-07-2024, 04:54 PM
                        6 responses
                        31 views
                        0 likes
                        Last Post RideMe
                        by RideMe
                         
                        Started by tkaboris, Today, 05:13 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post tkaboris  
                        Started by GussJ, 03-04-2020, 03:11 PM
                        16 responses
                        3,282 views
                        0 likes
                        Last Post Leafcutter  
                        Started by WHICKED, Today, 12:45 PM
                        2 responses
                        20 views
                        0 likes
                        Last Post WHICKED
                        by WHICKED
                         
                        Working...
                        X