Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RSI averages not same as chart's avgs

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

    RSI averages not same as chart's avgs

    Hello,

    This chart shows RSI average values that are not the same as the Data Box's RSI average values. I thought the index [1], etc would pull the correct values but it is not. Is the syntax incorrect somewhere in the code? See chart in attached.

    Thanks in advance!

    Code:
    namespace NinjaTrader.Strategy
    {
        public class ShowRSIvalue : Strategy
        {
            #region Variables
    		private DataSeries rsi;
    		private DataSeries avg;
            #endregion
    
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
    			Add(RSI(9,3));
    			rsi = new DataSeries(this);
    			avg = new DataSeries(this);
            }
            protected override void OnBarUpdate()
            {
    			rsi.Set(Math.Round((RSI(9,3)[0]),2));
    			avg.Set(Math.Round((RSI(9,3)[1]),2));
    			DrawTextFixed("RSI", "RSI 0: " + rsi[0] + "  " + avg[0]
    			+ "\nRSI 1: " + rsi[1] + "  " + avg[1]
    			+ "\nRSI 2: " + rsi[2] + "  " + avg[2]
    			+ "\nRSI 3: " + rsi[3] + "  " + avg[3]
    			+ "\nRSI 4: " + rsi[4] + "  " + avg[4]
    			+ "\nRSI 5: " + rsi[5] + "  " + avg[5]
    			,TextPosition.Center,Color.Yellow,new Font("Arial",18),Color.Black,Color.Black,10);
            }
    Attached Files

    #2
    Hello,

    Thank you for the question.

    I am looking at the Image you have provided and would like to clarify your question.

    I see that in the image you have the mouse hovering 1 bar in the past, the code which is getting the RSI for 1 bar in the past is the same value.

    Can you please clarify the question as to what you are trying to correct?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Data Box's RSI avg has 52.48 while chart's text has 50.31. All the remaining averages on the chart are not same to Data Box's values (Avg) when pointing specific bar. See next chart attached.

      Thanks.
      Attached Files

      Comment


        #4
        The code of your strategy is flawed.

        Math.Round((RSI(9,3)[1]),2) calls the RSI 1 bar ago.

        If you wish to call the RSI average for the current bar, then the correct formula would be

        Code:
        avg.Set(Math.Round(RSI(9,3).Avg[0],2);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mmenigma, 01-23-2024, 09:37 AM
        1 response
        85 views
        0 likes
        Last Post Nin8aTrender  
        Started by wbayne333, 02-22-2021, 01:18 PM
        6 responses
        408 views
        0 likes
        Last Post Nin8aTrender  
        Started by gtheaded, 07-03-2020, 03:47 PM
        3 responses
        367 views
        0 likes
        Last Post Nin8aTrender  
        Started by theminster, Today, 03:12 PM
        0 responses
        10 views
        0 likes
        Last Post theminster  
        Started by AyeSir, Today, 03:01 PM
        0 responses
        11 views
        0 likes
        Last Post AyeSir
        by AyeSir
         
        Working...
        X