• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Linear Regression unexpected difference in 2 similar series

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

    Linear Regression unexpected difference in 2 similar series

    I am in the process of creating a data series with historical Tick data that would be the same as say a 10 min Series on Live data with CalculateOnBarClose = false. So this would be where each index = close of 10 mins series and index 0 would be updated on each tick with the current tick price.

    I have studied the differences between historic and live bars and in order to create the custom series the same as live data , once the first tick is seen after the 10 min bars close, I set my custom series, (if its not the tick after the min bar closed I just update index 0 of my custom series)

    Code:
    if(barJustClosed)
    					{
    						Print("First Tick of min bar just seen. Current 1 tickBar = "+ CurrentBars[0] + " Price " + Closes[0][0]);
    						barJustClosed = false;
    						
    						//set our custom series to replicate closings of live bars
    						fastClose[1] = Closes[0][1];
    						fastClose[0] = Closes[0][0];
    					}
    					else
    						//keep custom series updated with current close
    						fastClose[0] = Closes[0][0];

    I have run the attached indicator on the same days data and compared the output of both and despite the series being extremely close,( there are a few ticks difference due to the expected differences due to different data sources.). The Linear Regression of both have huge differences and the Linear Regression of the custom data series is way out from expected values.

    Here is an example of the outputs form the run on Live via Historic ;

    HISTORIC

    BarsInProgress 1 3254
    Current 1 Tick Bar number 163265 Time 20/04/2016 21:46:50 Price 163.27
    fastClose[0] = 163.27
    fastClose[1] = 163.27
    fastClose[2] = 163.27
    fastClose[3] = 163.25
    fastClose[4] = 163.26
    fastClose[5] = 163.26
    fastClose[6] = 163.26
    fastClose[7] = 163.26
    fastClose[8] = 163.26
    fastClose[9] = 163.25
    Time 20/04/2016 21:46:50 LinReg FastClose 163.46872727273
    If you look at all the inputs to the 10 period linear regression of the custom series FastClose the value 163.4687 is way out



    LIVE

    BarsInProgress 1 3254
    Current 1 Tick Bar number 210727 Time 20/04/2016 21:46:49 Price 163.27
    Closes[0] = 163.27
    Closes[1] = 163.27
    Closes[2] = 163.27
    Closes[3] = 163.25
    Closes[4] = 163.26
    Closes[5] = 163.26
    Closes[6] = 163.26
    Closes[7] = 163.26
    Closes[8] = 163.26
    Closes[9] = 163.25
    Time 20/04/2016 21:46:49 LinReg Closes Min Bars 163.270000000002

    So I would like to get to the bottom of why the LinReg on the custom series is so out. I have attached a sample indicator to demo the problem. Couldn't attach the output files as they were to big
    Attached Files

    #2
    Hello GKonheiser,

    Thank you for your post.

    We will test your script and follow up with you here.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by GKonheiser View Post
      I am in the process of creating a data series with historical Tick data that would be the same as say a 10 min Series on Live data with CalculateOnBarClose = false. So this would be where each index = close of 10 mins series and index 0 would be updated on each tick with the current tick price.

      I have studied the differences between historic and live bars and in order to create the custom series the same as live data , once the first tick is seen after the 10 min bars close, I set my custom series, (if its not the tick after the min bar closed I just update index 0 of my custom series)

      Code:
      if(barJustClosed)
      					{
      						Print("First Tick of min bar just seen. Current 1 tickBar = "+ CurrentBars[0] + " Price " + Closes[0][0]);
      						barJustClosed = false;
      						
      						//set our custom series to replicate closings of live bars
      						fastClose[1] = Closes[0][1];
      						fastClose[0] = Closes[0][0];
      					}
      					else
      						//keep custom series updated with current close
      						fastClose[0] = Closes[0][0];

      I have run the attached indicator on the same days data and compared the output of both and despite the series being extremely close,( there are a few ticks difference due to the expected differences due to different data sources.). The Linear Regression of both have huge differences and the Linear Regression of the custom data series is way out from expected values.

      Here is an example of the outputs form the run on Live via Historic ;

      HISTORIC



      If you look at all the inputs to the 10 period linear regression of the custom series FastClose the value 163.4687 is way out



      LIVE




      So I would like to get to the bottom of why the LinReg on the custom series is so out. I have attached a sample indicator to demo the problem. Couldn't attach the output files as they were to big
      It sounds like it is time to make your own copy of the LinReg, and enable some Print() logging to see where the values are getting thrown off.

      Comment


        #4
        I wrote my own method a while back but want to understand what is going wrong with LinReg as mz method gives slightly different results too. Would be nice to see the actual calculation of the LinReg method but I am unable to do that in VS

        Comment


          #5
          Originally posted by GKonheiser View Post
          I wrote my own method a while back but want to understand what is going wrong with LinReg as mz method gives slightly different results too. Would be nice to see the actual calculation of the LinReg method but I am unable to do that in VS
          Yes you can. Just open the indicator. It is open source.

          Comment


            #6
            Hello GKonheiser,

            Thank you for your patience.

            I have included a video and a script in this response to hopefully clear things up for you on this matter. I would also ask that we keep this inquiry to one thread or one email as it will ensure we are providing accurate information on the case.

            The script is attached and the video is at the following link: http://screencast.com/t/wnFeUW9D
            Attached Files
            Patrick H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by priceisking, Today, 01:15 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by 2sureshk, Today, 07:29 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by frayrengytrader, Today, 10:58 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_SergeyS  
            Started by levikNT, Today, 11:28 AM
            3 responses
            27 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by ballboy11, Today, 09:35 AM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X