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 JTizz, Today, 03:32 PM
        1 response
        35 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by ebaydan777, Today, 02:41 PM
        1 response
        28 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by aligator, Today, 02:28 PM
        1 response
        27 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by daniel_weber8, Today, 01:21 PM
        1 response
        45 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by jungsoohuh, Today, 12:07 PM
        1 response
        37 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X