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

Custom indicator values change when "Days to load" changes

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

    Custom indicator values change when "Days to load" changes

    Hello,

    I've been experimenting with a custom indicator I found on the site a while back called "SpreadZScore". Please see attached code.

    Here is the problem I'm seeing and how it can be replicated: Load this indicator onto a 5 minute chart with say, 10 days of data. Take note of the last printed value of the indicator. Now modify the chart's data series to show 20 days of data. Look at the last printed indicator value again... it will be different than what you saw on the 10 day chart.

    I believe there is a problem with the way the DataSeries is set up, but I can't figure out how to correct this.

    Thanks in advance for any assistance with this. I see some great potential in this indicator but need to know it shows consistent values regardless of the size of the chart.

    Fred
    Attached Files

    #2
    Hi fredb987,

    This is not an NT provided indicator so unfortunately we won't be able to provide much insight on expected behavior. Best may be to PM the author directly with your observations.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by fredb987 View Post
      Hello,

      I've been experimenting with a custom indicator I found on the site a while back called "SpreadZScore". Please see attached code.

      Here is the problem I'm seeing and how it can be replicated: Load this indicator onto a 5 minute chart with say, 10 days of data. Take note of the last printed value of the indicator. Now modify the chart's data series to show 20 days of data. Look at the last printed indicator value again... it will be different than what you saw on the 10 day chart.

      I believe there is a problem with the way the DataSeries is set up, but I can't figure out how to correct this.

      Thanks in advance for any assistance with this. I see some great potential in this indicator but need to know it shows consistent values regardless of the size of the chart.

      Fred
      I do not even get that far. I tried it with /TF as the main instrument, and ^SP500 as the hedge on a 5 minute time frame. I get the error: "Error on calling 'OnBarUpdate' method for indicator 'SpreadZScore' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

      You might want to call on the author to correct his script, as this is one that has been posted for sharing.

      Comment


        #4
        Solved

        This additional code at the beginning of OnBarUpdate seems to correct the problem:

        Code:
        protected override void OnBarUpdate() /////////////////////////////////////////////
                {
        			if (BarsInProgress != 0)
        				return;
        			
        			if (CurrentBar == 0)
        			{
        				zPlot.Set(0);
        				mySpread.Set(0);
        				Value.Set(0);
        			}
        			else
        				
        			if (CurrentBars[0] < zPeriod || CurrentBars[1] < zPeriod)
                		return;
        		
        			//Calculate spread
        
        ...
        Last edited by fredb987; 02-20-2012, 01:42 PM. Reason: typo

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,603 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X