• 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

Problem using trade collection

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

    Problem using trade collection

    Hi!

    I'm sorry I have to bug you guys again with one of my small problems.
    This time I'm trying to calculate the Minimum Payoff Ratio of my strategy with this code:


    Code:
    // Minimum Payoff Ratio
    private string MinPayoff = "Not enough trades to calculate Minimum Payoff Ratio";
    private double MinPayoff2 = 1337; // Value is just to see when it prints this.
    
    			if((Performance.AllTrades.WinningTrades.TradesCount == 0) || (Performance.AllTrades.LosingTrades.TradesCount == 0))
    				MinPayoff = "Not enough trades to calculate Minimum Payoff Ratio";
    			else
    			{
    				MinPayoff = "Current Minimum Payoff Ratio is: ";
    				MinPayoff2 = (Performance.AllTrades.LosingTrades.TradesCount / Performance.AllTrades.WinningTrades.TradesCount);
    			}
    
    Print(MinPayoff + MinPayoff2); // Not working
    I have tried making it print just the Performance.AllTrades.LosingTrades.TradesCount (and winning one). Both of those will print out the correct value, however it won't print anything but 0 if I try to use thise code. The result will look like this: Current Minimum Payoff Ratio is: 0

    Anyone have an idea on how I can make it work?

    #2
    Since you're dividing two int's here, I think you need to add more precision to see the floating type results for your ratio - for example, please try this change :

    MinPayoff2 = (double)(Performance.AllTrades.LosingTrades.Trades Count / (double)Performance.AllTrades.WinningTrades.Trades Count);
    BertrandNinjaTrader Customer Service

    Comment


      #3
      That worked like a charm! Thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kweiss, Today, 08:35 PM
      0 responses
      1 view
      0 likes
      Last Post kweiss
      by kweiss
       
      Started by zulok, Today, 05:02 PM
      0 responses
      4 views
      0 likes
      Last Post zulok
      by zulok
       
      Started by Andreas M., Today, 04:42 PM
      0 responses
      2 views
      0 likes
      Last Post Andreas M.  
      Started by sidlercom80, Today, 12:29 PM
      2 responses
      23 views
      0 likes
      Last Post fx.practic  
      Started by itrader46, Today, 02:49 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X