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

Change the source of RSI & other indis in my strategy to OHLC4 or HLC3

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

    Change the source of RSI & other indis in my strategy to OHLC4 or HLC3

    Hi

    For a strategy that I'm developing I'd like to be able to change the source of the RSI from close, to OHLC/4.

    Please can you give me an idea of the best way to do this?

    I'm assuming when I define the RSI I should pass in the maths to do this, where the source would usually, if you could provide an example that would be great, could you please also confirm which method this should be within, I'm assuming configure?

    Thanks in advance

    #2
    Hello Gav_G,

    Thanks for your post.

    (H+L+C)/3 is provided by the Typical PriceSeries. You could use Typical instead of Close for this case.

    If you want to calculate (O+H+L+C)/4 then you can calculate this in a Series<double> and use that as input for the indicator.

    Example:

    Code:
    public class MyCustomStrategy16 : Strategy
    {
        private RSI RSI1;
        private Series<double> MySeries;
    
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                                    = @"Enter the description for your new custom Strategy here.";
                Name                                        = "MyCustomStrategy16";
                Calculate                                    = Calculate.OnBarClose;
            }
            else if (State == State.DataLoaded)
            {                
                MySeries             = new Series<double>(this);
                RSI1                = RSI(Close, 14, 3);
            }
        }
    
        protected override void OnBarUpdate()
        {
            if (BarsInProgress != 0)
                return;
    
            MySeries[0] = (Open[0] + High[0] + Low[0] + Close[0]) / 4;        
        }
    }
    Additional PriceSeries can be referenced here - https://ninjatrader.com/support/help...riceseries.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, I've had a little think & is the median not the OHLC/4?

      Thanks for the info on typical though...

      Comment


        #4
        Hello Gav_G,

        Median is calculated as High + Low / 2.



        Other PriceSeries can be referenced by clicking on the item in the PriceSeries documentation page linked in post #2.

        Please let me know if you have any additional questions.
        JimNinjaTrader Customer Service

        Comment


          #5
          Brilliant thanks Jim

          Comment


            #6
            Originally posted by NinjaTrader_Jim View Post
            Hello Gav_G,

            Thanks for your post.

            (H+L+C)/3 is provided by the Typical PriceSeries. You could use Typical instead of Close for this case.

            If you want to calculate (O+H+L+C)/4 then you can calculate this in a Series&lt;double&gt; and use that as input for the indicator.

            Example:

            Code:
            public class MyCustomStrategy16 : Strategy
            {
            private RSI RSI1;
            private Series&lt;double&gt; MySeries;
            
            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Description = @"Enter the description for your new custom Strategy here.";
            Name = "MyCustomStrategy16";
            Calculate = Calculate.OnBarClose;
            }
            else if (State == State.DataLoaded)
            {
            MySeries = new Series&lt;double&gt;(this);
            RSI1 = RSI([U][B]MySeries[/B][/U], 14, 3);
            }
            }
            
            protected override void OnBarUpdate()
            {
            if (BarsInProgress != 0)
            return;
            
            MySeries[0] = (Open[0] + High[0] + Low[0] + Close[0]) / 4;
            }
            }
            Additional PriceSeries can be referenced here - https://ninjatrader.com/support/help...riceseries.htm

            We look forward to assisting.

            I'm having some problems with this Jim, I didn't realise but its actually defaulting back to calculating on the 'Close' & not using my custom data series, the only thing I've changed on the above is using MySeries in the RSI declaration in data loaded, can you take a look at the above, should I be doing something else as well?

            Comment


              #7
              Hello Gav_G,

              Thanks for your post.

              I have attached a screenshot showing a test with an RSI based on MySeries and an RSI based on close. I am seeing different values. Please make sure you have set up the same test on your end.

              Let me know if you are seeing something different when testing the same.
              Attached Files
              JimNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Aviram Y, Today, 05:29 AM
              2 responses
              7 views
              0 likes
              Last Post Aviram Y  
              Started by cls71, Today, 04:45 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by TradeForge, Today, 02:09 AM
              1 response
              23 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by elirion, Today, 01:36 AM
              2 responses
              14 views
              0 likes
              Last Post elirion
              by elirion
               
              Working...
              X