• 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

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.

        https://ninjatrader.com/support/help...t8/?median.htm

        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(MySeries, 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 Florozmer, Today, 09:32 AM
              0 responses
              8 views
              0 likes
              Last Post Florozmer  
              Started by Hyper, Today, 09:45 AM
              0 responses
              2 views
              0 likes
              Last Post Hyper
              by Hyper
               
              Started by ATMtrader0001, Today, 05:05 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by EnveousColnago, Today, 08:31 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by odeifuor, Today, 09:05 AM
              0 responses
              1 view
              0 likes
              Last Post odeifuor  
              Working...
              X