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

Probability Statistic Confirmation

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

    Probability Statistic Confirmation

    I'm sorry to resurrect this thread, but I see this question come up in several other posts and didn't want to re-ask it. I've been playing around with various strategies and have one that indicates 5 trades executing... all 5 hit the profit target. The profit win average is exactly the same as the overall average. Yet the probability is 0. I'm having a hard time understanding what relevance "probability" has. The formula isn't published on the help page (not that I could find). Are we sure that it's working as intended?

    #2
    Hi, thanks for posting.

    You can plug your results into the students t-distribution to find out why this is producing 0, the method will return a 1 for true or 0 for false.
    I found a community members re-implementation:

    Code:
    double div = systemPerformance.AllTrades.TradesPerformance.Percent.StdDev / Math.Sqrt(systemPerformance.AllTrades.TradesCount) ;
    double t = Stat.StudTp(systemPerformance.AllTrades.TradesPerf ormance.Percent.AvgProfit / div, systemPerformance.AllTrades.TradesCount - 1);
    return (div <= 0.5 ? 1 - t : t);
    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I appreciate the response, but I think you have a bug here in the SystemPerformance.AllTrades.TradesPerformance.Perc ent collection.

      btw... the "s" should be capitalized in "SystemPerformance."

      I have run a Print() on just about all the properties in the Percent collection. The numbers returned do not represent anything even close to what they should. I ran this in a backtest strategy that had exactly six trades. Each of them had a take profit of $25. There were no losers. ie, Percent.AverageProfit returns a value of "0.00112206428499886" following the last trade in the dataset. So, if "AverageProfit" "LargestWinner" "LargestLoser" are all returning very similar values to 0.00112206428499886, I didn't bother messing with the rest of the method you posted, nor try to check NT's math on the StdDev.

      Comment


        #4
        I just ran ...Percent.StdDev as well... while the number was small (on the order of 3 x 10^-6) it still was not zero... which is what the std deviation should be for a dataset where all data points are equal (6 trades, $25 each).

        Comment


          #5
          Hello Chippy,

          I will look into these metrics and I will let you know what I find.

          I appreciate your patience.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hello Chippy,

            I've made some output to see if this is calculating correctly. From what I am seeing the numbers are matching.

            Note, that with percent metrics the profit is re-invested into the next trade and is cumulative.

            A sample of the output from the last trade:

            AllTrades.Count: 6, Currency.StdDev: 43.3304118940428, Percent.StdDev: 0.000197012793405613
            2/14/2022 4:20:00 PM | trade.Quantity: 1, trade.ProfitCurrency -37.5, trade.ProfitPercent: -0.000170415814587594
            (profitCurrency: -37.5 / quantity: 1 - currencySumProfit: 162.5 / TradesCount: 6): -64.5833333333333 * (profitCurrency / quantity - currencySumProfit / TradesCount) = 4171.00694444444
            -
            (profitPercent: -0.000170415814587594 - percentSumProfit: 0.000738930258560834 / TradesCount: 6): -0.000293570857681066 * (profitPercent - percentSumProfit / TradesCount) = 8.61838484795968E-08
            √(currencyDevProfit: 11265.1475694444 / TradesCount): 1877.52459490741 = 43.3304118940428
            √(percentDevProfit: 2.32884244592896E-07 / TradesCount): 3.88140407654827E-08 = 0.000197012793405613
            Attached is the full output from 6 trades in the test.
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              The code is working perfectly.

              Comment


                #8
                Hello HelenaMaria,

                Welcome to the NinjaTrader forums!
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Kicks.Spin, Today, 05:16 PM
                0 responses
                6 views
                0 likes
                Last Post Kicks.Spin  
                Started by MrBrunotte, Today, 12:52 PM
                0 responses
                20 views
                0 likes
                Last Post MrBrunotte  
                Started by AndyM, Today, 12:22 PM
                0 responses
                21 views
                0 likes
                Last Post AndyM
                by AndyM
                 
                Started by Carter, Today, 12:07 PM
                0 responses
                7 views
                0 likes
                Last Post Carter
                by Carter
                 
                Started by llanqui, Today, 12:05 PM
                0 responses
                7 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Working...
                X