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 Uregon, Today, 12:12 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by kerplunk1899, Today, 10:03 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by rexsole, Today, 10:20 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by pjsmith, Today, 03:01 AM
        6 responses
        17 views
        0 likes
        Last Post bltdavid  
        Started by algoroman, Today, 07:40 AM
        1 response
        25 views
        0 likes
        Last Post NinjaTrader_Jim  
        Working...
        X