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

Adding and Alert to the CCI Indicator

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

    Adding and Alert to the CCI Indicator

    How to I add a sound alert when CCI crosses overbought/over sold levels?

    #2
    Hello danp502,

    You can modify the CCI indicator by making a copy of it with a different name and then add alerts.

    Please use the steps I have provided below to create a copy of an indicator:
    • In the Control Center select Tools > Edit NinjaScript > Indicator...
    • Select the indicator to copy > Click Ok
    • Right-click within the code window > select Save As
    • Give the indicator a unique name > Click OK


    Below is a link to Alert() in the Help Guide.
    http://www.ninjatrader.com/support/h.../nt7/alert.htm

    Also, because this was a simple change, I have modified the indicator for you so that you have a working example and you can use this to modify other scripts or create your own.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you ChelseaB for the quick response. If I could ask one other thing, Ideally I would like to be able to change the sound file in the indicator window w/o having to edit the indicator script.

      Dan

      Comment


        #4
        Hi Dan,

        Thanks for your note.

        I made that modification so the alert is a parameter.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          Can someone add an alert option to this indicator for me, Please.

          As Chelsea said, I guess a parameter is the answer, as I guess that means it shows up when the indicator is added to a chart, and one can change the sound alert?

          Thank you,

          Joe
          Attached Files

          Comment


            #6
            Hi westcoastjoe,

            Using the example in post #4 you should be able to add a string input parameter that allows you to type a filename and use this as the sound file located in C:\Program Files (x86)\NinjaTrader 7\sounds\.

            In this example we create a string to store the filename with a default value:
            private string soundFile = "Alert1.wav";

            Create a public input the user can type into:
            [Description("Name of file for alert sound located in C:\\Program Files (x86)\\NinjaTrader 7\\sounds\\")]
            [GridCategory("Parameters")]
            public string SoundFile
            {
            get { return soundFile; }
            set { soundFile = value; }
            }

            And use this string for the soundLocation override in the Alert call:
            Alert("CCIcross", NinjaTrader.Cbi.Priority.Low, "CCI Crossed above 100", soundFile, 1, Color.White, Color.Black);
            Alert(string id, Priority priority, string message, string soundLocation, int rearmSeconds, Color backColor, Color foreColor)

            If you want to add an option to turn the alerts on or off, you can use a bool for this. Bool is short for boolean which holds a true or false value.

            For example:
            Create the bool:
            private bool useAlerts = true;

            Create a public input:
            [Description("Use Alerts")]
            [GridCategory("Parameters")]
            public bool UseAlerts
            {
            get { return useAlerts; }
            set { useAlerts = value; }
            }

            In your logic where you want to add the alert use:

            if (/* logic to trigger alert && */ useAlerts == true)
            {
            Alert("myAlert", NinjaTrader.Cbi.Priority.Low, "This is my custom alert", soundFile, 1, Color.White, Color.Black);
            }

            Below is a link to the help guide on Alert().
            http://www.ninjatrader.com/support/h.../nt7/alert.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks, Chelsea,

              I think that is too tough for me at this time.

              Joe

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by junkone, Today, 11:37 AM
              2 responses
              12 views
              0 likes
              Last Post junkone
              by junkone
               
              Started by frankthearm, Yesterday, 09:08 AM
              12 responses
              43 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by quantismo, 04-17-2024, 05:13 PM
              5 responses
              35 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by proptrade13, Today, 11:06 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              35 views
              0 likes
              Last Post love2code2trade  
              Working...
              X