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

Multi-Timeframe Value Does Not Match With Single Timeframe

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

    Multi-Timeframe Value Does Not Match With Single Timeframe

    Hi all,

    For the life of me I can't figure out why my Indicator values for a multitimeframe indicator is totally different than the indicator values when the indicator is a single-timeframe indicator.

    For example, I applied the following multi-timeframe indicator to a 5-minute chart of the stock RDC with 40 days of data loaded and using the "US Equities RTH" template. The multi-timeframe version adds the Daily chart as an additional dataseries.

    However, the indicator values for the multi-timeframe version don't seem to be working because it is totally different than when I place the rsiSignal dataseries into it's own single-timeframe version and place it on the Daily Chart.

    In addition, it also appears that I'm unable to access the Daily rsiSignal values from the BarsinProgress = 0 portion of the code. The rsiSignal values are returned as 0 which is incorrect.

    Any help would be greatly appreciated.

    Code:
        /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
            protected override void Initialize()
            {
            //    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                Overlay				= true;
    			MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    			Add(PeriodType.Day, 1);
    			CalculateOnBarClose = false;
    			
    			
    			smaValue	= new DataSeries(this);
    			rsiSignal	= new DataSeries(this);
    			
    			
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
               
    			
    				
    			
    			
    			if(BarsInProgress == 1 && CurrentBar > 10) 
    			{
    				
    				daysLoaded = CurrentBar;
    							
    				if(CurrentBar < 10)
    				return;
    			
    			
               	smaValue.Set(SMA(10)[0]);
    			rsiSignal.Set(RSI(smaValue, 5, 2)[0]);
    			
    			Print("DAILY SERIES VALUE");
    			Print("Time = "+Time[0]);
    			Print("rsiSignal = "+rsiSignal[0]);
    			
    			
    			}
    			
    					
    			if(BarsInProgress != 0)
    				return;
    	
    					
    					
    			if(daysLoaded > 10  ) 
    			{
    				Print("INTRADAY SERIES VALUE");
    				Print("Time = "+Time[0]);
    				Print("rsiSignal = "+rsiSignal[0]);
    				
    			}
    			
    				
            }

    #2
    Hello maltese,

    Thank you for your post.

    Please advise the main bar series the indicator is applied to.

    In addition, can you attach your full indicator file (.CS) to your response?
    You will find the indicator int he following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Indicator

    I look forward to your response.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello maltese,

      Thank you for your post.

      Please advise the main bar series the indicator is applied to.

      In addition, can you attach your full indicator file (.CS) to your response?
      You will find the indicator int he following directory on your PC: (My) Documents\NinjaTrader 7\bin\Custom\Indicator

      I look forward to your response.
      Hi Patrick,

      The main bar series is the 5-minute chart with the US Equities RTH session template loaded.

      Attached is the indicator file.
      Attached Files

      Comment


        #4
        Hello maltese,

        Thank you for your response.

        You will need to set the DaysToLoad on your chart to 32 or more days. Please right click in your chart > select Data Series > set the DaysToLoad parameter to 32 or more > OK.

        You should now see the Output correctly in the Output window. This was necessary as RSI for the rsiSignal has a period of 10, add the 20 bars required (default setting for BarsRequired) and you have 30 bars. I used CalculateOnBarClose = true so I had to factor in an additional bar.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello maltese,

          Thank you for your response.

          You will need to set the DaysToLoad on your chart to 32 or more days. Please right click in your chart > select Data Series > set the DaysToLoad parameter to 32 or more > OK.

          You should now see the Output correctly in the Output window. This was necessary as RSI for the rsiSignal has a period of 10, add the 20 bars required (default setting for BarsRequired) and you have 30 bars. I used CalculateOnBarClose = true so I had to factor in an additional bar.

          Please let me know if I may be of further assistance.

          Hi Patrick,

          I had originally tested the indicator with 40 days loaded so I don't think the amount of days loaded is causing the problem. Suffice to say, I tried again with 50 days loaded and still the indicator values are incorrect. Were you able to get it to show the correct values?

          Comment


            #6
            Hello maltese,

            Thank you for your response.

            I did not test this on a Day chart as a single bar series based indicator, please provide the code you use for the single bar series version. I can do this on my end however, I would like to see what you are using.

            In addition, please provide the instrument you are running this indicator on.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello maltese,

              Thank you for your response.

              I did not test this on a Day chart as a single bar series based indicator, please provide the code you use for the single bar series version. I can do this on my end however, I would like to see what you are using.

              In addition, please provide the instrument you are running this indicator on.
              Attached is the single bar version.

              I tested it on stock: RDC
              Attached Files

              Comment


                #8
                Hello maltese,

                Thank you for your patience.

                I used the following and the values were correct:
                Code:
                			if(CurrentBars[0] < 20 || CurrentBars[1] < 20)
                				return;
                			
                			if(BarsInProgress == 1)
                			{
                				
                				daysLoaded = CurrentBar;
                			
                			
                           	smaValue.Set(SMA(BarsArray[1], 10)[0]);
                			rsiSignal.Set(RSI(SMA(BarsArray[1], 10), 5, 2)[0]);
                Please let me know if this resolves the matter.

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello maltese,

                  Thank you for your patience.

                  I used the following and the values were correct:
                  Code:
                  			if(CurrentBars[0] < 20 || CurrentBars[1] < 20)
                  				return;
                  			
                  			if(BarsInProgress == 1)
                  			{
                  				
                  				daysLoaded = CurrentBar;
                  			
                  			
                             	smaValue.Set(SMA(BarsArray[1], 10)[0]);
                  			rsiSignal.Set(RSI(SMA(BarsArray[1], 10), 5, 2)[0]);
                  Please let me know if this resolves the matter.
                  Thanks for your help. I'll see if this worked. Thanks.

                  Comment


                    #10
                    NinjaTrader_PatrickH ...you SIR are a:

                    GENIUS!!

                    thanks that worked!!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    11 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    242 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    387 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X