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

RSI Alert

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

  • forextrader2003
    replied
    Originally posted by aligator View Post



    ​​​​​​

    Jesse,

    I wrote this quick simple code in 5 minutes to draw buy and sell arrow signals on price chart when the RSI crosses the 35 and 65 lines. It will just draw arrows on chart but not plot the RSI though.

    Hope it helps.

    Cheers!

    p.s. CrossAbove overloads are more than 2.
    Thank You,

    I use different values than the 35/75, can you please make those values inputs, so we do not have to change them in the code? (I use 22.5 and 77.5 so I would need doubles not integers )

    Thank You Again !!!

    Leave a comment:


  • Tradwell385
    replied
    Thanks, I really appreciate your help.

    Leave a comment:


  • aligator
    replied
    Originally posted by Tradwell385 View Post
    Hi, I am looking for a very simple RSI indicator that plots an up arrow when RSI crosses above a certain level (34) and a down arrow when it crosses below a certain level (66). Is there a code that I could copy and paste into the original RSI coding and then save it as a new indicator "RSICrossover" ?

    Thanks,
    Ian

    Originally posted by NinjaTrader_Jesse View Post
    Hello Tradwell385,

    Thank you for the reply.
    ​​​​​​

    Jesse,

    I wrote this quick simple code in 5 minutes to draw buy and sell arrow signals on price chart when the RSI crosses the 35 and 65 lines. It will just draw arrows on chart but not plot the RSI though.

    Hope it helps.

    Cheers!

    p.s. CrossAbove overloads are more than 2.
    Attached Files
    Last edited by aligator; 01-02-2020, 10:30 PM.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello Tradwell385,

    Thank you for the reply.

    I Just wanted to quickly mention that we are in the NT7 sub forum so the links I had provided were based on that detail. In the future for NT8 questions make sure to post to one of the NT8 sub forums so we can get you the correct info.

    NinjaTrader comes with quite a few samples and one strategy which can be used for learning about crossing conditions. The SampleMACrossover is a good way to see how to use indicators in code along with checking a crossing condition. This specifically uses SMA indicators but you could replace that with the RSI.

    The sample places orders but that can be changed to draw if you didn't want to place orders. You can replace the EnterLong and EnterShort with the appropriate drawings that you wanted.

    https://ninjatrader.com/support/help...hlightsub=draw

    We have a video that covers creating a crossover strategy as well which could help with this concept: https://www.youtube.com/watch?v=HCyt90GAs9k

    The same concepts from this video could be used from within an Indicator. An indicator is generally a better choice for marking the chart, a strategy requires more steps to apply and enable it. You could look at the SampleMACrossOver strategy and then take what you have learned from that and use it from within an indicator. It is generally easiest to start learning with a strategy due to the availability of the strategy builder and also the video covering building a strategy.

    I went back and changed the links in the previous post as well to NT8.

    I look forward to being of further assistance.




    Leave a comment:


  • Tradwell385
    replied
    Thanks,

    I looked through the user indicators and there isn't anything that I am looking for. I'm looking for a very very very simple way of plotting the arrow on the chart when the RSI crosses those levels. I'm using NT8. It'd be great to be able to code this. It seems like it should be easy to do. TD Ameritrade has this crossover strategy built into its interface, so I figured it should be pretty simple to add to the already existing RSI indicator in NT8. I'd love some guidance on how to add this coding. I tried the above code that you copied, but got all kinds of errors. I use the 14, 3 RSI, wilders.

    Thanks again,
    Ian

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello Tradwell385,

    Welcome to the NinjaTrader support forum.

    I would suggest taking a look at some of the user uploads that include RSI to see if any match your description or will fill in for what you want. I was not able to locate one that simply checks if the RSI is above or below but there are some that incorporate SMA's and other indicators to produce signals. You may try looking at the Smarsiv6 indicator on the app share, that seems to have had the closes description that I could find. This can otherwise be created, if you are interested in learning how to do this in NinjaScript I can provide details on that as well.




    If you were to make a condition for this, it would be similar to the following:


    Code:
    if(CrossAbove(RSI(20,3), 34))
    {
         Draw.ArrowDown(this, CurrentBar.ToString(), true, 0, High[0] + TickSize, Brushes.Blue);
    }
    https://ninjatrader.com/support/helpGuides/nt8/crossabove.htm?zoom_highlightsub=crossabove
    https://ninjatrader.com/support/helpGuides/nt8/relative_strength_index_rsi.htm?zoom_highlightsub= rsi
    https://ninjatrader.com/support/helpGuides/nt8/draw_arrowdown.htm




    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 12-31-2019, 03:42 PM.

    Leave a comment:


  • Tradwell385
    replied
    Hi, I am looking for a very simple RSI indicator that plots an up arrow when RSI crosses above a certain level (34) and a down arrow when it crosses below a certain level (66). Is there a code that I could copy and paste into the original RSI coding and then save it as a new indicator "RSICrossover" ?

    Thanks,
    Ian

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


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

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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:






    I look forward to being of further assistance.

    Leave a comment:


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

    Leave a comment:


  • bougie
    replied
    thank you, problem resolved

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • bougie
    replied
    ok, tried that, now getting this:

    Click image for larger version

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

    Leave a comment:


  • Radical
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by bmartz, 03-12-2024, 06:12 AM
4 responses
31 views
0 likes
Last Post bmartz
by bmartz
 
Started by Aviram Y, Today, 05:29 AM
4 responses
11 views
0 likes
Last Post Aviram Y  
Started by algospoke, 04-17-2024, 06:40 PM
3 responses
28 views
0 likes
Last Post NinjaTrader_Jesse  
Started by gentlebenthebear, Today, 01:30 AM
1 response
8 views
0 likes
Last Post NinjaTrader_Jesse  
Started by cls71, Today, 04:45 AM
1 response
7 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X