Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Regression

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

    Regression

    declared double

    Code:
    		private Series<double> reg;
    Code:
    			else if (State == State.Configure)
    			{
    				AddDataSeries(SYM_S, Data.BarsPeriodType.Day, 1,Data.MarketDataType.Last);	
    				AddDataSeries(SYM, Data.BarsPeriodType.Day, 1,Data.MarketDataType.Last);	
    				reg = new Series<double>(this, MaximumBarsLookBack);
    
    			}
    defined:

    Code:
    				reg[0] =  SystemPerformance.AllTrades.TradesPerformance.Percent.CumProfit;
    				LinReg1= LinReg(reg,2);
    				Print(string.Format("{0};{1};{2};{3}", Time[0], LinReg1[0],SystemPerformance.AllTrades.TradesPerformance.RSquared, SystemPerformance.AllTrades.TradesPerformance.Percent.CumProfit));
    what's wrong with this code? the output seems to be identical to tradesperformance.percent.cumprofit. I tried changing the period for LinReg(reg,2) to 14 and other numbers but the output seems to be "almost" identical to cum.profit.

    Code:
    				reg[0] =  SystemPerformance.AllTrades.TradesPerformance.Percent.CumProfit;
    				LinReg1= LinReg(reg,14);
    				LinRegIntercept1=LinRegIntercept(reg,14);
    				LinRegSlope1=LinRegSlope(reg,14);		
    				Print(string.Format("{0};{1};{2};{3};{4}", Time[0], LinReg1[0],LinRegSlope1[0], LinRegIntercept1[0],SystemPerformance.AllTrades.TradesPerformance.Percent.CumProfit));
    linregintercept is identical to cum.profit as well.
    Last edited by staycool3_a; 09-02-2018, 03:05 PM.

    #2
    Hello staycool3_a,

    Have you printed the values being saved to the reg series and done the math for the number of bars provided to LinReg() to indicate the value is incorrect?

    Likely there are going to be several consecutive bars in a row that have the same value over and over unless the strategy performance is changing rapidly.

    Is it possible that the values are correct?
    What values have you calculated?

    Can you provide output with the values you have calculated for each bar and the values produced when providing these values to the LinReg() indicator?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello staycool3_a,

      Have you printed the values being saved to the reg series and done the math for the number of bars provided to LinReg() to indicate the value is incorrect?

      Likely there are going to be several consecutive bars in a row that have the same value over and over unless the strategy performance is changing rapidly.

      Is it possible that the values are correct?
      What values have you calculated?

      Can you provide output with the values you have calculated for each bar and the values produced when providing these values to the LinReg() indicator?
      thats an excellent point. i think you're right. the values could be right but they're different from the values that I have b/c many bars have the same values over and over again. the values i have are from trade performance report (values as of close of trade). so in other words, if i had 50 trades, only 50 values are being used for regression analysis. but b/c OBC is being updating every single bar.. the reg[0] has many stale values.

      hmmm how to clean this data out so to only look at the aggregate trade performance values as of last trade.

      Comment


        #4
        Hello staycool3_a

        I would recommend you use the same logic over an array instead of a series and an indicator call.

        However, how you choose to design the logic is up to you.

        To confirm, however, your calculated values are the same as the indicator calculated values, is this correct?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello staycool3_a

          I would recommend you use the same logic over an array instead of a series and an indicator call.

          However, how you choose to design the logic is up to you.

          To confirm, however, your calculated values are the same as the indicator calculated values, is this correct?
          Yup, they are.

          Comment


            #6
            Originally posted by staycool3_a View Post
            how to clean this data out so to only look at the aggregate trade performance values as of last trade.
            Keep a bookmark of the index in the trade collection of where the trade starts, then only process the trade collection elements from your bookmark index to the end of the collection, after processing is complete reset your bookmark index to the end of the collection.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            49 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            66 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X