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

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 usazencort, Today, 01:16 AM
            0 responses
            1 view
            0 likes
            Last Post usazencort  
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            603 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            22 views
            0 likes
            Last Post xiinteractive  
            Started by Pattontje, Yesterday, 02:10 PM
            2 responses
            20 views
            0 likes
            Last Post Pattontje  
            Started by flybuzz, 04-21-2024, 04:07 PM
            17 responses
            230 views
            0 likes
            Last Post TradingLoss  
            Working...
            X