Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Default RSI Settings with an Automated Strategy

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

    Default RSI Settings with an Automated Strategy

    Hello everyone,

    When I run an automated strategy that involves the usage of an indicator (the RSI in my case) and I have chosen it to be plotted on charts when the strategy is executed, I notice that the setting of the indicator are those defined by NT.
    For example, I would need to display different Overbought/Oversold Levels (not 30/70, but 20/80) and different setting for the color and the width.

    If I manually change them once plotted and then click on the menu "set default for RSI", the next time the strategy loads it, it presents the old NT settings again.

    Any suggestions?

    Thank you,

    John.

    #2
    Hi John, for persisting the changes, please edit the strategy script adding those indicators with the tip shared here - http://www.ninjatrader.com/support/f...ead.php?t=3228
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      thanks for the quick reply.

      I inserted in my strategy the following code:


      {
      Add(RSI(14, 1));
      RSI(14, 1).Lines[0].Value = 80;
      RSI(14, 1).Lines[0].Value = 20;
      RSI(14, 1).Lines[0].Pen.Color = Color.Black;
      CalculateOnBarClose = true;
      }
      but it still gets plotted the "old" way, could you please tell me what is wrong?

      Thank you,

      John.

      Comment


        #4
        Did you compile those codes changes in and then started a new backtest / optimization run?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          No, I simply made the strategy run on a live chart as I did before, but the RSI still displays as "chosen" by NT.

          Comment


            #6
            Yes, but if you make any code changes, you will need to compile your files - otherwise those code changes are not applied at all. Please press F5 in the editor once those codes changes are included and then run a fresh instance of the just compiled strategy.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Done. But still no luck...

              Comment


                #8
                Can you please attach the strategy so we could take a look? Alternatively you could also send it to support at ninjatrader dot com if you not want to post it open here.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Here it is:
                  It was built with wizard. It simply delivers an e-mail alert.
                  It works, but I would simply like to change the way it plots the RSI.

                  Please find the modified code (in bold):

                  #region Using declarations
                  using System;
                  using System.ComponentModel;
                  using System.Diagnostics;
                  using System.Drawing;
                  using System.Drawing.Drawing2D;
                  using System.Xml.Serialization;
                  using NinjaTrader.Cbi;
                  using NinjaTrader.Data;
                  using NinjaTrader.Indicator;
                  using NinjaTrader.Gui.Chart;
                  using NinjaTrader.Strategy;
                  #endregion

                  // This namespace holds all strategies and is required. Do not change it.
                  namespace NinjaTrader.Strategy
                  {
                  /// <summary>
                  /// Sends an e-mail when the price of the instrument hits the specified level and the RSI goes OB
                  /// </summary>
                  [Description("Sends an e-mail when the price of the instrument hits the specified level and the RSI goes OB")]
                  public class AlertSELL : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  private double priceLevelBid = 1; // Default setting for PriceLevelBid
                  private int oBLevel = 80; // Default setting for OBLevel
                  // User defined variables (add any user defined variables below)
                  #endregion

                  /// <summary>
                  /// This method is used to configure the strategy and is called once before any strategy method is called.
                  /// </summary>
                  protected override void Initialize()
                  {
                  Add(RSI(14, 1));
                  RSI(14, 1).Lines[0].Value = 80;
                  RSI(14, 1).Lines[0].Value = 20;
                  RSI(14, 1).Lines[0].Pen.Color = Color.Black;
                  CalculateOnBarClose = true;


                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Condition set 1
                  if (GetCurrentBid() >= PriceLevelBid
                  && RSI(14, 1)[0] > OBLevel)
                  {
                  SendMail("[email protected]", "[email protected]", "Subject", "Text");
                  }
                  }

                  #region Properties
                  [Description("The price that triggers the alert")]
                  [GridCategory("Parameters")]
                  public double PriceLevelBid
                  {
                  get { return priceLevelBid; }
                  set { priceLevelBid = Math.Max(1, value); }
                  }

                  [Description("OB Level for the RSI")]
                  [GridCategory("Parameters")]
                  public int OBLevel
                  {
                  get { return oBLevel; }
                  set { oBLevel = Math.Max(80, value); }
                  }
                  #endregion
                  }
                  }

                  Comment


                    #10
                    Thanks, there are two lines that you would change here, so the 80 level would be the second one at index 1 :

                    Add(RSI(14, 1));
                    RSI(14, 1).Lines[1].Value = 80;
                    RSI(14, 1).Lines[0].Value = 20;
                    RSI(14, 1).Lines[0].Pen.Color = Color.Black;
                    CalculateOnBarClose = true;
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Hi, I have copied and pasted the code as per your last e-mail, but still at the initiating point...

                      Comment


                        #12
                        Sorry Bertrand, it is ok, except that for the color...

                        Comment


                          #13
                          Ok, after copying the changes in, did you compile them in again via the F5 key and then used a fresh instance of the script to test?
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by johnlucas View Post
                            Sorry Bertrand, it is ok, except that for the color...
                            Thanks, the same applied to your color as well - if you want to color the 80 level (your second line)

                            RSI(14, 1).Lines[1].Pen.Color = Color.Black;
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              thank you!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jxs_xrj, 01-12-2020, 09:49 AM
                              5 responses
                              3,290 views
                              1 like
                              Last Post jgualdronc  
                              Started by Touch-Ups, Today, 10:36 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Touch-Ups  
                              Started by geddyisodin, 04-25-2024, 05:20 AM
                              8 responses
                              61 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Option Whisperer, Today, 09:55 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post Option Whisperer  
                              Started by halgo_boulder, 04-20-2024, 08:44 AM
                              2 responses
                              24 views
                              0 likes
                              Last Post halgo_boulder  
                              Working...
                              X