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 Rapine Heihei, 04-23-2024, 07:51 PM
        2 responses
        30 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        943 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        9 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Working...
        X