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 IDataSeries input custom strategy

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

    RSI IDataSeries input custom strategy

    Dear Support,

    From the manual it seems you can use the following RSI
    RSI(IDataSeries input, int period, int smooth)

    The idea is to test the difference between H,C,O,L,(H+L/2), etc.

    I've tried to integrate that in a custom strategy but without success so far. This is an extract of my code:

    #region Variables
    // Wizard generated variables
    private string vinputrsi = @"Close"; // Default setting for Vinputrsi
    ...
    // Condition set 1
    if (CrossAbove(RSI(Vinputrsi, 14, 3), 20, 1)
    ...
    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public string Vinputrsi
    {
    get { return vinputrsi; }
    set { vinputrsi = value; }
    }

    I have the following errors message CS1502 and NT1503 when I try to compile the custom strategy.

    Any brilliant ideas?
    Kind regards,

    Chris

    #2
    Hi Chris, it would not take a string as input but an IDateSeries - http://www.ninjatrader.com/support/h...dataseries.htm

    If you would like to optimize the input series to drive your strategy, I would simply assign a int to each case and then optimize the int public input in the Strategy Analyzer.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Sorry Bertrand, this time I don't get it.

      RSI is usually calculated with the Close but it can be customize to another price e.g. open, high, low, etc.

      That is why I choose to create a custom variable as a string and not an integer?

      Am I wrong?

      Comment


        #4
        Yes, you could not pass a string into the RSI overload that would expect an IDataSeries type.

        If you to select / optimize the input series driving the RSI calcs, then set this with a public Integer as needed or change the passed in series for the RSI according to what string value you entered in the public string input.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          You're going beyond my limited coding abilities. do you have an example I could copy? I've been searching the forum since your last reply for an answer I could copycat but everything I've tried does not work.

          RSI(Open, 14, 3), 20, 1) OR RSI(High, 14, 3), 20, 1) works directly but (High+Low)/2 not.

          Thank you, chris

          Comment


            #6
            Chris, correct the first 2 would work - Open and High are data-series so the RSI method could work with it. For the your 3rd one, try passing in the Median : RSI(Median, 14, 3);
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you for the Median but if I wanted to test e.g. (H+O+L+C)/4?
              Also how can I optimize between these price series?

              I am still struggling with the public int or public string you've advised.

              Apologies for being slow

              Comment


                #8
                You would need to create a DataSeries for this and custom calculate it first and then pass this to the RSI method :

                mySeries.Set((Open[0] + Close[0] + High[0] + Low[0]) / 4);

                double myRSI = RSI(mySeries, 14, 3)[0];

                For compiling this snippet, you need to have in variables :

                private DataSeries mySeries;

                and then in the Initialize() :

                mySeries = new DataSeries(this);

                For the optimization, you would define a public int input and then calculate the RSI on different dataseries / price types for each setting so

                if (myInt == 1)
                RSI(Close....)

                if (myInt == 2)
                RSI(Median...)

                ....
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Thank you very much sir. I was far from seeing this complexity. This is very useful and I'll give it try. Chris

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Sparkyboy, Today, 10:57 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post Sparkyboy  
                  Started by TheMarlin801, 10-13-2020, 01:40 AM
                  21 responses
                  3,917 views
                  0 likes
                  Last Post Bidder
                  by Bidder
                   
                  Started by timmbbo, 07-05-2023, 10:21 PM
                  3 responses
                  152 views
                  0 likes
                  Last Post grayfrog  
                  Started by Lumbeezl, 01-11-2022, 06:50 PM
                  30 responses
                  812 views
                  1 like
                  Last Post grayfrog  
                  Started by xiinteractive, 04-09-2024, 08:08 AM
                  3 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Working...
                  X