Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What does Cbi mean ?

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

    What does Cbi mean ?

    Hi there,

    When trying to develop my custom Optimization Fitness in NT8, I checked the Max Strength Fitness in NT 8, and there is a line like this:

    Code:
    Cbi.TradeCollection trades = strategy.SystemPerformance.AllTrades;
    I guess the whole line is to store information with all trades (all relevant, like number of trades, long trades, shorts trades, profit & loss etc) in the variable "trades" ? But I can nowhere find the specific explanation of "Cbi" (by googling and NT8 reference), any definition on this?

    Thank you !

    #2
    So, what I want is a SQN (System Quality Number) defined as:

    SQN=Sqrt(Number of Trades) * AverageProfit&Loss / StdDev(profit of All trades)

    Code:
    Cbi.TradeCollection trades= strategy.SystemPerformance.AllTrades;
    
    Value=Math.Sqrt(trades.TradesCount)*strategy.SystemPerformance.AllTrades.TradesPerformance.Percent.AverageProfit/strategy.SystemPerformance.AllTrades.TradesPerformance.Percent.StdDev;
    Will this code get what I want? or I have to calculate every trade's profit to give a StdDev?
    Last edited by wolfcuring; 05-30-2019, 02:34 AM.

    Comment


      #3
      Hello wolfcuring, thanks for your post.

      Cbi stands for Common broker interface. Cbi is undocumented, so I don't have any first-hand information on the namespace. The TradePerformance class is documented among other items in Cbi.

      Any account item within AllTrades.TradesPerformance will be in terms of all trades summed together for that optimization period. If you print something out within OnCalculatePerformanceValue you will see the print occur for each optimization of the strategy. Please verify the output by printing out Value at the end of OnCalculatePerformanceValue and compare the output to a test set of data that is verified, e.g.

      Code:
      protected override void OnCalculatePerformanceValue(StrategyBase strategy)
      {
      if(strategy.SystemPerformance.AllTrades.TradesPerformance.Percent.StdDev == 0)
                      return;
      Cbi.TradeCollection trades= strategy.SystemPerformance.AllTrades;
      Value=Math.Sqrt(trades.TradesCount)*strategy.SystemPerformance.AllTrades.TradesPerformance.Percent.A verageProfit/strategy.SystemPerformance.AllTrades.TradesPerform ance.Percent.StdDev;
      Print(Value);
      }
      I look forward to hearing of your results.
      Last edited by NinjaTrader_ChrisL; 05-31-2019, 01:42 PM.

      Comment


        #4
        Hi Chris,

        The SQN worked as expected. while the "protected override void OnCalculatePerformanceValue(StrategyBase strategy)" throw an error like this:
        Code:
         [TABLE="border: 0, cellpadding: 0, cellspacing: 0"]
        [TR]
        [TD="width: 943"]NinjaTrader.NinjaScript.Strategies.M3.OnCalculatePerformanceValue(NinjaTrader.NinjaScript.StrategyBase)': no suitable method found to override[/TD]
         		[/TR]
        [/TABLE]

        Comment


          #5
          Hello wolfcuring, thanks for your reply.

          The error indicates you are overriding OnCalculatePerformanceValue in a Strategy, this method belongs to the NinjaTrader.NinjaScript.OptimizationFitnesses namespace only. I made a test out of your formula you posted, place the attached file within Documents\NinjaTrader 8\bin\Custom\OptimizationFitnesses. In the strategy analyzer, set to run an optimization and set "Optimize on" to SQNTest.

          Kind regards.
          Attached Files
          Last edited by NinjaTrader_ChrisL; 05-31-2019, 01:43 PM.

          Comment


            #6
            Originally posted by NinjaTrader_ChrisL View Post
            Hello wolfcuring, thanks for your reply.

            The error indicates you are overriding OnCalculatePerformanceValue in a Strategy, this method belongs to the NinjaTrader.NinjaScript.OptimizationFitnesses namespace only. I made a test out of your formula you posted, place the attached file within Documents\NinjaTrader 8\bin\Custom\OptimizationFitnesses. In the strategy analyzer, set to run an optimization and set "Optimize on" to SQNTest.

            Kind regards.
            You probably want to correct the code to account for/escape a division by zero. StdDev can be zero, if there is no trade, or if all trades return the exact same profit (unlikely, true).

            Comment


              #7
              Thanks for the catch koganam, posts have been edited to reflect the change.

              Comment


                #8
                Thank for your code Chris, and many thanks to Koganam for your advice, I will add a line to my original code to avoid the zero condition.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                55 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                132 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                73 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                49 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X