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

Linear Regression of 2 identical DataSeries different results ?

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

    Linear Regression of 2 identical DataSeries different results ?

    Hi,

    I am trying to figure out why a Linear Regression of the Closes[0] , in this example 10min bar closes , and a custom Data-series which holds Closes of 10min bars apart from index 0 which holds the current 1 tick close, Closes[1][0], gives me a different result even when both data Series are the same ?

    So for example this is the output that shows the output using a print statement. You can see that both Data Sets Close and fast Close are identical but the Linear Regression results, Average and FAverage, are different

    anyone know why this would be ?


    HTML Code:
    22/02/2016 11:00:00 10min Close= 165.14 165.17 165.2 165.22 165.22 165.25 165.24 165.25 165.22 165.13 165.02 164.95 165.08 165.08 165.1 165.09 165.01 164.92 165.04 165.05
    22/02/2016 11:00:00 fast Close  = 165.14 165.17 165.2 165.22 165.22 165.25 165.24 165.25 165.22 165.13 165.02 164.95 165.08 165.08 165.1 165.09 165.01 164.92 165.04 165.05
    Average  = 165.237
    FAverage = 165.192428571428

    #2
    Hello,

    Thank you for the question.

    I would be unsure of the reason with the data you provided, do you instead have syntax that can show this result?

    Without further testing and seeing the syntax used to see what is different it would be impossible to answer.

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

    Comment


      #3
      Well the first data series is just Closes[0].


      For the second DataSeries, fastClose in my primary BarsInProgress I set fastClose to the primary Bar series on the first bar and then for subsequent bars I am setting 1 bar back to the close of the primary bar 1 bar back:-
      Code:
      if(BarsInProgress == 0)
      				{
      					if(CurrentBars[0] == 0)
      						fastClose.Set(0, Closes[0][0]);
      					else
      						fastClose.Set(1, Closes[0][1]);
      
      
      				}
      Then in my secondary bar object I set the 0 index of the fastClose to allways be the most recent tick:-
      Code:
      if(BarsInProgress == 1 && CurrentBars[baseBars] > 1)
      				{
      
      fastClose.Set(0, Closes[1][0]);
      
      
      // linea regresion of my cutom series
      avg =	Average(fastClose, averageBase, 20); 
      
      // linea regression of Closes[0]
      double avg2 = Average(Closes[0],  averageBase, 20);
      
      }
      and my average method in UserMethods is:
      Code:
      public double Average(IDataSeries input, AverageBase averageBase, int sDPeriod)
      		{
      			
      			double avg = 0;
      				
      			switch(averageBase)
      			{
      				case AverageBase.LRC:
      					avg = LinReg(input,sDPeriod)[0];
      					break;
      					
      				case AverageBase.EMA:
      					avg = EMA(input,sDPeriod)[0];
      					break;
      					
      				case AverageBase.WMA:
      					avg = WMA(input,sDPeriod)[0];
      					break;
      					
      				case AverageBase.SMA:
      					avg = SMA(input,sDPeriod)[0];
      					break;
      			}
      			
      			return avg;
      		}

      So you can see from the output in the previous post , even when both series are identical I am getting different results.

      Comment


        #4
        Hello GKonheiser,

        Thank you for your response.

        Can you provide the full Output from the first bar it calculates to the last? If possible can you attach as a .txt file after copying and pasting the information from the Output to the .txt file?

        I look forward to your response.

        Comment


          #5
          Here is the output file from a complete run
          Attached Files
          Last edited by GKonheiser; 02-23-2016, 03:12 PM.

          Comment


            #6
            Hello GKonheiser,

            Thank you for your response.

            May I test the full script on my end?
            If you do not want to attach it here you can send it to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H - 1469781' in the subject line.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 02:12 AM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by briansaul, Today, 05:31 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PaulMohn, Today, 03:49 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by frslvr, 04-11-2024, 07:26 AM
            6 responses
            106 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            6 responses
            26 views
            0 likes
            Last Post trilliantrader  
            Working...
            X