• 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

RSI Alert

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

    RSI Alert

    Hi, I just want a sound alert once the lower or upper limits have been crossed. LineAlert would do the job, as I could just draw the line manually, unfortunately, it seems to only work on price bars, and not the RSI upper and lower lines.

    Thanks.

    #2
    Hello bougie,

    I'm not aware of an existing indicator that does this, however it would be possible with custom programming.

    NinjaTrader is based on the modern C# programming language which allows advanced charting that is extensible in that you can create custom indicators using NinjaScript.

    * Click here for information on programming in NinjaScript

    You would want to use the Alert() method based upon the condition that you would like.
    http://www.ninjatrader.com/support/h...html?alert.htm

    For Example:
    Code:
    if(CrossAbove(High[0], RSI(20, 3),1) || CrossBelow(Low[0], RSI(20, 3),1))
    				Alert("myAlert", NinjaTrader.Cbi.Priority.High, "RSI Alert", "Alert1.wav", 10, Color.Black, Color.Yellow);
    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      hi, sorry i have no experience with coding. Do i copy and paste that line of code into rsi.cs?

      Comment


        #4
        Hello bougie,

        Thank you for your response.

        You would not paste this into the RSI but would follow the instructions below to create a new indicator with the code that JC provided.
        • Go to Tools > New NinjaScript > Indicator
        • Next
        • Name the indicator and select Generate
        • Then paste the code JC created into the OnBarUpdate() method
        • Then press F5 compile

        Once complete you code should look like the following:
        Code:
                #region Variables
        
                #endregion
        
                /// <summary>
                /// This method is used to configure the indicator and is called once before any bar data is loaded.
                /// </summary>
                protected override void Initialize()
                {
                    Overlay				= false;
                }
        
                /// <summary>
                /// Called on each bar update event (incoming tick)
                /// </summary>
                protected override void OnBarUpdate()
                {
                    if(CrossAbove(High[0], RSI(20, 3),1) || CrossBelow(Low[0], RSI(20, 3),1))
        				Alert("myAlert", NinjaTrader.Cbi.Priority.High, "RSI Alert", "Alert1.wav", 10, Color.Black, Color.Yellow);
                }
        
                #region Properties
        
                #endregion
        We have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.

        A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

        I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

        We also have some Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
        Click here to see our NinjaScript Reference Samples
        Click here to see our NinjaScript Tips

        If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
        Click here for a list of certified NinjaScript Consultants

        Please let me know if I may be of further assistance.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          I've tried pasting it, getting many errors, maybe not pasting in right section of code?

          Click image for larger version

Name:	nt error.jpg
Views:	1
Size:	145.2 KB
ID:	866193

          Comment


            #6
            Did you make any modifications to the original @RSI.cs file? Those errors are in the @RSI.cs file, not the file that you have open in that window.

            Comment


              #7
              I tried to paste it originally into rsi.cs... might have screwed up that file possibly, how do I replace the original rsi file now?

              Comment


                #8
                Try opening the @RSI.cs file, deleting everything in it (so it's completely blank), then paste the below code into it:

                PHP Code:
                // 
                // Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
                // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
                //

                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Drawing;
                using System.Xml.Serialization;
                using NinjaTrader.Data;
                using NinjaTrader.Gui.Chart;
                #endregion

                // This namespace holds all indicators and is required. Do not change it.
                namespace NinjaTrader.Indicator
                {
                    
                /// <summary>
                    /// The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
                    /// </summary>
                    
                [Description("The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.")]
                    public class 
                RSI Indicator
                    
                {
                        
                #region Variables
                        
                private DataSeries                    avgUp;
                        private 
                DataSeries                    avgDown;
                        private 
                DataSeries                    down;
                        private 
                int                                period    14;
                        private 
                int                                smooth    3;
                        private 
                DataSeries                    up;
                        
                #endregion

                        /// <summary>
                        /// This method is used to configure the indicator and is called once before any bar data is loaded.
                        /// </summary>
                        
                protected override void Initialize()
                        {
                            
                Add(new Plot(Color.Green"RSI"));
                            
                Add(new Plot(Color.Orange"Avg"));

                            
                Add(new Line(System.Drawing.Color.DarkViolet30"Lower"));
                            
                Add(new Line(System.Drawing.Color.YellowGreen70"Upper"));

                            
                avgUp                = new DataSeries(this);
                            
                avgDown                = new DataSeries(this);
                            
                down                = new DataSeries(this);
                            
                up                    = new DataSeries(this);
                        }

                        
                /// <summary>
                        /// Calculates the indicator value(s) at the current index.
                        /// </summary>
                        
                protected override void OnBarUpdate()
                        {
                            if (
                CurrentBar == 0)
                            {
                                
                down.Set(0);
                                
                up.Set(0);

                                if (
                Period 3)
                                    
                Avg.Set(50);
                                return;
                            }

                            
                down.Set(Math.Max(Input[1] - Input[0], 0));
                            
                up.Set(Math.Max(Input[0] - Input[1], 0));

                            if ((
                CurrentBar 1) < Period
                            {
                                if ((
                CurrentBar 1) == (Period 1))
                                    
                Avg.Set(50);
                                return;
                            }

                            if ((
                CurrentBar 1) == Period
                            {
                                
                // First averages 
                                
                avgDown.Set(SMA(downPeriod)[0]);
                                
                avgUp.Set(SMA(upPeriod)[0]);
                            }  
                            else 
                            {
                                
                // Rest of averages are smoothed
                                
                avgDown.Set((avgDown[1] * (Period 1) + down[0]) / Period);
                                
                avgUp.Set((avgUp[1] * (Period 1) + up[0]) / Period);
                            }

                            
                double rsi      avgDown[0] == 100 100 100 / (avgUp[0] / avgDown[0]);
                            
                double rsiAvg = (2.0 / (Smooth)) * rsi + (- (2.0 / (Smooth))) * Avg[1];

                            
                Avg.Set(rsiAvg);
                            
                Value.Set(rsi);
                        }

                        
                #region Properties
                        /// <summary>
                        /// </summary>
                        
                [Browsable(false)]
                        [
                XmlIgnore()]
                        public 
                DataSeries Avg
                        
                {
                            
                get { return Values[1]; }
                        }

                        
                /// <summary>
                        /// </summary>
                        
                [Browsable(false)]
                        [
                XmlIgnore()]
                        public 
                DataSeries Default
                        {
                            
                get { return Values[0]; }
                        }
                        
                        
                /// <summary>
                        /// </summary>
                        
                [Description("Numbers of bars used for calculations")]
                        [
                GridCategory("Parameters")]
                        public 
                int Period
                        
                {
                            
                get { return period; }
                            
                set period Math.Max(1value); }
                        }

                        
                /// <summary>
                        /// </summary>
                        
                [Description("Number of bars for smoothing")]
                        [
                GridCategory("Parameters")]
                        public 
                int Smooth
                        
                {
                            
                get { return smooth; }
                            
                set smooth Math.Max(1value); }
                        }
                        
                #endregion
                    
                }

                That was taken directly from my stock @RSI.cs file.

                Comment


                  #9
                  ok, tried that, now getting this:

                  Click image for larger version

Name:	nt err 1.jpg
Views:	1
Size:	150.3 KB
ID:	866196

                  Comment


                    #10
                    Originally posted by bougie View Post
                    I've tried pasting it, getting many errors, maybe not pasting in right section of code?

                    [ATTACH]23554[/ATTACH]
                    That shows errors in the shipping NT system indicator. It is hard to see how you could have such an error unless you edited the file outside of the NT editor, as the NT editor would not save any changes to NT system files. As it is hard to know what else may now be corrupted, you would be best off reinstalling NT, then following the instructions that were so clearly written by NinjaTrader_PatrickH.

                    Comment


                      #11
                      thank you, problem resolved

                      Comment


                        #12
                        Hello, I am trying to find an alert on the RSI on the crossover do you have any information on that procedure?

                        Comment


                          #13
                          Hello boldhead,

                          Welcome to the NinjaTrader support forums.

                          Assuming that you are not doing the same steps which the original poster had you should be able to just copy the syntax from post #2 into a new indicator or strategy to make an alert from the RSI. The other content in this thread is related to the users specific situation and will not likely apply toward your situation.

                          You can learn more about this syntax from the help guide:

                          https://ninjatrader.com/support/help...lightsub=alert
                          https://ninjatrader.com/support/help...tsub=crossover
                          https://ninjatrader.com/support/help...ghlightsub=rsi


                          I look forward to being of further assistance.
                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            Hi Jessie. I looked over there information how do I take this information and put it into a crossover alert for the RSI?

                            Comment


                              #15
                              Hello boldhead,

                              The information in this post is for NinjaScript, so this assumes that you are developing a strategy or indicator already. Once you have created a strategy or indicator, you could utilize the syntax from post #2 to form an alert. The syntax is complete in that post, you would just need to make your script look the same to start working with alerts.

                              I look forward to being of further assistance.

                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Papercut110, Today, 09:08 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Papercut110  
                              Started by iq200, 11-09-2019, 08:26 AM
                              5 responses
                              56 views
                              0 likes
                              Last Post koganam
                              by koganam
                               
                              Started by johng964, Today, 02:57 PM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_RyanS  
                              Started by spamula, Today, 03:00 PM
                              2 responses
                              16 views
                              0 likes
                              Last Post spamula
                              by spamula
                               
                              Started by MARTIN MARTIN, Today, 01:01 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post MARTIN MARTIN  
                              Working...
                              X